diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-03 19:28:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-03 19:28:44 +0400 |
commit | a2324bd4e2b04d2cd85adc75189c00b4d3a84faf (patch) | |
tree | 807027b678ec7f74823b9bd63691f90377f0dd77 | |
parent | 8a56a6082b6f70571ba39f9bd739734a19710c45 (diff) |
split islands boolean option.
-rw-r--r-- | object_fracture_voroni/__init__.py | 6 | ||||
-rw-r--r-- | object_fracture_voroni/fracture_cell_setup.py | 31 |
2 files changed, 33 insertions, 4 deletions
diff --git a/object_fracture_voroni/__init__.py b/object_fracture_voroni/__init__.py index 38bbd787..11f76731 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 5c6efc12..56b7d442 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 |