On 11/12/2015 at 04:46, xxxxxxxx wrote:
Cinema 4D Version: 16.011
Platform: Windows ;
Language(s) : C++ ;
I'm working on an generator object, that potentially depends on lots of other objects in different ways, so cache handling is potentially tricky. So here is a bit of context and two three questions:
Historically the plugin uses BaseObject::NewDependenceList(), BaseObject::AddDependence() and BaseObject::CompareDependenceList() to check for changes of any child or linked input object. The idea of doing it this way originated here:
There has been no confirmation yet (at least not in that thread), whether this is actually legal. The documentation doesn't explicitly state any more that it *has* to be a child object, but still isn't exactly verbose. It has been working for a while now, so I guess that's ok.
I also manually walk through the full hierarchy of all real child objects (not the linked objects) and call BaseObject::Touch(), to make sure they aren't marked as input objects and therefore not displayed any more. I think I can't use BaseObject::TouchDependenceList(), because that would touch objects that are merely linked as well. Again, a confirmation would be awesome.
Now on to the questions:
(1) Certain linked objects may be placed in the scene further down than my generator object. Since the evaluation of a scene seems to mostly conform to the order the objects are placed in the Object Manager, that means I'd potentially use an old state (at least when I'm using their cache geometry) and they would then get updated after I evaluate my own generator. Is there a way around that? I guess MoGraph has a similar problem when the Cloner is used to place objects on another object.
(2) I am also linking scene materials, not just other objects in the scene. What's the recommended way to track changes with those? I guess the dependence list doesn't work there, because BaseObject::AddDependence() takes BaseObject* as input and the documentation explicitly mentions objects. However, I haven't tried. Do I have to manually track the dirty counter in these cases?
(3) The most important question: For certain rendering optimizations to work, I would need to enforce that the caches of the child objects are built, even though I don't use them directly within ObjectData::GetVirtualObjects(). The only way I currently see to force evaulation of their cache is to call BaseObject::GetHierarchyClone() on the child objects. That seems wasteful, however, because it also generates a clone (which I'd then just discard). Also my impression is that this function messes with my dependence list. Is there a way to make sure the child caches are built without doing anything with the dependence list and/or creating a clone? Alternatively it would be good to know what BaseObject::GetHierarchyClone() does exactly and whether I can perhaps deal with it. Does it perhaps just call BaseObject::AddDependence()?
Would be really great to get some input on this. Furthermore, since topics like these keep coming up, it would perhaps be great to have a comprehensive page on working with the caching system (perhaps including some of the most common workarounds)? I think this is one of the trickier things to wrap ones head around.