mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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.
|
// Now determine the winding for each path, from large to small.
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
var path1 = sorted[i],
|
var path1 = sorted[i],
|
||||||
indicesI = collisions[i];
|
indicesI = collisions[i],
|
||||||
|
entry1 = lookup[path1._id],
|
||||||
|
containerWinding = 0;
|
||||||
if (indicesI) {
|
if (indicesI) {
|
||||||
var entry1 = lookup[path1._id],
|
var point = null; // interior point, only get it if required
|
||||||
point = null; // interior point, only get it if required
|
|
||||||
containerWinding = 0;
|
|
||||||
for (var j = indicesI.length - 1; j >= 0; j--) {
|
for (var j = indicesI.length - 1; j >= 0; j--) {
|
||||||
if (indicesI[j] < i) {
|
if (indicesI[j] < i) {
|
||||||
point = point || path1.getInteriorPoint();
|
point = point || path1.getInteriorPoint();
|
||||||
|
@ -1142,7 +1142,7 @@ PathItem.inject(new function() {
|
||||||
* @return {Number} the winding number
|
* @return {Number} the winding number
|
||||||
*/
|
*/
|
||||||
_getWinding: function(point, dir, closed) {
|
_getWinding: function(point, dir, closed) {
|
||||||
let curves = this.getCurves();
|
var curves = this.getCurves();
|
||||||
return getWinding(point, curves, curves, dir, closed);
|
return getWinding(point, curves, curves, dir, closed);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,13 @@ var CollisionDetection = /** @lends CollisionDetection */{
|
||||||
// Binary search utility function.
|
// Binary search utility function.
|
||||||
// For multiple same entries, this returns the rightmost entry.
|
// For multiple same entries, this returns the rightmost entry.
|
||||||
// https://en.wikipedia.org/wiki/Binary_search_algorithm#Procedure_for_finding_the_rightmost_element
|
// https://en.wikipedia.org/wiki/Binary_search_algorithm#Procedure_for_finding_the_rightmost_element
|
||||||
var lo, hi;
|
var self = !boundsB || boundsA === boundsB,
|
||||||
var binarySearch = function(indices, coordinateValue, coordinate) {
|
allBounds = self ? boundsA : boundsA.concat(boundsB),
|
||||||
|
countA = boundsA.length,
|
||||||
|
countAll = allBounds.length,
|
||||||
|
lo, hi;
|
||||||
|
|
||||||
|
function binarySearch(indices, coordinateValue, coordinate) {
|
||||||
lo = 0;
|
lo = 0;
|
||||||
hi = indices.length;
|
hi = indices.length;
|
||||||
while (lo < hi) {
|
while (lo < hi) {
|
||||||
|
@ -179,13 +184,8 @@ var CollisionDetection = /** @lends CollisionDetection */{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lo - 1;
|
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
|
// Set coordinates for primary and secondary axis depending on sweep
|
||||||
// direction. By default we sweep in horizontal direction, which
|
// direction. By default we sweep in horizontal direction, which
|
||||||
// means x is the primary axis.
|
// means x is the primary axis.
|
||||||
|
@ -208,7 +208,7 @@ var CollisionDetection = /** @lends CollisionDetection */{
|
||||||
allCollisions = new Array(countA);
|
allCollisions = new Array(countA);
|
||||||
for (var i = 0; i < countAll; i++) {
|
for (var i = 0; i < countAll; i++) {
|
||||||
var currentIndex = allIndicesByP0[i],
|
var currentIndex = allIndicesByP0[i],
|
||||||
currentBounds = allBounds[currentIndex];
|
currentBounds = allBounds[currentIndex],
|
||||||
currentOriginalIndex = self ? currentIndex
|
currentOriginalIndex = self ? currentIndex
|
||||||
: currentIndex - countA, // index in boundsA or boundsB array
|
: currentIndex - countA, // index in boundsA or boundsB array
|
||||||
isCurrentA = currentIndex < countA,
|
isCurrentA = currentIndex < countA,
|
||||||
|
@ -279,7 +279,7 @@ var CollisionDetection = /** @lends CollisionDetection */{
|
||||||
activeIndicesByP1.push(currentIndex);
|
activeIndicesByP1.push(currentIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Sort collision indioes in ascending order
|
// Sort collision indices in ascending order
|
||||||
for (var i = 0; i < allCollisions.length; i++) {
|
for (var i = 0; i < allCollisions.length; i++) {
|
||||||
if (allCollisions[i]) {
|
if (allCollisions[i]) {
|
||||||
allCollisions[i].sort(function(i1, i2) {
|
allCollisions[i].sort(function(i1, i2) {
|
||||||
|
|
Loading…
Reference in a new issue