From 86b1b74869e61ce8484e6a7b844ea62406b623e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 3 Oct 2015 12:55:32 -0500 Subject: [PATCH] Prevent detection of tiny overlaps and streamline addOverlap() code. --- src/path/Curve.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index 0caca696ce..7b5ca983de 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1733,12 +1733,11 @@ new function() { // Scope for intersection using bezier fat-line clipping v[i][t1 === 0 ? 1 : 7]); if (t2 != null) { // If point is on curve var pair = i === 0 ? [t1, t2] : [t2, t1]; - if (pairs.length === 1 && pair[0] < pairs[0][0]) { - pairs.unshift(pair); - } else if (pairs.length === 0 - // TODO: Compare distance of the actual points instead! + // Filter out tiny overlaps + // TODO: Compare distance of points instead of curve time? + if (pairs.length === 0 || abs(pair[0] - pairs[0][0]) > timeEpsilon - || abs(pair[1] - pairs[0][1]) > timeEpsilon) { + && abs(pair[1] - pairs[0][1]) > timeEpsilon) { pairs.push(pair); } } @@ -1751,12 +1750,7 @@ new function() { // Scope for intersection using bezier fat-line clipping if (pairs.length === 2) { // create values for overlapping part of each curve var p1 = Curve.getPart(v[0], pairs[0][0], pairs[1][0]), - p2 = Curve.getPart(v[1], Math.min(pairs[0][1], pairs[1][1]), - Math.max(pairs[0][1], pairs[1][1])); - // Reverse values of second curve if necessary - if (pairs[0][1] > pairs[1][1]) { - p2 = [p2[6], p2[7], p2[4], p2[5], p2[2], p2[3], p2[0], p2[1]]; - } + p2 = Curve.getPart(v[1], pairs[0][1], pairs[1][1]); // Check if handles of overlapping paths are similar enough. // We could do another check for curve identity here if we find a // better criteria.