mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Prevent infinite loops through circular references of multiple intersections.
This commit is contained in:
parent
40570b3e59
commit
19a17b2918
1 changed files with 15 additions and 9 deletions
|
@ -215,15 +215,21 @@ PathItem.inject(new function() {
|
||||||
// Link the new segment with the intersection on the other curve
|
// Link the new segment with the intersection on the other curve
|
||||||
var inter = segment._intersection;
|
var inter = segment._intersection;
|
||||||
if (inter) {
|
if (inter) {
|
||||||
var other = inter._curve;
|
var other = inter._intersection,
|
||||||
|
next = loc._next;
|
||||||
|
while (next && next !== other) {
|
||||||
|
next = next._next;
|
||||||
|
}
|
||||||
|
if (!next) {
|
||||||
console.log('Link'
|
console.log('Link'
|
||||||
+ ', seg: ' + segment._path._id + '.' + segment._index
|
+ ', seg: ' + segment._path._id + '.' + segment._index
|
||||||
+ ', other: ' + other._path._id);
|
+ ', other: ' + inter._curve._path._id);
|
||||||
// Create a chain of possible intersections linked through _next
|
// Create a chain of possible intersections linked through _next
|
||||||
// First find the last intersection in the chain, then link it.
|
// First find the last intersection in the chain, then link it.
|
||||||
while (inter._next)
|
while (inter._next)
|
||||||
inter = inter._next;
|
inter = inter._next;
|
||||||
inter._next = loc._intersection;
|
inter._next = loc._intersection;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
segment._intersection = loc._intersection;
|
segment._intersection = loc._intersection;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue