Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2020-11-22 14:17:21 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-06-05 16:29:46 +0300
commitd2dc452333a4cfd335a0075277c21349473ba678 (patch)
tree5b8e5c0c93f964232e07ceca1b7ff89c5bb5df2f
parent2cd1bc3aa7e66a295313c9ab82fbd7ba4b4905e1 (diff)
Limit Rotation: add an Euler Order option.
Since Limit Rotation is based on Euler decomposition, it should allow specifying the order to use for the same reasons as Copy Rotation does, namely, if the bone uses Quaternion rotation for its animation channels, there is no way to choose the order for the constraint. Ref D9626
-rw-r--r--release/scripts/startup/bl_ui/properties_constraint.py1
-rw-r--r--source/blender/blenkernel/intern/constraint.c12
-rw-r--r--source/blender/makesdna/DNA_constraint_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c6
4 files changed, 19 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index e835e577953..a88def34767 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -245,6 +245,7 @@ class ConstraintButtonsPanel:
sub.prop(con, "max_z", text="Max")
row.label(icon='BLANK1')
+ layout.prop(con, "euler_order", text="Order")
layout.prop(con, "use_transform_limit")
self.space_template(layout, con, target=False, owner=True)
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 9293a2b449a..766d0f5dd2e 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1635,10 +1635,18 @@ static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
float eul[3];
float size[3];
+ /* Select the Euler rotation order, defaulting to the owner value. */
+ short rot_order = cob->rotOrder;
+
+ if (data->euler_order != CONSTRAINT_EULER_AUTO) {
+ rot_order = data->euler_order;
+ }
+
+ /* Decompose the matrix using the specified order. */
copy_v3_v3(loc, cob->matrix[3]);
mat4_to_size(size, cob->matrix);
- mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
+ mat4_to_eulO(eul, rot_order, cob->matrix);
/* constraint data uses radians internally */
@@ -1671,7 +1679,7 @@ static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UN
}
}
- loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder);
+ loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, rot_order);
}
static bConstraintTypeInfo CTI_ROTLIMIT = {
diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h
index 07fbf263d80..a94bc4625df 100644
--- a/source/blender/makesdna/DNA_constraint_types.h
+++ b/source/blender/makesdna/DNA_constraint_types.h
@@ -534,6 +534,8 @@ typedef struct bRotLimitConstraint {
float zmin, zmax;
short flag;
short flag2;
+ char euler_order;
+ char _pad[3];
} bRotLimitConstraint;
/* Limit Scale Constraint */
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index a3934b12a44..b363dcd4ba9 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -2598,6 +2598,12 @@ static void rna_def_constraint_rotation_limit(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
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_transform_limit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM);
RNA_def_property_ui_text(