Skip to content

Commit

Permalink
fix: ensure that boolean ops handle the presence of WN mods correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Apr 14, 2024
1 parent c562b27 commit fff5894
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions booleans/boolean_inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from .. lib.preferences import get_preferences
from .. lib.collections import move_to_utils_collection, isolate_in_utils_collection
from .. lib.numeric_input import update_stream, no_stream, get_stream_value, new_stream
from .. lib.modifiers import new_modifier, remove_problematic_bevels, rectify_smooth_by_angle
from .. lib.modifiers import new_modifier, remove_problematic_boolean_mods, rectify_smooth_by_angle


class ND_OT_bool_inset(BaseOperator):
Expand Down Expand Up @@ -134,14 +134,14 @@ def do_invoke(self, context, event):
self.reference_obj.data.name = self.reference_obj.name
self.reference_obj.hide_set(True)

remove_problematic_bevels(self.reference_obj)
remove_problematic_boolean_mods(self.reference_obj)

self.intersecting_obj.display_type = 'WIRE'
self.intersecting_obj.hide_render = True
self.intersecting_obj.name = " — ".join(['Bool', self.intersecting_obj.name])
self.intersecting_obj.data.name = self.intersecting_obj.name

remove_problematic_bevels(self.intersecting_obj)
remove_problematic_boolean_mods(self.intersecting_obj)

self.reference_obj.parent = self.target_obj
self.intersecting_obj.parent = self.target_obj
Expand Down
4 changes: 2 additions & 2 deletions booleans/boolean_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import bpy
from .. lib.collections import move_to_utils_collection, isolate_in_utils_collection
from .. lib.preferences import get_preferences
from .. lib.modifiers import new_modifier, remove_problematic_bevels, rectify_smooth_by_angle
from .. lib.modifiers import new_modifier, remove_problematic_boolean_mods, rectify_smooth_by_angle


keys = []
Expand Down Expand Up @@ -81,7 +81,7 @@ def execute(self, context):
reference_obj.data.name = reference_obj.name

if not self.do_not_clean_mesh:
remove_problematic_bevels(reference_obj)
remove_problematic_boolean_mods(reference_obj)

reference_obj.parent = target_obj
intersecting_obj.parent = target_obj
Expand Down
4 changes: 2 additions & 2 deletions booleans/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import bpy
from .. lib.collections import move_to_utils_collection, isolate_in_utils_collection
from .. lib.preferences import get_preferences
from .. lib.modifiers import new_modifier, remove_problematic_bevels, rectify_smooth_by_angle
from .. lib.modifiers import new_modifier, remove_problematic_boolean_mods, rectify_smooth_by_angle


keys = []
Expand Down Expand Up @@ -80,7 +80,7 @@ def execute(self, context):
reference_obj.data.name = reference_obj.name

if not self.do_not_clean_mesh:
remove_problematic_bevels(reference_obj)
remove_problematic_boolean_mods(reference_obj)

reference_obj.parent = target_obj
reference_obj.matrix_parent_inverse = target_obj.matrix_world.inverted()
Expand Down
10 changes: 9 additions & 1 deletion lib/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def rectify_mod_order(object, mod_name):

matching_mod_index = None
for index, mod in enumerate(mods):
if "Weighted Normal — ND WN" in mod.name:
matching_mod_index = index
break

if "Weld — ND SW" in mod.name:
matching_mod_index = index
break
Expand Down Expand Up @@ -126,11 +130,15 @@ def rectify_smooth_by_angle(object):
bpy.ops.object.modifier_move_to_index(modifier=mod.name, index=len(mods) - 1)


def remove_problematic_bevels(object):
def remove_problematic_boolean_mods(object):
mods = [mod for mod in object.modifiers]
remove_mods = []

for mod in mods:
if mod.name == "Weighted Normal — ND WN":
remove_mods.append(mod)
continue

if mod.type == 'BEVEL' and mod.affect == 'EDGES' and mod.limit_method == 'ANGLE':
if mod.segments > 1 or (mod.segments == 1 and mod.harden_normals):
remove_mods.append(mod)
Expand Down

0 comments on commit fff5894

Please sign in to comment.