mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Make sure overlaps are always returned in correct sequence.
Relates to #1223
This commit is contained in:
parent
7d3d7351ab
commit
88453914e5
1 changed files with 9 additions and 3 deletions
|
@ -2105,6 +2105,7 @@ new function() { // Scope for intersection using bezier fat-line clipping
|
||||||
}
|
}
|
||||||
|
|
||||||
var v = [v1, v2],
|
var v = [v1, v2],
|
||||||
|
insert = 'push',
|
||||||
pairs = [];
|
pairs = [];
|
||||||
// Iterate through all end points:
|
// Iterate through all end points:
|
||||||
// First p1 and p2 of curve 1, then p1 and p2 of curve 2.
|
// First p1 and p2 of curve 1, then p1 and p2 of curve 2.
|
||||||
|
@ -2119,11 +2120,16 @@ new function() { // Scope for intersection using bezier fat-line clipping
|
||||||
// Filter out tiny overlaps.
|
// Filter out tiny overlaps.
|
||||||
if (!pairs.length ||
|
if (!pairs.length ||
|
||||||
abs(pair[0] - pairs[0][0]) > timeEpsilon &&
|
abs(pair[0] - pairs[0][0]) > timeEpsilon &&
|
||||||
abs(pair[1] - pairs[0][1]) > timeEpsilon)
|
abs(pair[1] - pairs[0][1]) > timeEpsilon) {
|
||||||
pairs.push(pair);
|
pairs[insert](pair);
|
||||||
|
// If the first pair isn't found in the first iteration,
|
||||||
|
// invert insertion to preserve overlap orientation.
|
||||||
|
if (i || t1)
|
||||||
|
insert = 'unshift';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// We checked 3 points but found no match, curves can't overlap.
|
// We checked 3 points but found no match, curves can't overlap.
|
||||||
if (i === 1 && !pairs.length)
|
if (i && !pairs.length)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pairs.length !== 2) {
|
if (pairs.length !== 2) {
|
||||||
|
|
Loading…
Reference in a new issue