From b680ec05b96630bc81ae5aaadfef8affd6f5738e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 6 Mar 2017 10:13:14 +0100 Subject: [PATCH] Fix calls counting in addCurveIntersections() when dealing with straight curves. See https://github.com/paperjs/paper.js/issues/1239#issuecomment-284340550 --- src/path/Curve.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index 7e0dc232..0bc31673 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1759,18 +1759,19 @@ new function() { // Scope for bezier intersection using fat-line clipping // as well as the total amount of calls, to avoid massive call-trees as // suggested by @iconexperience in #904#issuecomment-225283430. // See also: #565 #899 #1074 - var abort = ++recursion >= 48 || ++calls > 256, - // Consider both curves as straight if we need to abort and see if + var abort = ++recursion >= 48 || ++calls > 4096, + // If we need to abort, consider both curves as straight and see if // their lines intersect. straight1 = abort || Curve.isStraight(v1), straight2 = abort || Curve.isStraight(v2); if (straight1 || straight2) { - return (straight1 && straight2 + (straight1 && straight2 ? addLineIntersection : addCurveLineIntersections)( flip ? v2 : v1, flip ? v1 : v2, flip ? c2 : c1, flip ? c1 : c2, locations, include, recursion); + return calls; } // Use an epsilon smaller than CURVETIME_EPSILON to compare curve-time // parameters in fat-line clipping code.