diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-06-27 06:42:06 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-06-27 15:27:49 +0300 |
commit | de6064eab174ab29e0845b4d024825e72805ed01 (patch) | |
tree | 9f84792d7d85afd1d42b7d92bd01e83014a2a6d4 /source | |
parent | ab921321e1ca6303ee0fa2f2de511b490d9d6427 (diff) |
Ctrl-Shift-C: Made it easier to add constraints between bones in different armatures
The Ctrl-Shift-C operator to add constraints between a pair of selected items,
for example, between two objects, or between two bones (in the same armature).
This commit makes it possible to use this operator to add a constraint where the
target is a bone from another object - e.g. to make a deform bone follow the control
bone in another armature, or to make an object use a bone as a tracking target.
Usage:
1) Ensure you are in Pose Mode, then select the bone to use as the target
2) Shift-Select the other object and/or the bone that's going to get the constraint
3) Ctrl-Shift-C
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index efd1ebbd51b..2b20d31c60f 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1636,22 +1636,36 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* just use the first object we encounter (that isn't the active object) * and which fulfills the criteria for the object-target that we've got */ - if ((ob != obact) && - ((!only_curve) || (ob->type == OB_CURVE)) && - ((!only_mesh) || (ob->type == OB_MESH))) - { - /* set target */ - *tar_ob = ob; - found = 1; - - /* perform some special operations on the target */ - if (only_curve) { - /* Curve-Path option must be enabled for follow-path constraints to be able to work */ - Curve *cu = (Curve *)ob->data; - cu->flag |= CU_PATH; + if (ob != obact) { + /* for armatures in pose mode, look inside the armature for the active bone + * so that we set up cross-armature constraints with less effort + */ + if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && + (!only_curve && !only_mesh)) + { + /* just use the active bone, and assume that it is visible + usable */ + *tar_ob = ob; + *tar_pchan = BKE_pose_channel_active(ob); + found = 1; + + break; + } + else if (((!only_curve) || (ob->type == OB_CURVE)) && + ((!only_mesh) || (ob->type == OB_MESH))) + { + /* set target */ + *tar_ob = ob; + found = 1; + + /* perform some special operations on the target */ + if (only_curve) { + /* Curve-Path option must be enabled for follow-path constraints to be able to work */ + Curve *cu = (Curve *)ob->data; + cu->flag |= CU_PATH; + } + + break; } - - break; } } CTX_DATA_END; |