Skip to content

Commit

Permalink
feat: add toggle for "fast" booleans in addon preferences and set def…
Browse files Browse the repository at this point in the history
…ault to true (previously "exact")
  • Loading branch information
tristan-hm committed Apr 19, 2022
1 parent 1093006 commit 43afa87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class NDPreferences(AddonPreferences):
default=False,
)

use_fast_booleans: BoolProperty(
name="Use Fast Booleans",
default=True,
)

mouse_value_scalar: FloatProperty(
name="Mouse Value Scalar",
default=0.0025,
Expand Down Expand Up @@ -126,6 +131,10 @@ def draw_general(self, box):
row = column.row()
row.prop(self, "utils_collection_name")

column = box.column(align=True)
row = column.row()
row.prop(self, "use_fast_booleans")

box = box.box()
column = box.column(align=True)
row = column.row()
Expand Down
7 changes: 5 additions & 2 deletions booleans/boolean_slice.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bpy
from .. lib.collections import move_to_utils_collection
from .. lib.preferences import get_preferences


class ND_OT_bool_slice(bpy.types.Operator):
Expand All @@ -16,6 +17,8 @@ def poll(cls, context):


def execute(self, context):
solver = 'FAST' if get_preferences().use_fast_booleans else 'EXACT'

a, b = context.selected_objects
reference_obj = a if a.name != context.object.name else b

Expand All @@ -29,12 +32,12 @@ def execute(self, context):
boolean_diff = difference_obj.modifiers.new("Difference — ND Bool", 'BOOLEAN')
boolean_diff.operation = 'DIFFERENCE'
boolean_diff.object = reference_obj
boolean_diff.solver = 'EXACT'
boolean_diff.solver = solver

boolean_isect = intersecting_obj.modifiers.new("Intersection — ND Bool", 'BOOLEAN')
boolean_isect.operation = 'INTERSECT'
boolean_isect.object = reference_obj
boolean_isect.solver = 'EXACT'
boolean_isect.solver = solver

reference_obj.display_type = 'WIRE'
reference_obj.hide_render = True
Expand Down
5 changes: 4 additions & 1 deletion booleans/vanilla.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bpy
from .. lib.collections import move_to_utils_collection
from .. lib.preferences import get_preferences


class ND_OT_bool_vanilla(bpy.types.Operator):
Expand All @@ -23,13 +24,15 @@ def poll(cls, context):


def execute(self, context):
solver = 'FAST' if get_preferences().use_fast_booleans else 'EXACT'

a, b = context.selected_objects
reference_obj = a if a.name != context.object.name else b

boolean = context.object.modifiers.new(" — ".join([self.mode.capitalize(), "ND Bool"]), 'BOOLEAN')
boolean.operation = self.mode
boolean.object = reference_obj
boolean.solver = 'EXACT'
boolean.solver = solver

reference_obj.display_type = 'WIRE'
reference_obj.hide_render = True
Expand Down

0 comments on commit 43afa87

Please sign in to comment.