Skip to content

Commit

Permalink
feat: add an option in general preferences to toggle auto smoothing a…
Browse files Browse the repository at this point in the history
…cross all operators
  • Loading branch information
tristan-hm committed May 29, 2024
1 parent d51fa57 commit 2d80d10
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ class NDPreferences(AddonPreferences):
default="GENERAL",
)

enable_auto_smooth: BoolProperty(
name="Enable Auto Smoothing",
default=True,
)

default_smoothing_angle: EnumProperty(
name="Default Smooting Angle",
items=[
Expand Down Expand Up @@ -469,7 +474,8 @@ def draw_general(self, box):
"use_fast_booleans",
"recon_poly_solidify",
"recon_poly_inscribed",
"enable_right_click_select"]
"enable_right_click_select",
"enable_auto_smooth"]

for pref in general_prefs:
column = box.column(align=True)
Expand Down
3 changes: 3 additions & 0 deletions bevels/bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ def summon_old_operator(self, context):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
add_smooth_by_angle(self.target_object)
return
Expand Down
3 changes: 3 additions & 0 deletions bevels/edge_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ def summon_old_operator(self, context, mods):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
bpy.ops.object.mode_set(mode='OBJECT')
add_smooth_by_angle(self.target_object)
Expand Down
3 changes: 3 additions & 0 deletions bevels/vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ def prepare_new_operator(self, context):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
bpy.ops.object.mode_set(mode='OBJECT')
add_smooth_by_angle(self.target_object)
Expand Down
3 changes: 3 additions & 0 deletions extrusion/profile_extrude.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def calculate_existing_weighting(self):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
self.smoothing = add_smooth_by_angle(self.target_object)
return
Expand Down
3 changes: 3 additions & 0 deletions extrusion/screw.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ def summon_old_operator(self, context, mods):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
add_smooth_by_angle(self.target_object)
return
Expand Down
3 changes: 3 additions & 0 deletions extrusion/solidify.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ def summon_old_operator(self, context, mods):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
add_smooth_by_angle(self.target_object)
return
Expand Down
2 changes: 1 addition & 1 deletion packaging/seams.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def invoke(self, context, event):

self.base_angle_factor = 15
self.angle = int(get_preferences().default_smoothing_angle)
self.commit_auto_smooth = True
self.commit_auto_smooth = get_preferences().enable_auto_smooth

self.angle_input_stream = new_stream()

Expand Down
3 changes: 3 additions & 0 deletions sketch/circularize.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def prepare_new_operator(self, context):


def add_smooth_shading(self, context):
if not get_preferences().enable_auto_smooth:
return

if bpy.app.version >= (4, 1, 0):
add_smooth_by_angle(self.target_object)
return
Expand Down

0 comments on commit 2d80d10

Please sign in to comment.