BaseContainer Size Limitations? [SOLVED]
-
On 25/08/2014 at 00:31, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
Hello Forum,Is there a limit to how much data can be stored in a BaseContainer? To be specific, is it safe to store 500 Int32s in a SubContainer?
I'm working on a DescriptionToolData plugin that needs to keep track of the selection order of points. The selection order can be tracked in the ToolData plugin just fine, but the plugin should also be able to undo/redo selection changes made by the user.
I have created a class that wraps SubContainer and can be used like an array. I can insert a SubContainer on the op and Set, Get and Delete Int32s just fine while getting undo/redo functionality. I don't think speed is a big issue because this plugin is only for modeling. It all seems to work fine on my systems but it brings up a few questions:
1. Is it ok to leave BaseContainer data hanging around on the op when the scene is saved or the op gets copied to a new document?
2. Is it bad form to use use a BaseContainer like an array?
I also tried using GetMemory and SetMemory to write arrays to the SubContainer with success. If I use this approach, I would still need to know a max capacity for BaseContainers. This approach seems more sound, but while testing to see what would happen if this container was accessed with Python, C4D would crash. I don't know if this is a huge deal or not?
After reading many posts(thanks for all of the great info!) I have also figured out how to do this with a SceneHook plugin storing the selection changes in a member variable while also overriding Read/Write/CopyTo to get undo/redo functionality. This seems like a lot of overhead for undo/redo but feels even more sound. This approach also brings up a few more questions:
1. Is it bad form to leave array data on the SceneHook node when the scene gets saved?
2. What actually happens when a SceneHook plugin is not installed on a NetRender or TeamRender client and a scene containing the SceneHook node is rendered? Can this cause errors on render farms? I exported scenes as XML and could find the SceneHook plugin id when the plugin was installed. When the plugin was removed and the scene saved, the plugin id was not present in the xml document.
Any advice would be appreciated.
Thank you,
Joe Buck
-
On 25/08/2014 at 01:32, xxxxxxxx wrote:
- As long as the data is still required, no. But it will be floating around consuming RAM and
HD space, which is wasteful if the data is not required anymore. - Yes, it is. BaseContainer's are implemented like a list. Access time is therefore O(i). Using
GetMemory()/SetMemory(), you have to take byte order into consideration to prevent failure
on different systems. - See #1
- It will not cause errors. SceneHooks are not issued as "missing plugins".
After reading many posts(thanks for all of the great info!) I have also figured out how to do this with a SceneHook plugin storing the selection changes in a member variable while also overriding Read/Write/CopyTo to get undo/redo functionality. This seems like a lot of overhead for undo/redo but feels even more sound.
Read/Write/CopyTo should be your way to go. It's clean, simple, faster and requires less memory
on RAM and HD (since you will most likely not store the array associative?Best,
-Niklas - As long as the data is still required, no. But it will be floating around consuming RAM and
-
On 25/08/2014 at 07:19, xxxxxxxx wrote:
Thanks Niklas! You have answered all of my questions.