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

    Re-using generator cache

    SDK Help
    0
    3
    286
    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.
    • H
      Helper
      last edited by

      On 21/05/2013 at 02:18, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :

      ---------
      Hello,

      I was wondering what the proper way of re-using a generator's cache is. How does Cinema know
      I re-used the cache? And what if I only want to re-use certain parts of the cache?

      For example:

      /* .. */ GetVirtualObjets(BaseObject* host, HierarchyHelp* hh) {
          // ..
          BaseObject* root = BaseObject::Alloc(Onull);
          BaseObject* cache = host->GetCache();
          BaseObject* obj = NULL;
          if (cache) {
              obj = cache->GetDown();
              if (obj) obj->Remove();
          }
          if (!obj) obj = BaseObject::Alloc(Ocube);
          if (obj) obj->InsertUnder(root);
        
          // ..
        
          return root;
      }
      

      Can I do this safely?

      Thanks,
      -Niklas

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 21/05/2013 at 03:22, xxxxxxxx wrote:

        I don't get the question, simply copy the atom you grabbed from the cache ? Are you trying
        to keep some sort of live link to the generators cache ? I am not sure what happens if you 
        do insert parts of an objects cache into the document. What do you  expect the generator
        object to do ? It has either to rebuild the cache (and set it at some point to Null) or not.

        my cheap pythonish cents,
        happy rendering,
        ferdinand

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 21/05/2013 at 03:26, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          simply copy the atom you grabbed from the cache ?

          The point is to not copy/reallocate the object for optimizing the object generating.  😄

          Anyway, I just checked and so far it seems to work fine. I remove the object I want to re-use
          from the cache (which is the parent) and I didn't get crashes or memory leaks. 🙂

          Best,
          -nik

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