[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3598] trunk/py/scripts/addons/ object_fracture_cell: add interior vertex group option.
Campbell Barton
ideasman42 at gmail.com
Mon Jul 9 11:17:42 CEST 2012
Revision: 3598
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3598
Author: campbellbarton
Date: 2012-07-09 09:17:41 +0000 (Mon, 09 Jul 2012)
Log Message:
-----------
add interior vertex group option.
Modified Paths:
--------------
trunk/py/scripts/addons/object_fracture_cell/__init__.py
trunk/py/scripts/addons/object_fracture_cell/fracture_cell_setup.py
Modified: trunk/py/scripts/addons/object_fracture_cell/__init__.py
===================================================================
--- trunk/py/scripts/addons/object_fracture_cell/__init__.py 2012-07-09 08:19:08 UTC (rev 3597)
+++ trunk/py/scripts/addons/object_fracture_cell/__init__.py 2012-07-09 09:17:41 UTC (rev 3598)
@@ -392,7 +392,7 @@
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
Modified: trunk/py/scripts/addons/object_fracture_cell/fracture_cell_setup.py
===================================================================
--- trunk/py/scripts/addons/object_fracture_cell/fracture_cell_setup.py 2012-07-09 08:19:08 UTC (rev 3597)
+++ trunk/py/scripts/addons/object_fracture_cell/fracture_cell_setup.py 2012-07-09 09:17:41 UTC (rev 3598)
@@ -324,6 +324,9 @@
):
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 @@
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 @@
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)
More information about the Bf-extensions-cvs
mailing list