diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-04-29 10:48:19 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-05-07 08:51:22 +0300 |
commit | 1e16662de8eaffecd95e42a1c14b16a4763c2ba7 (patch) | |
tree | 4d3011c696790cce440050ce684f8321d54eb207 | |
parent | 42089fcde087b3738312e52820a57504795c69f1 (diff) |
Fix T87592: Mirror fail with bisect, axis object & non-uniform scale
Bisect-plane calculation needed to take non-uniform scale into account.
-rw-r--r-- | source/blender/blenkernel/intern/mesh_mirror.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index d9be9a99b2b..6a270f94d76 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++ b/source/blender/blenkernel/intern/mesh_mirror.c @@ -147,6 +147,19 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis(MirrorModifierData *mmd, if (do_bisect) { copy_v3_v3(plane_co, itmp[3]); copy_v3_v3(plane_no, itmp[axis]); + + /* Account for non-uniform scale in `ob`, see: T87592. */ + float ob_scale[3] = { + len_squared_v3(ob->obmat[0]), + len_squared_v3(ob->obmat[1]), + len_squared_v3(ob->obmat[2]), + }; + /* Scale to avoid precision loss with extreme values. */ + const float ob_scale_max = max_fff(UNPACK3(ob_scale)); + if (LIKELY(ob_scale_max != 0.0f)) { + mul_v3_fl(ob_scale, 1.0f / ob_scale_max); + mul_v3_v3(plane_no, ob_scale); + } } } else if (do_bisect) { |