diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-06 21:47:51 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-06 21:55:20 +0300 |
commit | 50999f7fb0964839225f05f0f23cbd6e806226d4 (patch) | |
tree | 8d45ffe36f0b44bdb82f50f4492b78dd6fb7a1fb /source/blender/blenloader | |
parent | df1d990b6831fbc0b84363947fe2ef6c7d21c457 (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/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index afbb512fe2f..194459a1eda 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -692,6 +692,16 @@ static void do_version_bbone_scale_animdata_cb(ID *UNUSED(id), } } +static void do_version_constraints_maintain_volume_mode_uniform(ListBase *lb) +{ + for (bConstraint *con = lb->first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_SAMEVOL) { + bSameVolumeConstraint *data = (bSameVolumeConstraint *)con->data; + data->mode = SAMEVOL_UNIFORM; + } + } +} + void do_versions_after_linking_280(Main *bmain) { bool use_collection_compat_28 = true; @@ -1290,6 +1300,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + /* 2.79 style Maintain Volume mode. */ + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + do_version_constraints_maintain_volume_mode_uniform(&ob->constraints); + if (ob->pose) { + LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { + do_version_constraints_maintain_volume_mode_uniform(&pchan->constraints); + } + } + } } #ifdef USE_COLLECTION_COMPAT_28 |