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

    Mass-spring system updating

    SDK Help
    0
    4
    454
    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 25/02/2013 at 02:22, xxxxxxxx wrote:

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

      ---------
      In order to perform some soft-body deformations using a deformer object, I want to use a mass-spring system applied to the vertices and edges of the polygonized mesh sent to ModifyObject().  My problem is that I definitely do not want to create the mass-spring system every time ModifyObject() is called but only initially and when there are changes to the object being deformed that might require a rebuild of the system.  Would GetDirty(DIRTYFLAGS_DATA) be enough?  What if the user edits the mesh in some way (for already polygon objects)?  What messages might I be looking for in my deformer object from its 'parent' (if any)?

      Thanks,

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

        On 28/02/2013 at 12:43, xxxxxxxx wrote:

        No one?  I had an inkling that checking for DIRTYFLAGS_DATA in ModifyObject() wouldn't work.  It updates the system constantly because it is always dirty.  It only needs to be done if the user changes some property or the mesh - really, not just to kick in ModifyObject().

        Any takers?

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

          On 28/02/2013 at 14:01, xxxxxxxx wrote:

          Alrighty, then.  After a bit of experimentation, this works the best.  I provide this to alleviate the suffering of others in the future. 🙂

          Note: the mass-spring system is created/recreated in ModifyObject() only because I get a ready-made polygon object.

          // ObjectData.CheckDirty  
          //*---------------------------------------------------------------------------*  
          void DeformerObj::CheckDirty(BaseObject* op, BaseDocument* doc)  
          //*---------------------------------------------------------------------------*  
          {  
            if (!doc)                        return;  
            if (!op)                        return;  
            
            // Check Deformed object  
            BaseObject*        dop =            op->GetUp();  
            if (dop)  
            {  
                ULONG        dd =            dop->GetDirty(DIRTYFLAGS_MATRIX|DIRTYFLAGS_DATA);  
                if (dd != dDirty)  
                {  
                    dDirty =    dd;  
                    op->SetDirty(DIRTYFLAGS_DATA);  
                    // A data change constitutes a need to recreate Mass-Spring System  
                    needInitMassSpring =    TRUE;  
                    return;  
                }  
            }  
            
            // Check Collider object  
            BaseContainer*    bc =            op->GetDataInstance();  
            if (!bc)                        return;  
            // - Get linked object  
            BaseObject*        lop =            (BaseObject* )bc->GetLink(DEFORMER_OBJECT, doc, Obase);  
            if (!lop)                        return;  
            ULONG            dirtyness =        lop->GetDirty(DIRTYFLAGS_MATRIX|DIRTYFLAGS_DATA);  
            // - Linked object is not dirty  
            if (dirtyness == cDirty)        return;  
            // - is dirty  
            cDirty =                        dirtyness;  
            op->SetDirty(DIRTYFLAGS_DATA);  
          }
          
          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 01/03/2013 at 00:08, xxxxxxxx wrote:

            Hi Robert,

            Thanks for sharing the solution.

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