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 11:54:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-05 11:54:56 +0400
commit1b0bdd0444bcdb5726304e5edfdfbd36f9c150f4 (patch)
treeaccb7b28e2f7bf51674a80c524863c6475e50431 /object_fracture_cell
parentb5dd382b5a166d0d44b89ef2758c89e271ac78ea (diff)
minor improvement to cell fracture algo.
Diffstat (limited to 'object_fracture_cell')
-rw-r--r--object_fracture_cell/__init__.py8
-rw-r--r--object_fracture_cell/fracture_cell_calc.py10
2 files changed, 11 insertions, 7 deletions
diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py
index d284e205..0fcf7940 100644
--- a/object_fracture_cell/__init__.py
+++ b/object_fracture_cell/__init__.py
@@ -24,10 +24,10 @@ bl_info = {
"location": "Search > Fracture Object & Add -> Fracture Helper Objects",
"description": "Fractured Object, Bomb, Projectile, Recorder",
"warning": "",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"\
- "Scripts/Object/Fracture",
- "tracker_url": "https://projects.blender.org/tracker/index.php?"\
- "func=detail&aid=21793",
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "Scripts/Object/Fracture",
+ "tracker_url": "https://projects.blender.org/tracker/index.php?"
+ "func=detail&aid=21793",
"category": "Object"}
diff --git a/object_fracture_cell/fracture_cell_calc.py b/object_fracture_cell/fracture_cell_calc.py
index 3b9e5a16..d75f6994 100644
--- a/object_fracture_cell/fracture_cell_calc.py
+++ b/object_fracture_cell/fracture_cell_calc.py
@@ -24,6 +24,7 @@
def points_as_bmesh_cells(verts, points,
margin_bounds=0.05,
margin_cell=0.0):
+ from math import sqrt
import mathutils
from mathutils import Vector
@@ -79,11 +80,14 @@ def points_as_bmesh_cells(verts, points,
if len(plane_indices) != len(planes):
planes[:] = [planes[k] for k in plane_indices]
- distance_max = vertices[0].length
- for k in range(1, len(vertices)):
- distance = vertices[k].length
+ # for comparisons use length_squared and delay
+ # converting to a real length until the end.
+ distance_max = 10000000000.0 # a big value!
+ for v in vertices:
+ distance = v.length_squared
if distance_max < distance:
distance_max = distance
+ distance_max = sqrt(distance_max) # make real length
distance_max *= 2.0
if len(vertices) == 0: