From ed54c1b1c3cd3a9e42d1fc8f3eec7cb2745f15fc Mon Sep 17 00:00:00 2001
From: Campbell Barton <ideasman42@gmail.com>
Date: Mon, 11 Jul 2022 12:48:39 +1000
Subject: [PATCH] Fix T99542: 3D print toolbox thickness check causes assertion

Recalculate normals when applying transformation in the 3D print toolbox.
---
 object_print3d_utils/mesh_helpers.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/object_print3d_utils/mesh_helpers.py b/object_print3d_utils/mesh_helpers.py
index 7d23a0786..444df1f11 100644
--- a/object_print3d_utils/mesh_helpers.py
+++ b/object_print3d_utils/mesh_helpers.py
@@ -32,7 +32,13 @@ def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifier
     # would save ram
 
     if transform:
-        bm.transform(obj.matrix_world)
+        matrix = obj.matrix_world.copy()
+        if not matrix.is_identity:
+            bm.transform(matrix)
+            # Update normals if the matrix has no rotation.
+            matrix.translation.zero()
+            if not matrix.is_identity:
+                bm.normal_update()
 
     if triangulate:
         bmesh.ops.triangulate(bm, faces=bm.faces)
-- 
GitLab