diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2020-11-04 19:29:27 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-07-02 15:15:05 +0300 |
commit | bc8ae58727bf078df1fc5803a9de5c9eb984aeb7 (patch) | |
tree | 64037beefa7b8a8cf9201c51360d8fa310cc791c /source/blender/makesrna/intern/rna_constraint.c | |
parent | 01e1944cd455448e8634ab2c44ca8a96c73af628 (diff) |
Copy Transforms: implement Remove Target Shear and more Mix options.
This constraint can be naturally viewed as a prototype for a future
4x4 matrix math node (or subset thereof), since its basic semantics
already is matrix assignment. Thus it makes sense to add math options
to this constraint to increase flexibility in the meantime.
This patch adds support for several operations that would be useful:
- An option to remove shear in the incoming target matrix.
Shear is known to cause issues for various mathematical operations,
so an option to remove it at key points is useful.
Constraints based on Euler like Copy Rotation and Limit Rotation
already have always enabled shear removal built in, because their
math doesn't work correctly with shear.
In the future node system shear removal would be a separate node
(and currently Limit Rotation can be used as a Remove Shear constraint).
However removing shear from the result of the target space conversion
before mixing (similar to Copy Rotation) has to be built into
Copy Transforms itself as an option.
- More ways to combine the target and owner matrices.
Similar to multiple Inherit Scale modes for parenting, there are
multiple ways one may want to combine matrices based on context.
This implements 3 variants for each of the Before/After modes
(one of them already existing).
- Full implements regular matrix multiplication as the most basic
option. The downside is the risk of creating shear.
- Aligned emulates the 'anti-shear' Aligned Inherit Scale mode,
and basically uses Full for location, and Split for rotation/scale.
(This choice already existed.)
- Split Channels combines location, rotation and scale separately.
Looking at D7547 there is demand for Split Channels in some cases,
so I think it makes sense to include it in Copy Transforms too, so that
the Mix menu items can be identical for it and the Action constraint.
Differential Revision: https://developer.blender.org/D9469
Diffstat (limited to 'source/blender/makesrna/intern/rna_constraint.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index d79f2c4d13f..d34885e1a68 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1624,18 +1624,48 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna) 0, "Replace", "Replace the original transformation with copied"}, + {0, "", 0, NULL, NULL}, + {TRANSLIKE_MIX_BEFORE_FULL, + "BEFORE_FULL", + 0, + "Before Original (Full)", + "Apply copied transformation before original, using simple matrix multiplication as if " + "the constraint target is a parent in Full Inherit Scale mode. " + "Will create shear when combining rotation and non-uniform scale"}, {TRANSLIKE_MIX_BEFORE, "BEFORE", 0, - "Before Original", - "Apply copied transformation before original, as if the constraint target is a parent. " - "Scale is handled specially to avoid creating shear"}, + "Before Original (Aligned)", + "Apply copied transformation before original, as if the constraint target is a parent in " + "Aligned Inherit Scale mode. This effectively uses Full for location and Split Channels " + "for rotation and scale"}, + {TRANSLIKE_MIX_BEFORE_SPLIT, + "BEFORE_SPLIT", + 0, + "Before Original (Split Channels)", + "Apply copied transformation before original, handling location, rotation and scale " + "separately, similar to a sequence of three Copy constraints"}, + {0, "", 0, NULL, NULL}, + {TRANSLIKE_MIX_AFTER_FULL, + "AFTER_FULL", + 0, + "After Original (Full)", + "Apply copied transformation after original, using simple matrix multiplication as if " + "the constraint target is a child in Full Inherit Scale mode. " + "Will create shear when combining rotation and non-uniform scale"}, {TRANSLIKE_MIX_AFTER, "AFTER", 0, - "After Original", - "Apply copied transformation after original, as if the constraint target is a child. " - "Scale is handled specially to avoid creating shear"}, + "After Original (Aligned)", + "Apply copied transformation after original, as if the constraint target is a child in " + "Aligned Inherit Scale mode. This effectively uses Full for location and Split Channels " + "for rotation and scale"}, + {TRANSLIKE_MIX_AFTER_SPLIT, + "AFTER_SPLIT", + 0, + "After Original (Split Channels)", + "Apply copied transformation after original, handling location, rotation and scale " + "separately, similar to a sequence of three Copy constraints"}, {0, NULL, 0, NULL, NULL}, }; @@ -1653,6 +1683,12 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna) RNA_define_lib_overridable(true); + prop = RNA_def_property(srna, "remove_target_shear", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TRANSLIKE_REMOVE_TARGET_SHEAR); + RNA_def_property_ui_text( + prop, "Remove Target Shear", "Remove shear from the target transformation before combining"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + prop = RNA_def_property(srna, "mix_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mix_mode"); RNA_def_property_enum_items(prop, mix_mode_items); |