Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-05 14:25:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-05 14:25:16 +0400
commit8c0210974911aafdbfbc10df89fb11178ed1c118 (patch)
treea59721b7bfd529a066f9b6b42750d433c8d98c17 /object_fracture_cell
parent1b0bdd0444bcdb5726304e5edfdfbd36f9c150f4 (diff)
non uniform cell shape, currently only xyz scale.
Diffstat (limited to 'object_fracture_cell')
-rw-r--r--object_fracture_cell/__init__.py10
-rw-r--r--object_fracture_cell/fracture_cell_calc.py26
-rw-r--r--object_fracture_cell/fracture_cell_setup.py7
3 files changed, 40 insertions, 3 deletions
diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py
index 0fcf7940..01216409 100644
--- a/object_fracture_cell/__init__.py
+++ b/object_fracture_cell/__init__.py
@@ -40,6 +40,7 @@ from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
+ FloatVectorProperty,
EnumProperty)
from bpy.types import Operator
@@ -192,6 +193,14 @@ class FractureCell(Operator):
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 @@ class FractureCell(Operator):
rowsub.prop(self, "source_limit")
rowsub.prop(self, "source_noise")
rowsub = col.row()
+ rowsub.prop(self, "cell_scale")
box = layout.box()
col = box.column()
diff --git a/object_fracture_cell/fracture_cell_calc.py b/object_fracture_cell/fracture_cell_calc.py
index d75f6994..884fec11 100644
--- a/object_fracture_cell/fracture_cell_calc.py
+++ b/object_fracture_cell/fracture_cell_calc.py
@@ -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 @@ def points_as_bmesh_cells(verts, points,
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 @@ def points_as_bmesh_cells(verts, points,
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
diff --git a/object_fracture_cell/fracture_cell_setup.py b/object_fracture_cell/fracture_cell_setup.py
index a3365828..19a5086a 100644
--- a/object_fracture_cell/fracture_cell_setup.py
+++ b/object_fracture_cell/fracture_cell_setup.py
@@ -125,6 +125,7 @@ def cell_fracture_objects(scene, obj,
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 @@ def cell_fracture_objects(scene, obj,
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 @@ def cell_fracture_objects(scene, obj,
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