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-05-06 21:47:51 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-05-06 21:55:20 +0300
commit50999f7fb0964839225f05f0f23cbd6e806226d4 (patch)
tree8d45ffe36f0b44bdb82f50f4492b78dd6fb7a1fb /source/blender/makesrna/intern/rna_constraint.c
parentdf1d990b6831fbc0b84363947fe2ef6c7d21c457 (diff)
Maintain Volume: introduce an option switching between modes.
After a lot of thinking about this, I decided that all operation modes that I've tried over the past couple of years, including the original 2.79 one, have their uses after all. Thus the only reasonable solution is to add yet another option. The modes are: - Strict: The current 2.80 mode, which overrides the original scaling of the non-free axes to strictly preserve the volume. This is the most obvious way one would expect a 'Maintain Volume' constraint to work. - Uniform: The original 2.79 mode, which assumes that all axes have been scaled the same as the free one when computing the volume. This seems strange, but the net effect is that when simply scaling the object uniformly with S, the volume is preserved; however, scaling the non- free axes individually allows deviating from the locked volume. This was obviously intended as a more or less convenient UI tool. - Single Axis: My own variant of the intent of the Uniform scale, which does volume-preserving if the object is scaled just on the Free axis, while passing the non-free axis scaling through. I.e. instead of uniform S scaling, the user has to scale the object just on its primary axis to achieve constant volume. This can allow reducing the number of animation curves when only constant volume scaling is needed, or be an easier to control tool inside a complex rig.
Diffstat (limited to 'source/blender/makesrna/intern/rna_constraint.c')
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index c1c235d497b..49c1fa779ab 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -1346,13 +1346,34 @@ static void rna_def_constraint_same_volume(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static const EnumPropertyItem volume_items[] = {
+ static const EnumPropertyItem axis_items[] = {
{SAMEVOL_X, "SAMEVOL_X", 0, "X", ""},
{SAMEVOL_Y, "SAMEVOL_Y", 0, "Y", ""},
{SAMEVOL_Z, "SAMEVOL_Z", 0, "Z", ""},
{0, NULL, 0, NULL, NULL},
};
+ static const EnumPropertyItem mode_items[] = {
+ {SAMEVOL_STRICT,
+ "STRICT",
+ 0,
+ "Strict",
+ "Volume is strictly preserved, overriding the scaling of non-free axes"},
+ {SAMEVOL_UNIFORM,
+ "UNIFORM",
+ 0,
+ "Uniform",
+ "Volume is preserved when the object is scaled uniformly. "
+ "Deviations from uniform scale on non-free axes are passed through"},
+ {SAMEVOL_SINGLE_AXIS,
+ "SINGLE_AXIS",
+ 0,
+ "Single Axis",
+ "Volume is preserved when the object is scaled only on the free axis. "
+ "Non-free axis scaling is passed through"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
srna = RNA_def_struct(brna, "MaintainVolumeConstraint", "Constraint");
RNA_def_struct_ui_text(srna,
"Maintain Volume Constraint",
@@ -1360,11 +1381,18 @@ static void rna_def_constraint_same_volume(BlenderRNA *brna)
RNA_def_struct_sdna_from(srna, "bSameVolumeConstraint", "data");
prop = RNA_def_property(srna, "free_axis", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "flag");
- RNA_def_property_enum_items(prop, volume_items);
+ RNA_def_property_enum_sdna(prop, NULL, "free_axis");
+ RNA_def_property_enum_items(prop, axis_items);
RNA_def_property_ui_text(prop, "Free Axis", "The free scaling axis of the object");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, mode_items);
+ RNA_def_property_ui_text(
+ prop, "Mode", "The way the constraint treats original non-free axis scaling");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+
prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_range(prop, 0.001f, 100.0f);
RNA_def_property_ui_text(prop, "Volume", "Volume of the bone at rest");