URL processing options, useful when saving scene to file#636
URL processing options, useful when saving scene to file#636janadamec1 wants to merge 37 commits intomasterfrom
Conversation
- Useful for TDesignFrame.ExportToModel but also other saving routines (like from castle-model-viewer/converter) - Exposes various ways to process URLs (only 2 are implemented so far: none, and convert casttle-data to relative)
…lso prepare the subdirectory at processing start for copy-to-subdir option.
…os and saving with URL processing.
|
Thank you! Please add some automatic tests (1. that ProcessUrls works right, 2. that DeepCopy of prototypes works right). Because this is a difficult thing to test, there are various options. Let's use automated testing to help us (and ensure it will keep working forever :) ). Short primer how to add tests: You can test running the test suite in "tests/" , see tests/README.md . Short version: compile the project there, and run it :) At the beginning, just run all tests, to make sure it is OK (it should be -- GitHub Actions also check it). I usually use the "--console" and "--filter xxx" options when developing a new test. So I would add a method like "TestProcessUrls" to TTestX3DNodes (or maybe several methods) and then continue checking Of course you can compile and run the testsuite as you like, and use GUI or console runner, whatever is comfortable to you. The tests don't need to be anything complex, it can be as simple as providing some hardcoded input and looking does it match hardcoded output. Like procedure TTestX3DNodes.TestProcessUrlsEmbed;
begin
RootNode := TX3DRootNode.Create;
...
ImageTexture.SetUrl('textures/my.png');
// add ImageTexture to some ShapeNode within RootNode
TempLocation := GetTempFileName + '.x3d.';
ProcessUrls(RootNode, TempLocation, suEmbedResources);
AssertTrue(ImageTexture.Urls.Count = 1);
AssertTrue(IsSuffix('data:', ImageTexture.Urls[0]));
finally ... FreeAndNil everyhing :) end;
end; |
|
Sorry for a delay with this, I have this on a list of TODOs for next week! I see there are 2 conflicts with this PR, if you want to help me you can solve them. But you can also ignore them, I can do them too next week, look trivial :) Just conflicts around LPK / LPI that we indeed changed in CGE master in the meantime. |
|
No problem, I will merge it into master once the library_update PR is merged (working on it now) |
This adds ProcessUrls procedure with several options in TUrlProcessing:
Usage is implemented in CastleEditor, deprecated_library, and url-processing branch in CastleModelViewer/Converter. The check in GUI, the options are exposed as Radio menu items under Save As... command.