Bugfix [#25814] ChildOf constraint: double transformation in object
authorJoshua Leung <aligorith@gmail.com>
Tue, 8 Feb 2011 05:51:20 +0000 (05:51 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 8 Feb 2011 05:51:20 +0000 (05:51 +0000)
mode with drivers

ChildOf constraints added using the PoseBone.constraints.new() method
via Python scripts instead of using the operator (this latter method
is still the preferred/recommended method) were not getting some
critical flags set, causing errors arising from space conversions
being performed more than once.

source/blender/blenkernel/intern/constraint.c
source/blender/editors/object/object_constraint.c

index 1e3ff71..be9e760 100644 (file)
@@ -4148,6 +4148,21 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c
                constraints_set_active(list, con);
        }
        
+       /* set type+owner specific immutable settings */
+       // TODO: does action constraint need anything here - i.e. spaceonce?
+       switch (type) {
+               case CONSTRAINT_TYPE_CHILDOF:
+               {
+                       /* if this constraint is being added to a posechannel, make sure
+                        * the constraint gets evaluated in pose-space */
+                       if (pchan) {
+                               con->ownspace = CONSTRAINT_SPACE_POSE;
+                               con->flag |= CONSTRAINT_SPACEONCE;
+                       }
+               }
+                       break;
+       }
+       
        return con;
 }
 
index e92d73a..f3346bf 100644 (file)
@@ -1272,12 +1272,12 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
        bPoseChannel *pchan;
        bConstraint *con;
        
-       if(list == &ob->constraints) {
+       if (list == &ob->constraints) {
                pchan= NULL;
        }
        else {
                pchan= get_active_posechannel(ob);
-
+               
                /* ensure not to confuse object/pose adding */
                if (pchan == NULL) {
                        BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to.");
@@ -1327,19 +1327,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
        }
        
        /* do type-specific tweaking to the constraint settings  */
-       // TODO: does action constraint need anything here - i.e. spaceonce?
        switch (type) {
-               case CONSTRAINT_TYPE_CHILDOF:
-               {
-                       /* if this constraint is being added to a posechannel, make sure
-                        * the constraint gets evaluated in pose-space */
-                       if (pchan) {
-                               con->ownspace = CONSTRAINT_SPACE_POSE;
-                               con->flag |= CONSTRAINT_SPACEONCE;
-                       }
-               }
-                       break;
-                       
                case CONSTRAINT_TYPE_PYTHON: // FIXME: this code is not really valid anymore
                {
 #ifdef WITH_PYTHON