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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-30 14:18:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-30 14:18:46 +0300
commite1ba5517e65a702bfabac00e5981cf1b103d971a (patch)
tree2b8e43d3c1fe2543e035f2e4aaaf9ff8b42cf9be /release/scripts
parenta2d757dc7d12ee6e58c853738a6a9a934da5b357 (diff)
better remove doubles for retopo, use 15th the of the average of both splines lengths (less scale dependant)
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/modules/retopo.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/release/scripts/modules/retopo.py b/release/scripts/modules/retopo.py
index e9cd6240740..081ac1b0168 100644
--- a/release/scripts/modules/retopo.py
+++ b/release/scripts/modules/retopo.py
@@ -20,16 +20,13 @@
import bpy
-EPS = 0.001
-EPS_LINE_LINE = 0.02
-EPS_COLLAPSE = 0.05
-EPS_HUB = 0.002
+EPS_SPLINE_DIV = 15.0 # remove doubles is ~15th the length of the spline
-def get_hub(co, _hubs):
+def get_hub(co, _hubs, EPS_SPLINE):
if 1:
for hub in _hubs.values():
- if (hub.co - co).length < EPS_HUB:
+ if (hub.co - co).length < EPS_SPLINE:
return hub
key = co.toTuple(3)
@@ -48,7 +45,8 @@ def get_hub(co, _hubs):
'''
-class Hub:
+class Hub(object):
+ __slots__ = "co", "key", "index", "links"
def __init__(self, co, key, index):
self.co = co.copy()
self.key = key
@@ -122,9 +120,18 @@ class Hub:
class Spline:
+ __slots__ = "points", "hubs", "length"
def __init__(self, points):
self.points = points
self.hubs = []
+
+ # calc length
+ f = 0.0
+ co_prev = self.points[0]
+ for co in self.points[1:]:
+ f += (co - co_prev).length
+ co_prev = co
+ self.length = f
def link(self):
if len(self.hubs) < 2:
@@ -174,7 +181,7 @@ def xsect_spline(sp_a, sp_b, _hubs):
from Mathutils import MidpointVecs
from Geometry import ClosestPointOnLine
pt_a_prev = pt_b_prev = None
-
+ EPS_SPLINE = (sp_a.length + sp_b.length) / (EPS_SPLINE_DIV * 2)
pt_a_prev = sp_a.points[0]
for a, pt_a in enumerate(sp_a.points[1:]):
pt_b_prev = sp_b.points[0]
@@ -184,14 +191,16 @@ def xsect_spline(sp_a, sp_b, _hubs):
# print(pt_a, pt_a_prev, pt_b, pt_b_prev)
xsect = LineIntersect(pt_a, pt_a_prev, pt_b, pt_b_prev)
if xsect is not None:
- if (xsect[0]-xsect[1]).length <= EPS_LINE_LINE:
+ if (xsect[0]-xsect[1]).length <= EPS_SPLINE:
f = ClosestPointOnLine(xsect[1], pt_a, pt_a_prev)[1]
+ # if f >= 0.0-EPS_SPLINE and f <= 1.0+EPS_SPLINE: # for some reason doesnt work so well, same below
if f >= 0.0 and f <= 1.0:
f = ClosestPointOnLine(xsect[0], pt_b, pt_b_prev)[1]
+ # if f >= 0.0-EPS_SPLINE and f <= 1.0+EPS_SPLINE:
if f >= 0.0 and f <= 1.0:
# This wont happen often
co = MidpointVecs(xsect[0], xsect[1])
- hub = get_hub(co, _hubs)
+ hub = get_hub(co, _hubs, EPS_SPLINE)
sp_a.hubs.append((a, hub))
sp_b.hubs.append((b, hub))