[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3553] trunk/py/scripts/addons/ object_fracture_voroni: added margin option
Campbell Barton
ideasman42 at gmail.com
Fri Jun 29 19:43:47 CEST 2012
Revision: 3553
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3553
Author: campbellbarton
Date: 2012-06-29 17:43:46 +0000 (Fri, 29 Jun 2012)
Log Message:
-----------
added margin option
Modified Paths:
--------------
trunk/py/scripts/addons/object_fracture_voroni/__init__.py
trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_calc.py
trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_setup.py
Modified: trunk/py/scripts/addons/object_fracture_voroni/__init__.py
===================================================================
--- trunk/py/scripts/addons/object_fracture_voroni/__init__.py 2012-06-29 12:43:47 UTC (rev 3552)
+++ trunk/py/scripts/addons/object_fracture_voroni/__init__.py 2012-06-29 17:43:46 UTC (rev 3553)
@@ -54,9 +54,7 @@
recursion = kw_copy.pop("recursion")
recursion_chance = kw_copy.pop("recursion_chance")
recursion_chance_select = kw_copy.pop("recursion_chance_select")
-
- print("AAAA", recursion_chance_select * 10)
-
+
from . import fracture_cell_setup
objects = fracture_cell_setup.cell_fracture_objects(scene, obj, **kw_copy)
@@ -92,7 +90,7 @@
c = scene.cursor_location.copy()
objects_recurse_input.sort(key=lambda ob_pair:
(ob_pair[1].matrix_world.translation - c).length_squared)
- if recursion_chance_select == 'SIZE_MAX':
+ if recursion_chance_select == 'CURSOR_MAX':
objects_recurse_input.reverse()
objects_recurse_input[int(recursion_chance * len(objects_recurse_input)):] = []
@@ -193,6 +191,13 @@
default=True,
)
+ margin = FloatProperty(
+ name="Margin",
+ description="Gaps for the fracture (gives more stable physics)",
+ min=0.0, max=1.0,
+ default=0.001,
+ )
+
# -------------------------------------------------------------------------
# Object Options
@@ -230,8 +235,8 @@
items=(('RANDOM', "Random", ""),
('SIZE_MIN', "Small", "Recursively subdivide smaller objects"),
('SIZE_MAX', "Big", "Recursively subdivide smaller objects"),
- ('CURSOR_MIN', "Cursor Min", "Recursively subdivide objects closer to the cursor"),
- ('CURSOR_MAX', "Cursor Max", "Recursively subdivide objects closer to the cursor"),
+ ('CURSOR_MIN', "Cursor Close", "Recursively subdivide objects closer to the cursor"),
+ ('CURSOR_MAX', "Cursor Far", "Recursively subdivide objects closer to the cursor"),
),
default='SIZE_MIN',
)
@@ -247,7 +252,7 @@
def invoke(self, context, event):
print(self.recursion_chance_select)
wm = context.window_manager
- return wm.invoke_props_dialog(self, width=600)
+ return wm.invoke_props_dialog(self, width=1000)
def draw(self, context):
layout = self.layout
@@ -268,6 +273,7 @@
rowsub.prop(self, "use_smooth_faces")
rowsub.prop(self, "use_smooth_edges")
rowsub.prop(self, "use_data_match")
+ rowsub.prop(self, "margin")
# rowsub.prop(self, "use_island_split") # TODO
box = layout.box()
Modified: trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_calc.py
===================================================================
--- trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_calc.py 2012-06-29 12:43:47 UTC (rev 3552)
+++ trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_calc.py 2012-06-29 17:43:46 UTC (rev 3553)
@@ -21,7 +21,9 @@
# Script copyright (C) Blender Foundation 2012
-def points_as_bmesh_cells(verts, points, margin=0.01):
+def points_as_bmesh_cells(verts, points,
+ margin_bounds=0.01,
+ margin_cell=0.0):
import mathutils
from mathutils import Vector
@@ -38,9 +40,9 @@
ya = [v[1] for v in verts]
za = [v[2] for v in verts]
- xmin, xmax = min(xa) - margin, max(xa) + margin
- ymin, ymax = min(ya) - margin, max(ya) + margin
- zmin, zmax = min(za) - margin, max(za) + margin
+ xmin, xmax = min(xa) - margin_bounds, max(xa) + margin_bounds
+ ymin, ymax = min(ya) - margin_bounds, max(ya) + margin_bounds
+ zmin, zmax = min(za) - margin_bounds, max(za) + margin_bounds
convexPlanes = [
Vector((+1.0, 0.0, 0.0, -abs(xmax))),
Vector((-1.0, 0.0, 0.0, -abs(xmin))),
@@ -67,7 +69,7 @@
plane = normal.normalized()
plane.resize_4d()
- plane[3] = -nlength / 2.0
+ plane[3] = (-nlength / 2.0) + margin_cell
planes.append(plane)
vertices[:], plane_indices[:] = mathutils.geometry.points_in_planes(planes)
Modified: trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_setup.py
===================================================================
--- trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_setup.py 2012-06-29 12:43:47 UTC (rev 3552)
+++ trunk/py/scripts/addons/object_fracture_voroni/fracture_cell_setup.py 2012-06-29 17:43:46 UTC (rev 3553)
@@ -123,6 +123,7 @@
use_smooth_edges=True,
use_data_match=False,
use_island_split=False,
+ margin=0.0,
):
from . import fracture_cell_calc
@@ -173,7 +174,8 @@
matrix = obj.matrix_world.copy()
verts = [matrix * v.co for v in mesh.vertices]
- cells = fracture_cell_calc.points_as_bmesh_cells(verts, points)
+ cells = fracture_cell_calc.points_as_bmesh_cells(verts, points,
+ margin_cell=margin)
# some hacks here :S
cell_name = obj.name + "_cell"
@@ -259,7 +261,7 @@
game = obj_cell.game
game.physics_type = 'RIGID_BODY'
game.use_collision_bounds = True
- game.collision_bounds_type = 'TRIANGLE_MESH'
+ game.collision_bounds_type = 'CONVEX_HULL'
return objects
More information about the Bf-extensions-cvs
mailing list