[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3585] trunk/py/scripts/addons/ object_fracture_cell: non uniform cell shape, currently only xyz scale.
Campbell Barton
ideasman42 at gmail.com
Thu Jul 5 12:25:17 CEST 2012
Revision: 3585
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3585
Author: campbellbarton
Date: 2012-07-05 10:25:16 +0000 (Thu, 05 Jul 2012)
Log Message:
-----------
non uniform cell shape, currently only xyz scale.
Modified Paths:
--------------
trunk/py/scripts/addons/object_fracture_cell/__init__.py
trunk/py/scripts/addons/object_fracture_cell/fracture_cell_calc.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-05 09:05:22 UTC (rev 3584)
+++ trunk/py/scripts/addons/object_fracture_cell/__init__.py 2012-07-05 10:25:16 UTC (rev 3585)
@@ -40,6 +40,7 @@
BoolProperty,
IntProperty,
FloatProperty,
+ FloatVectorProperty,
EnumProperty)
from bpy.types import Operator
@@ -192,6 +193,14 @@
default=0.0,
)
+ cell_scale = FloatVectorProperty(
+ name="Scale",
+ description="Scale Cell Shape",
+ size=3,
+ min=0.0, max=1.0,
+ default=(1.0, 1.0, 1.0),
+ )
+
# -------------------------------------------------------------------------
# Recursion
@@ -330,6 +339,7 @@
rowsub.prop(self, "source_limit")
rowsub.prop(self, "source_noise")
rowsub = col.row()
+ rowsub.prop(self, "cell_scale")
box = layout.box()
col = box.column()
Modified: trunk/py/scripts/addons/object_fracture_cell/fracture_cell_calc.py
===================================================================
--- trunk/py/scripts/addons/object_fracture_cell/fracture_cell_calc.py 2012-07-05 09:05:22 UTC (rev 3584)
+++ trunk/py/scripts/addons/object_fracture_cell/fracture_cell_calc.py 2012-07-05 10:25:16 UTC (rev 3585)
@@ -21,7 +21,9 @@
# Script copyright (C) Blender Foundation 2012
-def points_as_bmesh_cells(verts, points,
+def points_as_bmesh_cells(verts,
+ points,
+ points_scale=None,
margin_bounds=0.05,
margin_cell=0.0):
from math import sqrt
@@ -29,6 +31,14 @@
from mathutils import Vector
cells = []
+
+ '''
+ if points_scale:
+ points_scale = (1.0 / points_scale[0],
+ 1.0 / points_scale[1],
+ 1.0 / points_scale[2],
+ )
+ '''
points_sorted_current = [p for p in points]
plane_indices = []
@@ -65,6 +75,20 @@
for j in range(1, len(points)):
normal = points_sorted_current[j] - point_cell_current
nlength = normal.length
+
+ if points_scale is not None:
+ normal_alt = normal.copy()
+ normal_alt.x *= points_scale[0]
+ normal_alt.y *= points_scale[1]
+ normal_alt.z *= points_scale[2]
+
+ # rotate plane to new distance
+ # should always be positive!! - but abs incase
+ scalar = normal_alt.normalized().dot(normal.normalized())
+ # assert(scalar >= 0.0)
+ nlength *= scalar
+ normal = normal_alt
+
if nlength > distance_max:
break
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-05 09:05:22 UTC (rev 3584)
+++ trunk/py/scripts/addons/object_fracture_cell/fracture_cell_setup.py 2012-07-05 10:25:16 UTC (rev 3585)
@@ -125,6 +125,7 @@
margin=0.0,
material_index=0,
use_debug_redraw=False,
+ cell_scale=(1.0, 1.0, 1.0),
):
from . import fracture_cell_calc
@@ -136,7 +137,7 @@
if not points:
# print using fallback
- points = _points_from_object(obj, source | {'VERT_OWN'})
+ points = _points_from_object(obj, {'VERT_OWN'})
if not points:
print("no points found")
@@ -187,7 +188,9 @@
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,
+ cell_scale,
margin_cell=margin)
# some hacks here :S
More information about the Bf-extensions-cvs
mailing list