From e858d21ae42386c57c7f5b4b0982642173f460e5 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 6 Sep 2019 11:54:34 +0300 Subject: 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. --- source/blender/makesrna/intern/rna_constraint.c | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source/blender/makesrna/intern/rna_constraint.c') 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) -- cgit v1.2.3