Try linked up intersections first before switching to the other intersecetion.

This commit is contained in:
Jürg Lehni 2015-10-02 19:00:32 -05:00
parent 632eb25f19
commit 7496a7c9e2

View file

@ -591,19 +591,19 @@ PathItem.inject(new function() {
|| (!strict || isValid(seg, true)) || (!strict || isValid(seg, true))
&& isValid(next, !strict && inter._overlap)) && isValid(next, !strict && inter._overlap))
? inter ? inter
// If it's no match, check the other intersection first, then // If it's no match, check the next linked intersection first,
// carry on with the next linked intersection. // otherwise carry on with the 'other' intersection location.
: !ignoreOther : inter._next !== prev // Prevent circular loops
&& getIntersection(strict, inter._next, inter, false)
// We need to get the intersection on the segment, not // We need to get the intersection on the segment, not
// on inter, since multiple solutions are only linked up // on inter, since multiple solutions are only linked up
// as a chain through _next there. But do not check that // as a chain through _next there. But do not check that
// intersection in the first call to getIntersection() // intersection in the first call to getIntersection()
// (prev == null), since we'd go straight back to the // (prev == null), since we'd go straight back to the
// originating segment. // originating segment.
|| !ignoreOther
&& (prev || seg._intersection !== inter._intersection) && (prev || seg._intersection !== inter._intersection)
&& getIntersection(strict, seg._intersection, inter, true) && getIntersection(strict, seg._intersection, inter, true);
|| inter._next !== prev // Prevent circular loops
&& getIntersection(strict, inter._next, inter, false);
} }
for (var i = 0, l = segments.length; i < l; i++) { for (var i = 0, l = segments.length; i < l; i++) {
var seg = segments[i], var seg = segments[i],