suppressing updates



  • On 13/05/2013 at 11:59, xxxxxxxx wrote:

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

    ---------
    Hi, i have a problem regarding updating of my ObjectPlugin. It is updated whenever the camera is turned around (and maybe other times, too).

    This is how i check now:

    BaseObject *HANDRAIL::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)
    {
    	BaseDocument *doc = op->GetDocument();
    	BaseContainer *bc = op->GetDataInstance();
    	BaseObject *spline = op->GetDown();
    	if (!spline || (spline->GetInfo() & OBJECT_ISSPLINE) != OBJECT_ISSPLINE) return NULL;
    	Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTYFLAGS_DATA);
    	if (mode!=Mpoints) dirty |= spline->IsDirty(DIRTYFLAGS_DATA) || spline->IsDirty(DIRTYFLAGS_MATRIX) || spline->IsDirty(DIRTYFLAGS_CACHE);
    	dirty = dirty || !op->CompareDependenceList();
    	if (!dirty) 
    	{
    		return op->GetCache(hh);
    	}
    ....
    

    and this is my message function:

    Bool HANDRAIL::Message(GeListNode *node, LONG type, void *t_data)
    {
    	if (type==MSG_DESCRIPTION_VALIDATE || type==MSG_FILTER)
    	{
    		BaseObject *op = (BaseObject* )node;
    		readParameters(op);
    	}
    	return TRUE;
    }
    

    can anyone tell me what i am doing wrong there?

    cheers,
    Ello



  • On 13/05/2013 at 13:05, xxxxxxxx wrote:

    If you tell me what your problem is, possibly. :)



  • On 13/05/2013 at 13:09, xxxxxxxx wrote:

    the problem is that the object plugin rebuilds everytime i rotate the camera. not just on changes to the parameters.



  • On 13/05/2013 at 13:34, xxxxxxxx wrote:

    Oh, I thought that was your aim.
    I've never used IsDirty(), but instead stored the previous dirty count.

    class HANDRAIL : public ObjectData {
        LONG dc;
      
    public:
      
        // ...
      
        BaseObject* GetVirtualObjects(...) {
            if (dc != op->GetDirty(DIRTYFLAGS_DATA || !op->GetCache()) {
                dc = op->GetDirty(DIRTYFLAGS_DATA);
                //...
            }
            else return op->GetCache();
        }
      
    }
    

    check if that works for you.



  • On 13/05/2013 at 13:44, xxxxxxxx wrote:

    hi, after putting a ) behind DIRTYFLAGS_DATA it results in the same behaviour.



  • On 14/05/2013 at 00:35, xxxxxxxx wrote:

    normally, you don't have to store the dirty count yourself. The C4DAtom does that anyway.

    If you notice that your dirty check always returns true, so your object is rebuilt, you should step through every line of that code in your debugger and see what goes wrong.

    I suspect in this case it's the CompareDependenceList() call, since you never started a new dependence list, or added any dependence to it. But you can easily find out using the debugger and taking a good look at the watches :)

    Also, your object type check does not make sense:

    (spline->GetInfo() & OBJECT_ISSPLINE) != OBJECT_ISSPLINE)
    

    The code spline- >GetInfo() & OBJECT_ISSPLINE returns either TRUE or FALSE. It doesn't make sense to check it for OBJECT_ISSPLINE again. This is enough:

    if (spline->GetInfo() & OBJECT_ISSPLINE) { /* object is a spline */ }
    

    And yet another tip:
    I recommend not to use the GetInfo() method for checking of an object is a spline. It'S not 100% sure. For example, the MoGraph Cloner would also return TRUE on the above shown check (the OBJECT_ISSPLINE flag is set since it may return a spline). OBJECT_ISSPLINE is a flag that is set on registration of a plugin object, and therefore does not necessarily reflect what is actually happening.

    This should be better:

    if (spline->IsInstanceOf(Ospline)) { /* object is a spline */ }
    

    And a last tip:
    Always check your pointers for NULL!! :-)
    http://c4dprogramming.wordpress.com/2012/09/18/crash-safety/



  • On 14/05/2013 at 01:00, xxxxxxxx wrote:

    thank you for your tips.  how do i step through every line of that code in your debugger? is this done in MS Visual C++? and how??

    ok. found it in the sdk. i'll try if i get this :)

    and thanks for the link to crash safety...



  • On 14/05/2013 at 01:51, xxxxxxxx wrote:

    hmm. i get this message when starting the debugger:

    any ideas? and in the output window there are much more more messages about missing pdb files..

    plus i get this when ending cinema:

    Eine Ausnahme (erste Chance) bei 0x52c40958 in CINEMA 4D 64 Bit.exe: 0xC0000005: Zugriffsverletzung bei Position 0x0000000052c40958.
    Unbehandelte Ausnahme bei 0x52c40958 in CINEMA 4D 64 Bit.exe: 0xC0000005: Zugriffsverletzung bei Position 0x0000000052c40958.
    Das Programm "[4804] CINEMA 4D 64 Bit.exe: Systemeigen" wurde mit Code 0 (0x0) beendet.

    btw, any information on how to use the debugger is welcome. never did this before :)

    for example, what do red numbers mean? some vectors have red numbers others not... 
    and how do i gain information (for example about memory leaks) while going thru the lines?



  • On 14/05/2013 at 03:27, xxxxxxxx wrote:

    so, i found out that my GetVirtualObjects function is called three times when i click somewhere or when the mouse hits any handle (even those of other objects) in the viewport. and it passes the dirty check, thus results in a full rebuild.

    what would be the next step?

    edit:
    :) got it working. dunno what exactly did the trick, but somehow it works now. and magically the memora leaks are gone, too...

    thanks to everybody who helped!



  • On 02/08/2013 at 16:35, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    I suspect in this case it's the CompareDependenceList() call, since you never started a new dependence list, or added any dependence to it. But you can easily find out using the debugger and taking a good look at the watches :)

    Where can I read about CompareDependenceList() etc above?

    Thanks.

    --8


Log in to reply