From 1b0bdd0444bcdb5726304e5edfdfbd36f9c150f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Jul 2012 07:54:56 +0000 Subject: minor improvement to cell fracture algo. --- object_fracture_cell/__init__.py | 8 ++++---- object_fracture_cell/fracture_cell_calc.py | 10 +++++++--- 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: -- cgit v1.2.3