Switch to absolute winding values in getWinding()

That’s what the previous code was already doing, but cryptically so. Relates to #1073
This commit is contained in:
Jürg Lehni 2017-02-04 21:38:17 +01:00
parent 0e8b304715
commit 4d6ebe2f3f

View file

@ -42,7 +42,7 @@ PathItem.inject(new function() {
intersect: { '2': true }, intersect: { '2': true },
subtract: { '1': true }, subtract: { '1': true },
// exclude only needs -1 to support reorientPaths() when there are // exclude only needs -1 to support reorientPaths() when there are
// no crossings. // no crossings. The actual boolean code uses unsigned winding.
exclude: { '1': true, '-1': true } exclude: { '1': true, '-1': true }
}; };
@ -673,13 +673,12 @@ PathItem.inject(new function() {
vClose = null; vClose = null;
} }
} }
// TODO: If the winding one // Use the unsigned winding contributions when determining which areas
windingL = windingL && (2 - abs(windingL) % 2); // are part of the boolean result.
windingR = windingR && (2 - abs(windingR) % 2); windingL = abs(windingL);
// Return the calculated winding contribution and detect if we are windingR = abs(windingR);
// on the contour of the area by comparing windingL and windingR. // Return the calculated winding contributions along with a quality
// This is required when handling unite operations, where a winding // value indicating how reliable the value really is.
// number of 2 is not part of the result unless it's the contour:
return { return {
winding: max(windingL, windingR), winding: max(windingL, windingR),
windingL: windingL, windingL: windingL,