"Fix" for [#30704] Action Constraint mapping bug
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 12 Jun 2012 06:22:23 +0000 (06:22 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 12 Jun 2012 06:22:23 +0000 (06:22 +0000)
Feature request rather than a real bug: allow constrained bone to use "object" part of the linked action, in addition to "same-named bone" part.

release/scripts/startup/bl_ui/properties_object_constraint.py
source/blender/blenkernel/intern/constraint.c
source/blender/makesdna/DNA_constraint_types.h
source/blender/makesrna/intern/rna_constraint.c

index bfa2b4f60ef76cff5c2a683c223a15ce3eaaa149..e4da581ab8345ba741a7868ae5064d5e50b6cfc6 100644 (file)
@@ -444,6 +444,7 @@ class ConstraintButtonsPanel():
         col = split.column()
         col.label(text="To Action:")
         col.prop(con, "action", text="")
+        col.prop(con, "use_bone_object_action")
 
         split = layout.split()
 
index 9d36a66843b3fc031d4110e00b372f8f0fc1b437..62fb791df3a4defdb7bf270c99b0a0a2f9dd49d3 100644 (file)
@@ -2159,7 +2159,15 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT
                        printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name + 2, (cob->pchan) ? cob->pchan->name : NULL);
                
                /* Get the appropriate information from the action */
-               if (cob->type == CONSTRAINT_OBTYPE_BONE) {
+               if (cob->type == CONSTRAINT_OBTYPE_OBJECT || (data->flag & BONE_USE_OBJECT_ACTION)) {
+                       Object workob;
+                       
+                       /* evaluate using workob */
+                       // FIXME: we don't have any consistent standards on limiting effects on object...
+                       what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
+                       BKE_object_to_mat4(&workob, ct->matrix);
+               }
+               else if (cob->type == CONSTRAINT_OBTYPE_BONE) {
                        Object workob;
                        bPose *pose;
                        bPoseChannel *pchan, *tchan;
@@ -2185,14 +2193,6 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT
                        /* Clean up */
                        BKE_pose_free(pose);
                }
-               else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) {
-                       Object workob;
-                       
-                       /* evaluate using workob */
-                       // FIXME: we don't have any consistent standards on limiting effects on object...
-                       what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
-                       BKE_object_to_mat4(&workob, ct->matrix);
-               }
                else {
                        /* behavior undefined... */
                        puts("Error: unknown owner type for Action Constraint");
index 59d8e81de3929e2afffe9e930bff3b48649d2038..aae167d05c61c60ce3b51e0a50f4bc4a58119f4a 100644 (file)
@@ -247,7 +247,7 @@ typedef struct bActionConstraint {
        int                     end;
        float           min;
        float           max;
-       int         pad;
+       int                     flag;
        struct bAction  *act;
        char            subtarget[64];  /* MAX_ID_NAME-2 */
 } bActionConstraint;
@@ -561,6 +561,12 @@ typedef enum eSameVolume_Modes {
        SAMEVOL_Z
 } eSameVolume_Modes;
 
+/* bActionConstraint.flag
+ * WARNING: bitwise! */
+typedef enum eAction_flags {
+       BONE_USE_OBJECT_ACTION = 1 << 0, /* Bones use "object" part of target action, instead of "same bone name" part. */
+} eAction_flags;
+
 /* Locked-Axis Values (Locked Track) */
 typedef enum eLockAxis_Modes {
        LOCK_X  = 0,
index 8e29e5c2e79881ac18cab4d603c2aa9249679933..f02df6c30ed4cf1b87f017590cf02c4e87f5eed9 100644 (file)
@@ -1111,6 +1111,13 @@ static void rna_def_constraint_action(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
 
+       prop = RNA_def_property(srna, "use_bone_object_action", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_USE_OBJECT_ACTION);
+       RNA_def_property_ui_text(prop, "Object Action",
+                                "Bones only: apply the object's transformation channels of the action "
+                                "to the constrained bone, instead of bone's channels");
+       RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
        prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
        RNA_def_property_int_sdna(prop, NULL, "start");
        RNA_def_property_range(prop, MINAFRAME, MAXFRAME);