Revert a row of recent changes that break example in #1091

This commit is contained in:
Jürg Lehni 2016-07-17 20:35:36 +02:00
parent c9100a2b61
commit 4bb2f7a8fc

View file

@ -105,9 +105,9 @@ PathItem.inject(new function() {
var path = paths[i]; var path = paths[i];
segments.push.apply(segments, path._segments); segments.push.apply(segments, path._segments);
curves.push.apply(curves, path.getCurves()); curves.push.apply(curves, path.getCurves());
// Keep track of whether there are valid intersections that are // Keep track if there are valid intersections other than
// not overlaps in each path. // overlaps in each path.
path._overlapsOnly = true; path._overlapsOnly = path._validOverlapsOnly = true;
} }
} }
@ -130,11 +130,16 @@ PathItem.inject(new function() {
if (segment._winding == null) { if (segment._winding == null) {
propagateWinding(segment, _path1, _path2, curves, operator); propagateWinding(segment, _path1, _path2, curves, operator);
} }
// See if there are any valid segments that aren't part of overlaps.
// This information is used to determine where to start tracing the
// path, and how to treat encountered invalid segments.
if (!(inter && inter._overlap)) { if (!(inter && inter._overlap)) {
// Keep track of whether there are valid intersections that are var path = segment._path;
// not overlaps in each path. This information is used later to path._overlapsOnly = false;
// handle fully overlapping paths. // This is not an overlap. If it is valid, take note that there
segment._path._overlapsOnly = false; // are valid intersections other than overlaps in this path.
if (operator[segment._winding])
path._validOverlapsOnly = false;
} }
} }
return createResult(CompoundPath, tracePaths(segments, operator), true, return createResult(CompoundPath, tracePaths(segments, operator), true,
@ -492,8 +497,8 @@ PathItem.inject(new function() {
// Use the on-path windings if no other intersections // Use the on-path windings if no other intersections
// were found or if they canceled each other. // were found or if they canceled each other.
var add = path.isClockwise() ? 1 : -1; var add = path.isClockwise() ? 1 : -1;
windingL += add; // windingL += add;
windingR -= add; // windingR -= add;
onPathWinding += add; onPathWinding += add;
} else { } else {
windingL += pathWindingL; windingL += pathWindingL;
@ -713,8 +718,11 @@ PathItem.inject(new function() {
seg._visited = true; seg._visited = true;
break; break;
} }
// If we encounter and invalid segment, bail out immediately. // If there are only valid overlaps and we encounter and invalid
if (!isValid(seg)) // segment, bail out immediately. Otherwise we need to be more
// tolerant due to complex situations of crossing,
// see findBestIntersection()
if (seg._path._validOverlapsOnly && !isValid(seg))
break; break;
if (!path) { if (!path) {
path = new Path(Item.NO_INSERT); path = new Path(Item.NO_INSERT);