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>2019-09-06 11:54:34 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-09-06 12:53:35 +0300
commite858d21ae42386c57c7f5b4b0982642173f460e5 (patch)
tree90d36cb8f5bd0ba8be7414b5027553eeca115c77 /source/blender/makesrna/intern/rna_constraint.c
parenta23ce7f3b78b28550c6e6cfd73404b82dc210529 (diff)
Transformation Constraint: implement a Mix Mode option.
Allow selecting how the new location/rotation/scale is combined with the existing transformation. This is most useful for rotation, which has multiple options, and scale, which previously could only replace.
Diffstat (limited to 'source/blender/makesrna/intern/rna_constraint.c')
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 658addece8a..7732bf531d8 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -1934,6 +1934,34 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem mix_mode_loc_items[] = {
+ {TRANS_MIXLOC_REPLACE, "REPLACE", 0, "Replace", "Replace component values"},
+ {TRANS_MIXLOC_ADD, "ADD", 0, "Add", "Add component values together"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ static const EnumPropertyItem mix_mode_rot_items[] = {
+ {TRANS_MIXROT_REPLACE, "REPLACE", 0, "Replace", "Replace component values"},
+ {TRANS_MIXROT_ADD, "ADD", 0, "Add", "Add component values together"},
+ {TRANS_MIXROT_BEFORE,
+ "BEFORE",
+ 0,
+ "Before Original",
+ "Apply new rotation before original, as if it was on a parent"},
+ {TRANS_MIXROT_AFTER,
+ "AFTER",
+ 0,
+ "After Original",
+ "Apply new rotation after original, as if it was on a child"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ static const EnumPropertyItem mix_mode_scale_items[] = {
+ {TRANS_MIXSCALE_REPLACE, "REPLACE", 0, "Replace", "Replace component values"},
+ {TRANS_MIXSCALE_MULTIPLY, "MULTIPLY", 0, "Multiply", "Multiply component values together"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "TransformConstraint", "Constraint");
RNA_def_struct_ui_text(
srna, "Transformation Constraint", "Map transformations of the target to the object");
@@ -2066,6 +2094,13 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
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_loc");
+ RNA_def_property_enum_items(prop, mix_mode_loc_items);
+ RNA_def_property_ui_text(
+ prop, "Location Mix Mode", "Specify how to combine the new location with original");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
/* Rot */
prop = RNA_def_property(srna, "from_min_x_rot", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "from_min_rot[0]");
@@ -2139,6 +2174,13 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+ prop = RNA_def_property(srna, "mix_mode_rot", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mix_mode_rot");
+ RNA_def_property_enum_items(prop, mix_mode_rot_items);
+ RNA_def_property_ui_text(
+ prop, "Rotation Mix Mode", "Specify how to combine the new rotation with original");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
/* Scale */
prop = RNA_def_property(srna, "from_min_x_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "from_min_scale[0]");
@@ -2211,6 +2253,13 @@ static void rna_def_constraint_transform(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop = RNA_def_property(srna, "mix_mode_scale", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mix_mode_scale");
+ RNA_def_property_enum_items(prop, mix_mode_scale_items);
+ RNA_def_property_ui_text(
+ prop, "Scale Mix Mode", "Specify how to combine the new scale with original");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
}
static void rna_def_constraint_location_limit(BlenderRNA *brna)