diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-05 11:54:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-05 11:54:56 +0400 |
commit | 1b0bdd0444bcdb5726304e5edfdfbd36f9c150f4 (patch) | |
tree | accb7b28e2f7bf51674a80c524863c6475e50431 /object_fracture_cell/fracture_cell_calc.py | |
parent | b5dd382b5a166d0d44b89ef2758c89e271ac78ea (diff) |
minor improvement to cell fracture algo.
Diffstat (limited to 'object_fracture_cell/fracture_cell_calc.py')
-rw-r--r-- | object_fracture_cell/fracture_cell_calc.py | 10 |
1 files changed, 7 insertions, 3 deletions
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: |