From 50999f7fb0964839225f05f0f23cbd6e806226d4 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 6 May 2019 21:47:51 +0300 Subject: 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. --- source/blender/makesdna/DNA_constraint_types.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source/blender/makesdna/DNA_constraint_types.h') diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index f839f22ec9f..d3165efb647 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -296,7 +296,9 @@ typedef struct bSizeLikeConstraint { /* Maintain Volume Constraint */ typedef struct bSameVolumeConstraint { - int flag; + char free_axis; + char mode; + char _pad[2]; float volume; } bSameVolumeConstraint; @@ -758,12 +760,22 @@ typedef enum eTransform_ToFrom { TRANS_SCALE = 2, } eTransform_ToFrom; -/* bSameVolumeConstraint.flag */ -typedef enum eSameVolume_Modes { +/* bSameVolumeConstraint.free_axis */ +typedef enum eSameVolume_Axis { SAMEVOL_X = 0, SAMEVOL_Y = 1, SAMEVOL_Z = 2, -} eSameVolume_Modes; +} eSameVolume_Axis; + +/* bSameVolumeConstraint.mode */ +typedef enum eSameVolume_Mode { + /* Strictly maintain the volume, overriding non-free axis scale. */ + SAMEVOL_STRICT = 0, + /* Maintain the volume when scale is uniform, pass non-uniform other axis scale through. */ + SAMEVOL_UNIFORM = 1, + /* Maintain the volume when scaled only on the free axis, pass other axis scale through. */ + SAMEVOL_SINGLE_AXIS = 2, +} eSameVolume_Mode; /* bActionConstraint.flag */ typedef enum eActionConstraint_Flags { -- cgit v1.2.3