Caching for VP Bitmapbutton...



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/08/2003 at 15:04, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.100 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi,
    I have a VP plugin and have a instant preview directly in the rendersettings dialog. The preview is created by internally rendering another document that executes the VP plugin itself. Ok, that works and the preview is updated (so the other scene is rendered and shown in the Bitmapbutton) whenever a user changes a value in the plugin (means any gui element changes like clicking a button etc.). But the preview is also calculated when the user switches between the quicktabs even if I oppress the automatic update.
    David already gave me the tipp to cache the rendered bitmap and return it when the dirty variable is not incremented.
    Ok, but I cannot make it work. No matter how I try to allocate another bitmap and no matter where, it either does not work as expected (shows black because of freeing the bitmap which needs to be done) or Cinema 4D crashes (when I for example do not free it properly). I tried so many ways and am sitting in front of this for 2 days now, I´m kinda...down :=
    So the question is: where can I allocate and free a bitmap for caching sensibly? I only have my VP plugin class. Thanks for any info/ideas.
    Best
    Samir



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/08/2003 at 15:07, xxxxxxxx wrote:

    ah and here is the code in my message function:

        
        
        if (type == MSG_DESCRIPTION_GETBITMAP)   
         {    
          DescriptionGetBitmap* dgb = static_cast<DescriptionGetBitmap*>(data);  
          if (dgb->id[0] == QCFX_PREVIEW)    
          {     
            /*if(cachefilled) //if picture rendered and dirty variable == 0  
            { 
        
        
        
        
            }  
            else  
            {  
             */  
               
             RenderPreview rp; //Render Thread  
             rp.dgb = dgb;  
             rp.vdata = vdata;  
             rp.current = (BaseDocument* )node->GetDocument()->GetClone(0,NULL);  
             rp.update = b_dirty;  
             rp.Main();  
            //}  
          }     
         } 
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/08/2003 at 10:02, xxxxxxxx wrote:

    What is it that your plugin is supposed to do exactly?
    Nate



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/08/2003 at 12:11, xxxxxxxx wrote:

    Do you still need to know this samir? in Message this is the code I have (cut down) :

        
        
          
        switch (type)  
        {  
        case MSG_DESCRIPTION_GETBITMAP:  
         {   
          DescriptionGetBitmap *rbs=(DescriptionGetBitmap* )data;  
          switch(rbs->id[0].id)  
          {  
          case OUTLINEMAT_PREVIEW_IMAGETAB:  
          case OUTLINEMAT_PREVIEW_IMAGE:  
           {  
            BaseList2D *bl=(BaseList2D* )node;  
            BaseContainer *bc=bl->GetDataInstance();  
            BaseDocument *doc=NULL;
        
        
        
        
            m_pPreviewLock->LockAndWait((BaseThread* )NULL);
        
        
        
        
            if (doc) doc=(BaseDocument* )doc->GetClone(NULL,NULL);
        
        
        
        
            m_pPreviewLock->UnLock();
        
        
        
        
            if (doc)  
            {  
             if (m_lBMdirty!=m_BMdirty)  
             {  
              if (m_pPreviewMap)  
              {
        
        
        
        
              //...
        
        
        
        
          
               RenderDocument(doc,NULL,NULL,m_pPreviewMap,rdata,RENDERFLAG_SHOWERRORS|RENDERFLAG_NODOCUMENTCLONE|RENDERFLAG_EXTERNAL,FALSE,(Thread* )NULL);  
              }
        
        
        
        
              m_lBMdirty=m_BMdirty;  
             }
        
        
        
        
             if (m_pPreviewMap)  
              rbs->bmp=m_pPreviewMap->GetClone();  
             else  
              rbs->bmp=NULL;
        
        
        
        
             BaseDocument::Free(doc);  
               
            }
        
        
        
        
            return TRUE;  
           }  
          }  
         }  
         break;  
        
    

    then you change the dirty in SetDParameter(). You basically give C4D a clone of your BaseBitmap always keeping the original for your plugin.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/08/2003 at 14:05, xxxxxxxx wrote:

    hi Dave,
    thanks. :) I really couldn´t make it but this code looks more logical than mine though :)
    Best
    Samir



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/08/2003 at 16:08, xxxxxxxx wrote:

    But wait, where are you allocating (and freeing) the bitmap (pPreviewMap)? That´s actually my problem :\



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/08/2003 at 11:39, xxxxxxxx wrote:

    tzz, forget about it. you are cloning it...man I´m glad I have two weeks of vacation now :)
    Best
    Samir


Log in to reply