Fix calls counting in addCurveIntersections() when dealing with straight curves.

See https://github.com/paperjs/paper.js/issues/1239#issuecomment-284340550
This commit is contained in:
Jürg Lehni 2017-03-06 10:13:14 +01:00
parent b85fc988de
commit b680ec05b9

View file

@ -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.