AddJoint, SetWeight crash



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

    On 12/10/2010 at 00:50, xxxxxxxx wrote:

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

    ---------
    Under what circumstances would AddJoint() from CAWeightTag return -1 for the joint index?
    I use the following code after I have allocated and added all joint objects to the document. 
    All joint object pointers are valid.

      
    CAWeightTag* tag = CAWeightTag::Alloc();  
    for(i=0; i < num_joints; i++) {  
       LONG joint_index = tag->AddJoint( joints[i].ob ); // returns -1 ???  
    }  
    pPoly->InsertTag( tag, NULL );  
    

    Then later, calling tag->SetWeight( joint_index, vindex, weight ); will crash the program from passing -1 as joint_index.



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

    On 12/10/2010 at 02:31, xxxxxxxx wrote:

    It seems that you have first to insert the tag before inserting the joints.

    little example:

      
    void StepThru(BaseObject *op, CAWeightTag *tag)  
    {  
      while (op && tag)  
      {  
          if (op->GetType() == Ojoint)  
          {  
              tag->AddJoint(op);  
              tag->Message(MSG_UPDATE);  
          }  
      
          StepThru(op->GetDown(), tag);  
          op = op->GetNext();  
      }  
    }  
      
    Bool MenuTest::Execute(BaseDocument *doc)  
    {  
      BaseObject *op = doc->GetActiveObject();  
      if (!op) return FALSE;  
      
      CAWeightTag *tag = CAWeightTag::Alloc();  
      if (!tag) return FALSE;  
            
      op->InsertTag(tag);  
      
      op->Message(MSG_UPDATE);  
      EventAdd();  
      
      StepThru(doc->GetFirstObject(), (CAWeightTag* )tag);  
      
      return TRUE;  
    }  
    

    cheers,
    Matthias



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

    On 12/10/2010 at 10:26, xxxxxxxx wrote:

    Great, got it working!  Thanks.


Log in to reply