Fix various issues introduced in #1740

This commit is contained in:
Jürg Lehni 2019-12-13 16:13:56 +01:00
parent 1f39b1df98
commit a183dc0c0d
2 changed files with 34 additions and 34 deletions

View file

@ -349,11 +349,11 @@ PathItem.inject(new function() {
// Now determine the winding for each path, from large to small.
for (var i = 0; i < length; i++) {
var path1 = sorted[i],
indicesI = collisions[i];
if (indicesI) {
var entry1 = lookup[path1._id],
point = null; // interior point, only get it if required
indicesI = collisions[i],
entry1 = lookup[path1._id],
containerWinding = 0;
if (indicesI) {
var point = null; // interior point, only get it if required
for (var j = indicesI.length - 1; j >= 0; j--) {
if (indicesI[j] < i) {
point = point || path1.getInteriorPoint();
@ -1142,7 +1142,7 @@ PathItem.inject(new function() {
* @return {Number} the winding number
*/
_getWinding: function(point, dir, closed) {
let curves = this.getCurves();
var curves = this.getCurves();
return getWinding(point, curves, curves, dir, closed);
},

View file

@ -166,8 +166,13 @@ var CollisionDetection = /** @lends CollisionDetection */{
// Binary search utility function.
// For multiple same entries, this returns the rightmost entry.
// https://en.wikipedia.org/wiki/Binary_search_algorithm#Procedure_for_finding_the_rightmost_element
var lo, hi;
var binarySearch = function(indices, coordinateValue, coordinate) {
var self = !boundsB || boundsA === boundsB,
allBounds = self ? boundsA : boundsA.concat(boundsB),
countA = boundsA.length,
countAll = allBounds.length,
lo, hi;
function binarySearch(indices, coordinateValue, coordinate) {
lo = 0;
hi = indices.length;
while (lo < hi) {
@ -179,13 +184,8 @@ var CollisionDetection = /** @lends CollisionDetection */{
}
}
return lo - 1;
};
}
//
var self = !boundsB || boundsA === boundsB,
allBounds = self ? boundsA : boundsA.concat(boundsB),
countA = boundsA.length,
countAll = allBounds.length;
// Set coordinates for primary and secondary axis depending on sweep
// direction. By default we sweep in horizontal direction, which
// means x is the primary axis.
@ -208,7 +208,7 @@ var CollisionDetection = /** @lends CollisionDetection */{
allCollisions = new Array(countA);
for (var i = 0; i < countAll; i++) {
var currentIndex = allIndicesByP0[i],
currentBounds = allBounds[currentIndex];
currentBounds = allBounds[currentIndex],
currentOriginalIndex = self ? currentIndex
: currentIndex - countA, // index in boundsA or boundsB array
isCurrentA = currentIndex < countA,
@ -279,7 +279,7 @@ var CollisionDetection = /** @lends CollisionDetection */{
activeIndicesByP1.push(currentIndex);
}
}
// Sort collision indioes in ascending order
// Sort collision indices in ascending order
for (var i = 0; i < allCollisions.length; i++) {
if (allCollisions[i]) {
allCollisions[i].sort(function(i1, i2) {