Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Dependence Cache flag

    Cinema 4D SDK
    c++ r19 r20
    2
    3
    759
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rsodreR
      rsodre
      last edited by

      Hi,

      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.

      How can I clear the dependence dirty cache flag?

      My code..

      op->NewDependenceList();
      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);
      	return cache;
      }
      // Generate....
      
      1 Reply Last reply Reply Quote 0
      • a_blockA
        a_block
        last edited by a_block

        Hello Roger,

        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.

        Cheers,
        Andreas

        rsodreR 1 Reply Last reply Reply Quote 1
        • rsodreR
          rsodre @a_block
          last edited by rsodre

          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 );
          }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post