From 019fcd6a500835736eb4548d5a0353c97dd00cc6 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Mon, 9 Jul 2012 09:17:41 +0000 Subject: [PATCH] add interior vertex group option. --- object_fracture_cell/__init__.py | 2 +- object_fracture_cell/fracture_cell_setup.py | 29 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py index 71909b3ef..4e85831db 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 b248021ab..889f9135f 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) -- GitLab