mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Make findBestIntersection() more strict and improve comments.
This commit is contained in:
parent
94853669f6
commit
af5a5b5f2d
1 changed files with 8 additions and 11 deletions
|
@ -523,21 +523,18 @@ PathItem.inject(new function() {
|
||||||
nextSeg = seg.getNext(),
|
nextSeg = seg.getNext(),
|
||||||
nextInter = nextSeg._intersection;
|
nextInter = nextSeg._intersection;
|
||||||
// See if this segment and the next are both not visited yet, or
|
// See if this segment and the next are both not visited yet, or
|
||||||
// are bringing us back to the beginning, and are both part of
|
// are bringing us back to the beginning, and are both valid,
|
||||||
// the boolean result.
|
// meaning they are part of the boolean result.
|
||||||
// Handling overlaps correctly here is tricky, requiring two
|
// Handling overlaps correctly requires two passes, first with
|
||||||
// passes, first with strict = true, then false:
|
// strict set to true, then false:
|
||||||
// In strict mode, the current and the next segment are both
|
// In strict mode, the next segment is not allowed to be an
|
||||||
// checked for validity, and only the current one is allowed to
|
// overlap. In non-strict mode, the next segment may be invalid
|
||||||
// be an overlap.
|
// if it offers a switch to a valid segment.
|
||||||
// If this pass does not yield a result, the non-strict mode is
|
|
||||||
// used, in which invalid current segments are tolerated, and
|
|
||||||
// overlaps for the next segment are allowed.
|
|
||||||
if (seg !== exclude && (isStart(seg) || isStart(nextSeg)
|
if (seg !== exclude && (isStart(seg) || isStart(nextSeg)
|
||||||
|| !seg._visited && !nextSeg._visited
|
|| !seg._visited && !nextSeg._visited
|
||||||
// Self-intersections (!operator) don't need isValid() calls
|
// Self-intersections (!operator) don't need isValid() calls
|
||||||
&& (!operator
|
&& (!operator
|
||||||
|| (!strict || isValid(seg))
|
|| isValid(seg)
|
||||||
// Do not consider nextSeg in strict mode if it is part
|
// Do not consider nextSeg in strict mode if it is part
|
||||||
// of an overlap, in order to give non-overlapping
|
// of an overlap, in order to give non-overlapping
|
||||||
// options that might follow the priority over overlaps.
|
// options that might follow the priority over overlaps.
|
||||||
|
|
Loading…
Reference in a new issue