Skip to content

Commit

Permalink
feat: add only ngons option to triangulate modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jul 6, 2023
1 parent 8d059c4 commit 1a8221b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packaging/triangulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class ND_OT_triangulate(bpy.types.Operator):
bl_idname = "nd.triangulate"
bl_label = "Triangulate"
bl_description = """Add a triangulate modifier to the selected objects
ALT — Do not preserve custom normals"""
ALT — Do not preserve custom normals
SHIFT — Only triangulate ngons (5+ vertices)"""
bl_options = {'UNDO'}


Expand All @@ -38,11 +39,13 @@ def poll(cls, context):

def invoke(self, context, event):
self.preserve_normals = not event.alt
self.only_ngons = event.shift

for obj in context.selected_objects:
triangulate = new_modifier(obj, 'Triangulate — ND', 'TRIANGULATE', rectify=False)
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

return {'FINISHED'}

Expand Down

0 comments on commit 1a8221b

Please sign in to comment.