diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-03-02 18:42:27 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-03-02 18:42:27 +0300 |
commit | c327cf489c4d145407786552e4d9027295754985 (patch) | |
tree | 9d1cc902a67988fe82d710d922d16794369c9615 /source/blender/blenkernel | |
parent | f9f559a05fc16e66031210e62bd7bc51d26208a3 (diff) | |
parent | f76d49ed9504612cc5ba3956b53f920f7c93bd20 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index f0e60296119..b070ccdd4eb 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1917,28 +1917,29 @@ static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase * bSameVolumeConstraint *data = con->data; float volume = data->volume; - float fac = 1.0f; + float fac = 1.0f, total_scale; float obsize[3]; mat4_to_size(obsize, cob->matrix); /* calculate normalizing scale factor for non-essential values */ - if (obsize[data->flag] != 0) - fac = sqrtf(volume / obsize[data->flag]); + total_scale = obsize[0] * obsize[1] * obsize[2]; + if (total_scale != 0) + fac = sqrtf(volume / total_scale); /* apply scaling factor to the channels not being kept */ switch (data->flag) { case SAMEVOL_X: - mul_v3_fl(cob->matrix[1], fac / obsize[1]); - mul_v3_fl(cob->matrix[2], fac / obsize[2]); + mul_v3_fl(cob->matrix[1], fac); + mul_v3_fl(cob->matrix[2], fac); break; case SAMEVOL_Y: - mul_v3_fl(cob->matrix[0], fac / obsize[0]); - mul_v3_fl(cob->matrix[2], fac / obsize[2]); + mul_v3_fl(cob->matrix[0], fac); + mul_v3_fl(cob->matrix[2], fac); break; case SAMEVOL_Z: - mul_v3_fl(cob->matrix[0], fac / obsize[0]); - mul_v3_fl(cob->matrix[1], fac / obsize[1]); + mul_v3_fl(cob->matrix[0], fac); + mul_v3_fl(cob->matrix[1], fac); break; } } |