Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Checking if Cache/Deform Cache Is Dirty?

    Cinema 4D SDK
    c++ r20
    2
    4
    736
    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.
    • D
      d_schmidt
      last edited by d_schmidt

      Hello! I'm having an issue with detecting whether and input object is dirty or not. For reference here is my scene file: Voronoi Fracture.c4d

      My understanding is that the Random Effector is making changes to making changes to the Voronoi Fracture's Cache.

      I don't understand why checking GetDirty(DIRTYFLAGS::CACHE) isn't returning dirty in this case. Is there something beyond that should be done?

      The other test I was doing was browsing through the cache via GetCache(), GetDown and GetNext and checking each individual part of the Cache for it being dirty. This does correctly return whether it is dirty or not, but this really slow to me, especially for something that would be running so often.

      What is the best way to reliably get if the Voronoi Fracture is dirty?

      Dan

      1 Reply Last reply Reply Quote 0
      • D
        d_schmidt
        last edited by

        Here's the code I wrote. From what I can tell it gets the job done but it seems to get slow fast when the caches get big. Is there a better way to do this?

        CompleteDirtyCheck(BaseObject* checkobject, DIRTYFLAGS flags, maxon::BaseArray<Int32>* dirtyvalues)
        {
            if (checkobject == nullptr)
            {
                return ;
            }
            
            Int32 dvalue = checkobject->GetDirty(flags);
            dirtyvalues->Append(dvalue);
            BaseObject* cache = checkobject->GetCache();
            if (cache == nullptr)
            {
                return;
            }
            maxon::BaseArray<BaseObject*> caches;
            GetChildren(cache, &caches);
            Int32 childcount = caches.GetCount();
            for (Int32 x = 0; x<childcount; x++)
            {
                BaseObject* subcache = caches[x]->GetCache();
                
                CompleteDirtyCheck(subcache,flags,dirtyvalues);
                
                Int32 dirtyvalue = caches[x]->GetDirty(flags);
                dirtyvalues->Append(dirtyvalue);
                BaseObject* deformcache = caches[x]->GetDeformCache();
                if (deformcache!=nullptr)
                {
                    
                    Int32 dirtyvalue2 = deformcache->GetDirty(flags);
                    dirtyvalues->Append(dirtyvalue2);
                }
            }
            
        
        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          Hi,

          sorry for the late reply.
          Did you try using GetHDirty on the cache of the voronoi object?

          If you use the Active Object plugin (from our sdk example) you can see that the voronoi object doesn't change its dirty state while every object on the cache does.
          efeb136a-9098-4c70-8825-bcff87330750-image.png

          I tried it and it seem to work as expected. Using GetHDirty hallow you to store only one value for the whole hierarchy.

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • D
            d_schmidt
            last edited by

            Thanks, that was exactly what I needed!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post