Skip to content

Commit

Permalink
feat: add immediate apply mode to seams operator, default to angle se…
Browse files Browse the repository at this point in the history
…t in preferences, and lock auto smooth to 180 degrees
  • Loading branch information
tristan-hm committed Nov 3, 2022
1 parent 2700e23 commit ad2b167
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packaging/seams.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
class ND_OT_seams(bpy.types.Operator):
bl_idname = "nd.seams"
bl_label = "UV Seams"
bl_description = "Interactively set UV seams & sharp edges"
bl_description = """Interactively set UV seams & sharp edges
SHIFT — Skip interactive mode and immediately apply the default settings"""
bl_options = {'UNDO'}


Expand Down Expand Up @@ -104,9 +105,11 @@ def modal(self, context, event):

def invoke(self, context, event):
self.dirty = False
self.fast_apply = event.shift

self.base_angle_factor = 15
self.angle = degrees(context.active_object.data.auto_smooth_angle)
self.commit_auto_smooth = False
self.angle = int(get_preferences().default_smoothing_angle)
self.commit_auto_smooth = True

self.angle_input_stream = new_stream()

Expand All @@ -115,6 +118,11 @@ def invoke(self, context, event):

self.operate(context)

if self.fast_apply:
self.finish(context)

return {'FINISHED'}

capture_modifier_keys(self, None, event.mouse_x)

init_overlay(self, event)
Expand Down Expand Up @@ -159,7 +167,7 @@ def finish(self, context):
if self.commit_auto_smooth:
bpy.ops.object.shade_smooth()
context.active_object.data.use_auto_smooth = True
context.active_object.data.auto_smooth_angle = radians(self.angle)
context.active_object.data.auto_smooth_angle = radians(180)

unregister_draw_handler()

Expand All @@ -185,8 +193,8 @@ def draw_text_callback(self):

draw_hint(
self,
"Sync Auto Smooth [A]: {0}".format("Yes" if self.commit_auto_smooth else "No"),
"Synchronize auto-smooth with seams angle on complete")
"Auto Smooth [A]: {0}".format("Yes" if self.commit_auto_smooth else "No"),
"Set auto smooth angle to 180° on completion")


def register():
Expand Down

0 comments on commit ad2b167

Please sign in to comment.