On 04/08/2013 at 22:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: r14
Platform: Mac OSX ;
Language(s) : C++ ;
---------
I am trying to understand how to use the cache properly, and am using a simplest useful code for that purpose. My plugin node has two children, I then create two respective clones using GetAndCheckHierarchyClone, and then return null. I am not doing any calculations, I am not generating any objects, yet GetAndCheckHierarchyClone is always changing the dirty boolean to true. What am I doing wrong? Here is the code:
BaseObject *TSPData::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)
{
BaseObject *orig = op->GetDown();
if (!orig) return NULL;
BaseObject *origSibling = orig->GetNext();
if (!origSibling) return NULL;
Bool dirty=FALSE;
Matrix ml;
BaseObject \*child = op->GetAndCheckHierarchyClone(hh,orig,HIERARCHYCLONEFLAGS_ASPOLY,&dirty,NULL,FALSE);
Bool dirtyS = FALSE;
BaseObject *sibling = op->GetAndCheckHierarchyClone(hh,origSibling,HIERARCHYCLONEFLAGS_ASPOLY,&dirtyS,NULL,FALSE);
dirty = dirty || dirtyS;
if (!dirty) dirty = op->CheckCache(hh);
if (!dirty) dirty = op->IsDirty(DIRTYFLAGS_DATA);
op->TouchDependenceList();
if (!dirty) return op->GetCache(hh);
op->AddDependence(hh, child);
op->AddDependence(hh, sibling);
return NULL;
}
The problem is that if (!dirty) return op->GetCache (hh); never returns cache, as the dirty is always set to true in the GetAndCheckHierarchyClone.
Reading the forum I suspect the problem is in the dependence list, and I don't quite understand what am I supposed to add to the dependence list. My original children? Their clones? It seems that GetAndCheckHierarchyClone creates a new list for each call/child. Is it OK, or I should prevent that?
Would appreciate _any_ reaction from this list.
Thanks.
--8