diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-07-15 20:39:02 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-11-06 10:56:08 +0300 |
commit | 798cdaeeb6927cb9ca42597fa23845eac04c02b2 (patch) | |
tree | 92e444a0a2268d891cdd90f56299ccb8f1c1bf3b /source/blender/editors | |
parent | a817613be5ab1545b000e9173a8d3079aaaefa01 (diff) |
Implement an Armature constraint that mimics the modifier.
The main use one can imagine for this is adding tweak controls to
parts of a model that are already deformed by multiple other major
bones. It is natural to expect such locations to deform as if the
tweaks aren't there by default; however currently there is no easy
way to make a bone follow multiple other bones.
This adds a new constraint that implements the math behind the Armature
modifier, with support for explicit weights, bone envelopes, and dual
quaternion blending. It can also access bones from multiple armatures
at the same time (mainly because it's easier to code it that way.)
This also fixes dquat_to_mat4, which wasn't used anywhere before.
Differential Revision: https://developer.blender.org/D3664
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/keyframing.c | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 21 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 1 |
3 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 39b1bed3ac1..863dd4efa82 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -810,6 +810,7 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) switch (con->type) { /* multi-transform constraints */ case CONSTRAINT_TYPE_CHILDOF: + case CONSTRAINT_TYPE_ARMATURE: return true; case CONSTRAINT_TYPE_TRANSFORM: case CONSTRAINT_TYPE_TRANSLIKE: diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 4081c005132..212bf0ba018 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -430,6 +430,11 @@ static void test_constraint(Main *bmain, Object *owner, bPoseChannel *pchan, bCo if (check_targets && cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); + /* constraints with empty target list that actually require targets */ + if (!targets.first && ELEM(con->type, CONSTRAINT_TYPE_ARMATURE)) { + con->flag |= CONSTRAINT_DISABLE; + } + /* disable and clear constraints targets that are incorrect */ for (ct = targets.first; ct; ct = ct->next) { /* general validity checks (for those constraints that need this) */ @@ -473,6 +478,18 @@ static void test_constraint(Main *bmain, Object *owner, bPoseChannel *pchan, bCo } } } + else if (con->type == CONSTRAINT_TYPE_ARMATURE) { + if (ct->tar) { + if (ct->tar->type != OB_ARMATURE) { + ct->tar = NULL; + con->flag |= CONSTRAINT_DISABLE; + } + else if (!BKE_armature_find_bone_name(BKE_armature_from_object(ct->tar), ct->subtarget)) { + /* bone must exist in armature... */ + con->flag |= CONSTRAINT_DISABLE; + } + } + } } /* free any temporary targets */ @@ -1245,7 +1262,9 @@ void ED_object_constraint_tag_update(Main *bmain, Object *ob, bConstraint *con) BKE_pose_tag_update_constraint_flags(ob->pose); } - object_test_constraint(bmain, ob, con); + if (con) { + object_test_constraint(bmain, ob, con); + } if (ob->type == OB_ARMATURE) DEG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d9857b50ec0..c0d4db0cc97 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5599,6 +5599,7 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, + CONSTRAINT_TYPE_ARMATURE, CONSTRAINT_TYPE_OBJECTSOLVER, CONSTRAINT_TYPE_FOLLOWTRACK)) { |