Re-using generator cache

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

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


    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?


  • 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,

  • 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. :)


Log in to reply