mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix various issues introduced in #1740
This commit is contained in:
parent
1f39b1df98
commit
a183dc0c0d
2 changed files with 34 additions and 34 deletions
|
@ -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];
|
||||
indicesI = collisions[i],
|
||||
entry1 = lookup[path1._id],
|
||||
containerWinding = 0;
|
||||
if (indicesI) {
|
||||
var entry1 = lookup[path1._id],
|
||||
point = null; // interior point, only get it if required
|
||||
containerWinding = 0;
|
||||
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);
|
||||
},
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue