Skip to content

Commit

Permalink
fix: only attempt to preserve custom normals when running triangulate…
Browse files Browse the repository at this point in the history
… in Blender <4.2
  • Loading branch information
tristan-hm committed Jul 4, 2024
1 parent 3373146 commit 4143813
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packaging/triangulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ND_OT_triangulate(bpy.types.Operator):
bl_label = "Triangulate"
bl_description = """Add a triangulate modifier to the selected objects
CTRL — Remove existing modifiers
ALT — Do not preserve custom normals
ALT — Do not preserve custom normals (Blender <4.2)
SHIFT — Only triangulate ngons (5+ vertices)"""
bl_options = {'UNDO'}

Expand All @@ -58,7 +58,10 @@ def invoke(self, context, event):

for obj in mesh_objects:
triangulate = new_modifier(obj, 'Triangulate — ND', 'TRIANGULATE', rectify=False)
triangulate.keep_custom_normals = self.preserve_normals

if bpy.app.version < (4, 1, 0):
triangulate.keep_custom_normals = self.preserve_normals

triangulate.quad_method = 'FIXED' if self.preserve_normals else 'BEAUTY'
triangulate.min_vertices = 5 if self.only_ngons else 4

Expand Down

0 comments on commit 4143813

Please sign in to comment.