Skip to content

Commit

Permalink
feat: remove problematic bevels from all boolean reference objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jun 12, 2022
1 parent 752de82 commit 6349c4d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
6 changes: 4 additions & 2 deletions booleans/boolean_inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ def invoke(self, context, event):
self.boolean_isect.solver = solver
self.boolean_isect.show_expanded = False

remove_problematic_bevels(self.intersecting_obj)

self.reference_obj_display_type_prev = self.reference_obj.display_type
self.reference_obj_hide_render_prev = self.reference_obj.hide_render
self.reference_obj_name_prev = self.reference_obj.name
Expand All @@ -163,12 +161,16 @@ def invoke(self, context, event):
self.reference_obj.name = " — ".join(['Bool', self.reference_obj.name])
self.reference_obj.data.name = self.reference_obj.name
self.reference_obj.hide_set(True)

remove_problematic_bevels(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)

self.reference_obj.parent = self.target_obj
self.intersecting_obj.parent = self.target_obj

Expand Down
14 changes: 12 additions & 2 deletions booleans/boolean_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import bpy
from .. lib.collections import move_to_utils_collection, isolate_in_utils_collection
from .. lib.preferences import get_preferences
from .. lib.modifiers import rectify_mod_order
from .. lib.modifiers import rectify_mod_order, remove_problematic_bevels


class ND_OT_bool_slice(bpy.types.Operator):
bl_idname = "nd.bool_slice"
bl_label = "Slice"
bl_description = "Perform a boolean operation on the selected objects"
bl_description = """Perform a boolean operation on the selected objects
ALT — Do not clean reference object mesh before operation"""
bl_options = {'UNDO'}


Expand Down Expand Up @@ -71,6 +72,9 @@ def execute(self, context):
reference_obj.name = " — ".join(['Bool', reference_obj.name])
reference_obj.data.name = reference_obj.name

if not self.do_not_clean_mesh:
remove_problematic_bevels(reference_obj)

reference_obj.parent = difference_obj
intersecting_obj.parent = difference_obj

Expand All @@ -86,6 +90,12 @@ def execute(self, context):

return {'FINISHED'}


def invoke(self, context, event):
self.do_not_clean_mesh = event.alt

return self.execute(context)


def register():
bpy.utils.register_class(ND_OT_bool_slice)
Expand Down
9 changes: 7 additions & 2 deletions booleans/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
import bpy
from .. lib.collections import move_to_utils_collection, isolate_in_utils_collection
from .. lib.preferences import get_preferences
from .. lib.modifiers import rectify_mod_order
from .. lib.modifiers import rectify_mod_order, remove_problematic_bevels


class ND_OT_bool_vanilla(bpy.types.Operator):
bl_idname = "nd.bool_vanilla"
bl_label = "Boolean"
bl_description = """Perform a boolean operation on the selected objects
SHIFT — Protect the reference object (do not convert into utility)"""
SHIFT — Protect the reference object (do not convert into utility)
ALT — Do not clean reference object mesh before operation"""
bl_options = {'UNDO'}


Expand Down Expand Up @@ -64,6 +65,9 @@ def execute(self, context):
reference_obj.hide_render = True
reference_obj.name = " — ".join(['Bool', reference_obj.name])
reference_obj.data.name = reference_obj.name

if not self.do_not_clean_mesh:
remove_problematic_bevels(reference_obj)

reference_obj.parent = context.active_object
reference_obj.matrix_parent_inverse = context.active_object.matrix_world.inverted()
Expand All @@ -81,6 +85,7 @@ def execute(self, context):

def invoke(self, context, event):
self.protect_reference_obj = event.shift
self.do_not_clean_mesh = event.alt

return self.execute(context)

Expand Down
9 changes: 6 additions & 3 deletions lib/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ def remove_problematic_bevels(object):
remove_mods = []

for mod in mods:
if mod.type == 'BEVEL' and mod.segments == 1 and mod.harden_normals:
remove_mods.append(mod)
elif "— ND WNB" in mod.name:
if "— ND WNB" in mod.name:
remove_mods.append(mod)
continue
elif 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)
continue

for mod in remove_mods:
object.modifiers.remove(mod)

0 comments on commit 6349c4d

Please sign in to comment.