From 73af884df004171bacffb82f3ff7f6e627a12690 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Apr 2021 17:48:19 +1000 Subject: [PATCH] Fix T87592: Mirror fail with bisect, axis object & non-uniform scale Bisect-plane calculation needed to take non-uniform scale into account. --- source/blender/blenkernel/intern/mesh_mirror.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c index 93a2e9058fa..3d30c218fba 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.c +++ b/source/blender/blenkernel/intern/mesh_mirror.c @@ -183,6 +183,19 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(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) {