Scene Data Custom data not saved
pciccone
Posts: 661
Hi.
According to a previous post I wrote a custom class to implement a way of saving custom data in the Studio scene.
This is the registration of the classes involved:
DZ_PLUGIN_CLASS_GUID( ReSceneBlock, XXX );
DZ_PLUGIN_CLASS_GUID( ReStorage, YYY );
DZ_PLUGIN_REGISTER_SCENEDATA_EXTRA_OBJECT_IO( "ReSceneDataBlock", ReStorage, ReSceneBlock );
ReSceneBlock is a subclass of DzSceneData and ReStorage is a subclass of DzExtraSceneDataIO.
The ctor for ReSceneBlock is:
ReSceneBlock() : DzSceneData(RE_DS_SCENEDATA_ID, true) {
};
When saving a scene with Gen4 figures everything works as expected. ReStorage is created, the methods are called and the DUF file gains a ReSceneDataBlock block with the data stored.
When using a TriAxis figure, Genesis, Genesis2 or even Dawn no data is stored. The class ReStorage is not created and called in that scenario.
What can be the cause of this behavior?
Thanks in advance.
Comments
What triggers the original ReSceneBlock to be created? the nodeAdded signal?
It seems to be the starting of a new scene but that class has nothing it. All the work is done in the ReStorage class.
Thanks.
When loading a cr2 character, such as gen4 figures, the system always does a merge into the existing scene.
- This means your ReSceneBlock is left intact.
When loading a duf file, such as the figures you noted, when the scene is "empty" the system will do a file open.
- This means that the scene is cleared including clearing your ReSceneBlock
I am pretty sure you want to create a ReSceneBlock anytime the dzScene emits a sceneCleared
All right, I checked the events.
The ReSceneBlock is created automatically at the creation of a new scene. I don't explicitly create it. I assume that the creation is done by Studio because of the DZ_PLUGIN_REGISTER_SCENEDATA_EXTRA_OBJECT_IO macro.
If I add V4 and save then the data is saved. When the scene is getting saved Studio creates a ReStorage object and calls the shouldWrite() method in it.
If I keep the scene with V4 and add Genesis 2, change the materials in Reality, save then scene, then everything is fine
If I clear the scene with Cmd-N then a new ReSceneBlock is created
If I then add Genesis 2 the ReSceneBlock is deleted and no new one is created by Studio
What should I do in this case? I assume that Studio creates the ReSceneBlock object and stores it in its ow catalog. If you can provide details on how to make this work I will be most grateful.
Do a dzScene->addDataItem(new ReSceneBlock) anytime dzScene emits a sceneCleared.
But I must admit I am confused. It sounds like you never create an ReSceneBlock manually. Do you have your preferences setup so that you load a File when you do a Cmd-N, look in Preferences -> Scene -> On New ?
Thank you, I will try it.
No, there is no file set for the "On New" option. You are correct, I never create a ReSceneBlock manually.
So, the fact that it is created automatically is strange? Will the new instance that I create manually interfere for the times when Studio creates it automatically?
Cheers.
Hi.
I have to retract that I said before. I looked at the code again and found that indeed I create a new ReSceneBlock() manually in a slot that is called in answer to the sceneCleared() signal. Apologies for confusing the issue.
I also create the ReSceneBlock instance in the startup() method of the plugin. Should I avoid doing that?
I found the issue.
There was a condition that cause the code that create the ReSceneBlock instance to not execute.
Sorry for the false alarm. I appreciate the help.