== Constraints - Bugfixes ==
authorJoshua Leung <aligorith@gmail.com>
Mon, 23 Jul 2007 11:28:43 +0000 (11:28 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 23 Jul 2007 11:28:43 +0000 (11:28 +0000)
Here are some attempts at fixing bugs being encountered with the constraint system after the recode. I've just fixed a few typos (where relevant), and added some extra checks for things.

source/blender/blenkernel/intern/constraint.c
source/blender/blenloader/intern/readfile.c
source/blender/src/transform_conversions.c

index d0bfd7113579587b4bb2da789eaa53efaf5039a9..c97b5caafaac381a2497dce70171dd1f52cdab0e 100644 (file)
@@ -818,7 +818,7 @@ bConstraintOb *constraints_make_evalob (Object *ob, void *subdata, short datatyp
                                cob->type = datatype;
                                
                                /* matrix in world-space */
-                               Mat4MulMat4 (cob->matrix, cob->pchan->pose_mat, ob->obmat);
+                               Mat4MulMat4(cob->matrix, cob->pchan->pose_mat, ob->obmat);
                                Mat4CpyMat4(cob->startmat, cob->matrix);
                        }
                        else
@@ -2640,6 +2640,8 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime)
        for (con= conlist->first; con; con= con->next) {
                /* this we can skip completely */
                if (con->flag & CONSTRAINT_DISABLE) continue;
+               /* influence == 0 should be ignored */
+               if (con->enforce == 0.0f) continue;
                /* and inverse kinematics is solved seperate */ 
                if (con->type==CONSTRAINT_TYPE_KINEMATIC) continue;
                /* rigidbody is really a game-engine thing - and is not solved here */
index e5fdebae89d72fdb4eda102cd95b371eb168adfe..bd62a431d38c69229dca70a4619f15a435499376 100644 (file)
@@ -6555,6 +6555,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                        {
                                                                bActionConstraint *data= (bActionConstraint *)curcon->data;
                                                                
+                                                               /* 'data->local' used to mean that target was in local-space */
                                                                if (data->local)
                                                                        curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
                                                        }                                                       
@@ -6563,10 +6564,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                        {
                                                                bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data;
                                                                
-                                                               if (data->flag2) {
+                                                               /* old limit without parent option for objects */
+                                                               if (data->flag2)
                                                                        curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
-                                                                       curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
-                                                               }
+                                                       }
+                                                               break;
+                                                       case CONSTRAINT_TYPE_STRETCHTO:
+                                                       {
+                                                               bStretchToConstraint *data= (bStretchToConstraint *)curcon->data;
+                                                               
+                                                               /* force recalc of rest-length */
+                                                               data->orglength = 0;
                                                        }
                                                                break;
                                                }       
@@ -6595,6 +6603,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                                        {
                                                                                bActionConstraint *data= (bActionConstraint *)curcon->data;
                                                                                
+                                                                               /* 'data->local' used to mean that target was in local-space */
                                                                                if (data->local)
                                                                                        curcon->tarspace = CONSTRAINT_SPACE_LOCAL;
                                                                        }                                                       
@@ -6603,10 +6612,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                                        {
                                                                                bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data;
                                                                                
-                                                                               if (data->flag2) {
+                                                                               /* old limit without parent option for objects */
+                                                                               if (data->flag2)
                                                                                        curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
-                                                                                       curcon->ownspace = CONSTRAINT_SPACE_LOCAL;
-                                                                               }
+                                                                       }
+                                                                               break;
+                                                                       case CONSTRAINT_TYPE_STRETCHTO:
+                                                                       {
+                                                                               bStretchToConstraint *data= (bStretchToConstraint *)curcon->data;
+                                                                               
+                                                                               /* force recalc of rest-length */
+                                                                               data->orglength = 0;
                                                                        }
                                                                                break;
                                                                }
index 5e92a4db95b44798180a845b6f48e7cc4c32e144..2d78c9a232292ec0abfdaadd9456de5842c4c80d 100755 (executable)
@@ -540,8 +540,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
        Mat3Inv(lmat, tmat);
        Mat3CpyMat4(pmat, pchan->pose_mat);
        Mat3MulMat3(tmat, lmat, pmat); // argh... order of args is reversed 
-       Mat3MulMat3(td->mtx, omat, pmat);
-               
+       Mat3MulMat3(td->mtx, omat, tmat);
        Mat3Inv(td->smtx, td->mtx);
        
        /* for axismat we use bone's own transform */
@@ -2066,15 +2065,15 @@ static void ObjectToTransData(TransData *td, Object *ob)
 
        VECCOPY(td->center, ob->obmat[3]);
 
-       if (ob->parent || ob->track || ob->constraints.first)
+       if (ob->parent || ob->constraints.first)
        {
                float totmat[3][3], obinv[3][3];
                
-               /* get the effect of parenting, and/or tracking, and/or constraints */
+               /* get the effect of parenting, and/or constraints */
                object_to_mat3(ob, obmtx);
                Mat3CpyMat4(totmat, ob->obmat);
-               Mat3Inv(obinv, totmat);
-               Mat3MulMat3(td->smtx, obmtx, obinv);
+               Mat3Inv(obinv, obmtx);
+               Mat3MulMat3(td->smtx, totmat, obinv);
                Mat3Inv(td->mtx, td->smtx);
        }
        else