diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-01 13:19:11 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-09-01 14:13:23 +0300 |
commit | 18d4ad5a59d32922f9d70b0412da0c830baceb17 (patch) | |
tree | c6e630362f87e533b5482ae7fd096ce49d0eeab6 /source/blender/makesrna/intern | |
parent | ae43b1d51b4a0384c2197a6aca5cd2810c9283ff (diff) |
Copy Rotation & Transform: add Euler order override options.
For reasons similar to drivers, it should be possible to set an
explicit Euler rotation order in constraints that use Euler angles.
The Transform constraint in a way approaches drivers in its use,
in that it effectively alters channels using values of other
channels after applying a fixed form mathematical expression.
For this reason, instead of just specifying the euler order for
its inputs, it uses the same enum as driver variables. However
Quaternion components are converted to a weighted pseudo-angle
representation as the rest of the constraint UI expects angles.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 29 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 26 |
2 files changed, 42 insertions, 13 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 539e2a66296..05154dcc20e 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -256,6 +256,17 @@ static const EnumPropertyItem track_axis_items[] = { {0, NULL, 0, NULL, NULL}, }; +static const EnumPropertyItem euler_order_items[] = { + {CONSTRAINT_EULER_AUTO, "AUTO", 0, "Default", "Euler using the default rotation order"}, + {CONSTRAINT_EULER_XYZ, "XYZ", 0, "XYZ Euler", "Euler using the XYZ rotation order"}, + {CONSTRAINT_EULER_XZY, "XZY", 0, "XZY Euler", "Euler using the XZY rotation order"}, + {CONSTRAINT_EULER_YXZ, "YXZ", 0, "YXZ Euler", "Euler using the YXZ rotation order"}, + {CONSTRAINT_EULER_YZX, "YZX", 0, "YZX Euler", "Euler using the YZX rotation order"}, + {CONSTRAINT_EULER_ZXY, "ZXY", 0, "ZXY Euler", "Euler using the ZXY rotation order"}, + {CONSTRAINT_EULER_ZYX, "ZYX", 0, "ZYX Euler", "Euler using the ZYX rotation order"}, + {0, NULL, 0, NULL, NULL}, +}; + #ifdef RNA_RUNTIME static const EnumPropertyItem space_object_items[] = { @@ -1324,6 +1335,12 @@ static void rna_def_constraint_rotate_like(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z rotation"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + prop = RNA_def_property(srna, "euler_order", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "euler_order"); + RNA_def_property_enum_items(prop, euler_order_items); + RNA_def_property_ui_text(prop, "Euler Order", "Explicitly specify the euler rotation order"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + prop = RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_OFFSET); RNA_def_property_ui_text(prop, "Offset", "Add original rotation into copied rotation"); @@ -1885,6 +1902,18 @@ static void rna_def_constraint_transform(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + prop = RNA_def_property(srna, "from_rotation_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "from_rotation_mode"); + RNA_def_property_enum_items(prop, rna_enum_driver_target_rotation_mode_items); + RNA_def_property_ui_text(prop, "From Mode", "Specify the type of rotation channels to use"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + + prop = RNA_def_property(srna, "to_euler_order", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "to_euler_order"); + RNA_def_property_enum_items(prop, euler_order_items); + RNA_def_property_ui_text(prop, "To Order", "Explicitly specify the output euler rotation order"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); + /* Loc */ prop = RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "from_min[0]"); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 684c786b1b9..b6b759882b3 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -132,6 +132,18 @@ const EnumPropertyItem rna_enum_beztriple_interpolation_easing_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_driver_target_rotation_mode_items[] = { + {DTAR_ROTMODE_AUTO, "AUTO", 0, "Auto Euler", "Euler using the rotation order of the target"}, + {DTAR_ROTMODE_EULER_XYZ, "XYZ", 0, "XYZ Euler", "Euler using the XYZ rotation order"}, + {DTAR_ROTMODE_EULER_XZY, "XZY", 0, "XZY Euler", "Euler using the XZY rotation order"}, + {DTAR_ROTMODE_EULER_YXZ, "YXZ", 0, "YXZ Euler", "Euler using the YXZ rotation order"}, + {DTAR_ROTMODE_EULER_YZX, "YZX", 0, "YZX Euler", "Euler using the YZX rotation order"}, + {DTAR_ROTMODE_EULER_ZXY, "ZXY", 0, "ZXY Euler", "Euler using the ZXY rotation order"}, + {DTAR_ROTMODE_EULER_ZYX, "ZYX", 0, "ZYX Euler", "Euler using the ZYX rotation order"}, + {DTAR_ROTMODE_QUATERNION, "QUATERNION", 0, "Quaternion", "Quaternion rotation"}, + {0, NULL, 0, NULL, NULL}, +}; + #ifdef RNA_RUNTIME # include "WM_api.h" @@ -1702,18 +1714,6 @@ static void rna_def_drivertarget(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; - static const EnumPropertyItem prop_rotation_mode_items[] = { - {DTAR_ROTMODE_AUTO, "AUTO", 0, "Auto Euler", "Euler using the rotation order of the target"}, - {DTAR_ROTMODE_EULER_XYZ, "XYZ", 0, "XYZ Euler", "Euler using the XYZ rotation order"}, - {DTAR_ROTMODE_EULER_XZY, "XZY", 0, "XZY Euler", "Euler using the XZY rotation order"}, - {DTAR_ROTMODE_EULER_YXZ, "YXZ", 0, "YXZ Euler", "Euler using the YXZ rotation order"}, - {DTAR_ROTMODE_EULER_YZX, "YZX", 0, "YZX Euler", "Euler using the YZX rotation order"}, - {DTAR_ROTMODE_EULER_ZXY, "ZXY", 0, "ZXY Euler", "Euler using the ZXY rotation order"}, - {DTAR_ROTMODE_EULER_ZYX, "ZYX", 0, "ZYX Euler", "Euler using the ZYX rotation order"}, - {DTAR_ROTMODE_QUATERNION, "QUATERNION", 0, "Quaternion", "Quaternion rotation"}, - {0, NULL, 0, NULL, NULL}, - }; - srna = RNA_def_struct(brna, "DriverTarget", NULL); RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables"); @@ -1764,7 +1764,7 @@ static void rna_def_drivertarget(BlenderRNA *brna) prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "rotation_mode"); - RNA_def_property_enum_items(prop, prop_rotation_mode_items); + RNA_def_property_enum_items(prop, rna_enum_driver_target_rotation_mode_items); RNA_def_property_ui_text(prop, "Rotation Mode", "Mode for calculating rotation channel values"); RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); |