diff options
-rw-r--r-- | object_fracture_cell/__init__.py | 2 | ||||
-rw-r--r-- | object_fracture_cell/fracture_cell_setup.py | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py index 71909b3e..4e85831d 100644 --- a/object_fracture_cell/__init__.py +++ b/object_fracture_cell/__init__.py @@ -392,7 +392,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_interior_vgroup") + rowsub.prop(self, "use_interior_vgroup") rowsub.prop(self, "material_index") rowsub = col.row() # could be own section, control how we subdiv diff --git a/object_fracture_cell/fracture_cell_setup.py b/object_fracture_cell/fracture_cell_setup.py index b248021a..889f9135 100644 --- a/object_fracture_cell/fracture_cell_setup.py +++ b/object_fracture_cell/fracture_cell_setup.py @@ -324,6 +324,9 @@ def cell_fracture_boolean(scene, obj, objects, ): objects_boolean = [] + + if use_interior_vgroup: + obj.data.polygons.foreach_set("hide", [False] * len(obj.data.polygons)) for obj_cell in objects: mod = obj_cell.modifiers.new(name="Boolean", type='BOOLEAN') @@ -331,6 +334,10 @@ def cell_fracture_boolean(scene, obj, objects, mod.operation = 'INTERSECT' if not use_debug_bool: + + if use_interior_vgroup: + obj_cell.data.polygons.foreach_set("hide", [True] * len(obj_cell.data.polygons)) + mesh_new = obj_cell.to_mesh(scene, apply_modifiers=True, settings='PREVIEW') @@ -366,6 +373,28 @@ def cell_fracture_boolean(scene, obj, objects, bm.to_mesh(mesh_new) bm.free() + if use_interior_vgroup and mesh_new: + bm = bmesh.new() + bm.from_mesh(mesh_new) + for bm_vert in bm.verts: + bm_vert.tag = True + for bm_face in bm.faces: + if not bm_face.hide: + for bm_vert in bm_face.verts: + bm_vert.tag = False + # now add all vgroups + defvert_lay = bm.verts.layers.deform.verify() + for bm_vert in bm.verts: + if bm_vert.tag: + bm_vert[defvert_lay][0] = 1.0 + for bm_face in bm.faces: + bm_face.hide = False + bm.to_mesh(mesh_new) + bm.free() + + # add a vgroup + obj_cell.vertex_groups.new(name="Interior") + if obj_cell is not None: objects_boolean.append(obj_cell) |