From 43afa87c5662f3a1ff7ca88d087c43834e9858df Mon Sep 17 00:00:00 2001 From: Tristan Strathearn Date: Tue, 19 Apr 2022 10:05:33 +1000 Subject: [PATCH] feat: add toggle for "fast" booleans in addon preferences and set default to true (previously "exact") --- __init__.py | 9 +++++++++ booleans/boolean_slice.py | 7 +++++-- booleans/vanilla.py | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 621fad2..9b19dc9 100644 --- a/__init__.py +++ b/__init__.py @@ -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, @@ -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() diff --git a/booleans/boolean_slice.py b/booleans/boolean_slice.py index 8f40f81..814579e 100644 --- a/booleans/boolean_slice.py +++ b/booleans/boolean_slice.py @@ -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): @@ -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 @@ -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 diff --git a/booleans/vanilla.py b/booleans/vanilla.py index 5fd541c..bfba0bf 100644 --- a/booleans/vanilla.py +++ b/booleans/vanilla.py @@ -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): @@ -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