From 5a693ce9e396f04d88140d8e015fcace7eddc6c2 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 27 Jun 2021 23:15:57 +0300 Subject: Constraints: support a new Local Space (Owner Orientation) for targets. Add a new transformation space choice for bone constraints, which represent the local transformation of the target bone in the constraint owner's local space. The use case for this is transferring the local (i.e. excluding the effect of parents) motion of one bone to another one, while ignoring the difference between their rest pose orientations. The new option replaces the following setup: * A `child` bone of the `target`, rotated the same as `owner` in rest pose. * A `sibling` bone of the `target`, positioned same as `child` in rest pose and using Copy Transforms in World Space from `child`. * The `owner` bone constraint uses Local Space of `sibling`. (This analogy applies provided both bones use Local Location) Differential Revision: https://developer.blender.org/D9493 --- source/blender/makesrna/intern/rna_constraint.c | 10 ++++++++++ source/blender/makesrna/intern/rna_object_api.c | 3 +++ 2 files changed, 13 insertions(+) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index d34885e1a68..28aef635688 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -206,6 +206,7 @@ static const EnumPropertyItem target_space_pchan_items[] = { "Custom Space", "The transformation of the target is evaluated relative to a custom object/bone/vertex " "group"}, + {0, "", 0, NULL, NULL}, {CONSTRAINT_SPACE_POSE, "POSE", 0, @@ -224,6 +225,14 @@ static const EnumPropertyItem target_space_pchan_items[] = { "Local Space", "The transformation of the target is evaluated relative to its local " "coordinate system"}, + {CONSTRAINT_SPACE_OWNLOCAL, + "LOCAL_OWNER_ORIENT", + 0, + "Local Space (Owner Orientation)", + "The transformation of the target bone is evaluated relative to its local coordinate " + "system, followed by a correction for the difference in target and owner rest pose " + "orientations. When applied as local transform to the owner produces the same global " + "motion as the target if the parents are still in rest pose"}, {0, NULL, 0, NULL, NULL}, }; @@ -238,6 +247,7 @@ static const EnumPropertyItem owner_space_pchan_items[] = { 0, "Custom Space", "The constraint is applied in local space of a custom object/bone/vertex group"}, + {0, "", 0, NULL, NULL}, {CONSTRAINT_SPACE_POSE, "POSE", 0, diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 4608b0c1bac..10ba2b9acb1 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -303,6 +303,9 @@ static void rna_Object_mat_convert_space(Object *ob, { copy_m4_m4((float(*)[4])mat_ret, (float(*)[4])mat); + BLI_assert(!ELEM(from, CONSTRAINT_SPACE_OWNLOCAL)); + BLI_assert(!ELEM(to, CONSTRAINT_SPACE_OWNLOCAL)); + /* Error in case of invalid from/to values when pchan is NULL */ if (pchan == NULL) { if (ELEM(from, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_PARLOCAL)) { -- cgit v1.2.3