THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/05/2004 at 03:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.503
Platform: Windows ;
Language(s) : C++ ;
---------
Hi forum,
I have some very basic questions. At the moment I'm trying to understand how C4D handles internal caches and how it decides wether an objet is dirty or not. Furthermore I want to know how DependenceLists work, and what they are I think by understanding GetAndCheckHierarchyClone all this will be much clearer for me and other beginners.
So here is the function as found in c4d_baseobject.cpp. I try to comment it as far as my little understanding goes. Maybe one of you may help me further.
Thanx in advance
BaseObject *PluginObject::GetAndCheckHierarchyClone(HierarchyHelp *hh, BaseObject *op, LONG flags, Bool *dirty, AliasTrans *trans, Bool allchilds)
{
BaseObject *res=NULL,*tp=NULL,*dp=NULL;
/* here the cache and the data is checked. If the cache doesn't represent the objects current state or the data was modified the variable dirty gets TRUE. That means CheckCache() returns TRUE if the Cache is not valid, correct?*/
*dirty = *dirty || CheckCache(hh) || IsDirty(DIRTY_DATA);
/* if dirty is FALSE this code is executed. That means it's only executed if everything's OK and C4D can use the cache instead of generating the object again.*/
if (!(*dirty))
{
/* A new DependenceList is created. Some questions arise here. Where is it created as the function doesn't return anything? Is it correct that every ObjectPlugin Object has only one DependenceList and this commands resets it to the defaults? I've no real clue.*/
NewDependenceList();
/* the if statement decides wether the whole hierarchy has to be browsed. But what does GetHierarchyClone here, as the returned clone is not stored or used anywhere. My first idea was, that the function only modifies the dirty variable, correct?*/
if (!allchilds)
GetHierarchyClone(hh,op,flags,dirty,trans);
else
{
for (tp=op;tp;tp=tp->GetNext())
GetHierarchyClone(hh,tp,flags,dirty,trans);
}
}
/* after doing all the stuff above dirty is checked again. But this time using the inverted result of CompareDependenceList(); So wich list is compared to wich here? The one that exists by default with the one we created above? In wich case does CompareDependenceList return true?*/
*dirty = *dirty || !CompareDependenceList();
/* dirty gets TRUE if it was TRUE already or if CompareDependanceList returns false. The code below is only executed if dirty is FALSE*/
if (!(*dirty))
{
/* what does TouchDependenceList do? I thougt it marks all childs of my PluginObject as belonging to the Object. This causes them to get invisible as they're replaced by my plugin.*/
TouchDependenceList();
/* here the Cache is returned instead of building new Hierarchy Clones as dirty is FALSE. Where does this cache come from and what does the HierarchyHelp structure store or do? Is it correct, that every C4D object has a cache attached and cinema cares of building it internally?*/
return GetCache(hh);
}
/* OK, if the statements above were not executed as dirty is TRUE we have to rebuild the Clones. Execution continues here. Here NewDependenceList occurs again. What does it do exactly?*/
NewDependenceList();
/* The child object/objects is/are cloned and passed to the parent Generator (this is my plugin, right?). Is it correct that one has to use GetHirarchyClone instead of using the input object directly. If so, why?*/
if (!allchilds)
res = GetHierarchyClone(hh,op,flags,NULL,trans);
else
{
res = BaseObject::Alloc(Onull); if (!res) return NULL;
res->SetName(op->GetName());
for (tp=op;tp;tp=tp->GetNext())
{
dp = GetHierarchyClone(hh,tp,flags,NULL,trans);
if (dp) dp->InsertUnderLast(res);
}
}
/*The generated clones are returned*/
return res;
}