I'm building a dependence list on a generator, I want to know if the input object parameter is changed and/or deformed. When adding the dependence using DIRTYFLAGS_DATA | DIRTYFLAGS_CACHE, it does exactly that but I get a dirty cache on every single screen update, the cache flag never gets cleared. If I use DIRTYFLAGS_DATA only, I get it dirtied only once when a parameter changes, as expected.
DIRTYFLAGS_DATA | DIRTYFLAGS_CACHE
How can I clear the dependence dirty cache flag?
for ( auto child = op->GetDown() ; child != nullptr ; child = child->GetNext() )
BaseObject* dependence = nullptr;
if ( ValidateChildMesh( child->GetType() ) )
dependence = child;
if ( dependence != nullptr )
//op->AddDependence( hh, dependence, DIRTYFLAGS_DATA );
op->AddDependence( hh, dependence, DIRTYFLAGS_DATA | DIRTYFLAGS_CACHE );
if ( !dirty )
dirty = !op->CompareDependenceList();
op->TouchDependenceList(); // Hide dependences
if ( !dirty )
auto cache = op->GetCache(hh);
I'm terribly sorry, it's again you who has to wait longer than usual for an answer. Somehow you have a knack for the more difficult questions...
In general your code is correct. Internally AddDependence() is mainly used without any flags.
Unfortunately the behavior of these flags and dirtiness in general currently also depends on the type and hierarchy of input objects. If you really need to improve beyond what you have already, then it will certainly involve adaption to very specific cases. Something where I can unfortunately not provide a general answer, but we'd need to discuss these cases separately.
As an example Maxime elaborates a bit on the special case of the MoGraph Matrix object in this thread: Getting MoData in GVO of a ObjectData Plugin.
Hey @a_block ,
I finally got some time to try again, and I actually had two problems
First, I'm adding that object as a dependent because one of my modifiers need it, and it was sending a Join modeling command to read it as a single polygon. The command was invalidating the cache, entering a loop. Now I first clone it before join, and the cache flag remains intact.
Just looking at the CACHE dirty count of the object was not enough to detect if the deform cache was dirty, I need to look at it's cache dirty cache count. Sounds weird but works, and makes sense to me.
if ( distributionObject != nullptr )
// Check deformed cache
auto distributionObjectCache = distributionObject->GetCache( hh );
if ( distributionObjectCache != nullptr )
auto dirtyCount = distributionObjectCache->GetDirty( DIRTYFLAGS_CACHE );
if ( distributionObjectDirtyCount_ != dirtyCount )
dirty = true;
distributionObjectDirtyCount_ = dirtyCount;
op->AddDependence( hh, distributionObject, DIRTYFLAGS_DATA | DIRTYFLAGS_CACHE );