Remove includeOverlaps parameter from getCrossings()

And write better comments about how overlaps should be dealt with ideally.
This commit is contained in:
Jürg Lehni 2016-01-07 11:18:46 +01:00
parent 2fc7684efb
commit af797df5ba
2 changed files with 11 additions and 10 deletions

View file

@ -92,9 +92,8 @@ PathItem.inject(new function() {
_path2.reverse();
// Split curves at crossings on both paths. Note that for self-
// intersection, path2 is null and getIntersections() handles it.
var crossings = divideLocations(CurveLocation.expand(
// Only handle overlaps when not self-intersecting
_path1.getCrossings(_path2, !!_path2))),
var crossings = divideLocations(
CurveLocation.expand(_path1.getCrossings(_path2))),
segments = [],
// Aggregate of all curves in both operands, monotonic in y.
monoCurves = [],
@ -156,7 +155,7 @@ PathItem.inject(new function() {
return null;
var _path1 = preparePath(path1, false),
_path2 = preparePath(path2, false),
crossings = _path1.getCrossings(_path2, true),
crossings = _path1.getCrossings(_path2),
sub = operator.subtract,
paths = [];

View file

@ -146,16 +146,18 @@ var PathItem = Item.extend(/** @lends PathItem# */{
* crossing each other, as opposed to simply touching.
*
* @param {PathItem} path the other item to find the crossings with
* @param {Boolean} includeOverlaps whether to also count overlaps as
* crossings
* @see #getIntersections(path)
*/
getCrossings: function(path, includeOverlaps) {
getCrossings: function(path) {
return this.getIntersections(path, function(inter) {
// TODO: Only return overlaps that are actually crossings! For this
// we need proper overlap range detection first.
// Check overlap first since it's the cheaper test between the two.
return includeOverlaps && inter._overlap || inter.isCrossing();
// we need proper overlap range detection / merging first...
// But as we call #resolveCrossings() first in boolean operations,
// removing all self-touching areas in paths, this currently works
// as it should in the known use cases.
// The ideal implementation would deal with it in a way outlined in:
// https://github.com/paperjs/paper.js/issues/874#issuecomment-168332391
return inter._overlap || inter.isCrossing();
});
},