diff --git a/object_fracture_voroni/__init__.py b/object_fracture_voroni/__init__.py index 38bbd7871064c8f1e10d4ea8c56542a735090ba0..11f76731358d8ef0d61b5a93905e92edcb54ca26 100644 --- a/object_fracture_voroni/__init__.py +++ b/object_fracture_voroni/__init__.py @@ -56,12 +56,13 @@ def main_object(scene, obj, level, **kw): recursion_chance_select = kw_copy.pop("recursion_chance_select") use_layer_next = kw_copy.pop("use_layer_next") group_name = kw_copy.pop("group_name") - + use_island_split = kw_copy.pop("use_island_split") from . import fracture_cell_setup objects = fracture_cell_setup.cell_fracture_objects(scene, obj, **kw_copy) - objects = fracture_cell_setup.cell_fracture_boolean(scene, obj, objects) + objects = fracture_cell_setup.cell_fracture_boolean(scene, obj, objects, + use_island_split=use_island_split) # todo, split islands. @@ -327,6 +328,7 @@ class FractureCell(Operator): rowsub.prop(self, "use_smooth_faces") rowsub.prop(self, "use_smooth_edges") rowsub.prop(self, "use_data_match") + rowsub.prop(self, "use_island_split") rowsub.prop(self, "margin") # rowsub.prop(self, "use_island_split") # TODO diff --git a/object_fracture_voroni/fracture_cell_setup.py b/object_fracture_voroni/fracture_cell_setup.py index 5c6efc12ce440128f4f61daf41cadb3961dc0994..56b7d4422919ac00cf99653676a7014c22991c92 100644 --- a/object_fracture_voroni/fracture_cell_setup.py +++ b/object_fracture_voroni/fracture_cell_setup.py @@ -122,7 +122,6 @@ def cell_fracture_objects(scene, obj, use_smooth_faces=False, use_smooth_edges=True, use_data_match=False, - use_island_split=False, use_debug_points=False, margin=0.0, ): @@ -279,7 +278,11 @@ def cell_fracture_objects(scene, obj, return objects -def cell_fracture_boolean(scene, obj, objects, apply=True, clean=True): +def cell_fracture_boolean(scene, obj, objects, + apply=True, + clean=True, + use_island_split=False, + ): objects_boolean = [] @@ -326,4 +329,28 @@ def cell_fracture_boolean(scene, obj, objects, apply=True, clean=True): if obj_cell is not None: objects_boolean.append(obj_cell) + + if use_island_split: + # this is ugly and Im not proud of this - campbell + objects_islands = [] + for obj_cell in objects_boolean: + + scene.objects.active = obj_cell + + group_island = bpy.data.groups.new(name="Islands") + group_island.objects.link(obj_cell) + + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.mesh.select_all(action='SELECT') + bpy.ops.mesh.separate(type='LOOSE') + bpy.ops.object.mode_set(mode='OBJECT') + + objects_islands.extend(group_island.objects[:]) + + bpy.data.groups.remove(group_island) + + scene.objects.active = None + + objects_boolean = objects_islands + return objects_boolean