diff --git a/src/shapes/Shape.js b/src/shapes/Shape.js index a90cfd4d..00bd9211 100644 --- a/src/shapes/Shape.js +++ b/src/shapes/Shape.js @@ -2,8 +2,8 @@ module.exports = Shape; var vec2 = require('../math/vec2'); -let PLAYER = Math.pow(2,0); -let EVERYTHING_EXCEPT_PLAYER = Math.pow(2,1); +var PLAYER = Math.pow(2,0); +var EVERYTHING_EXCEPT_PLAYER = Math.pow(2,1); /** * Base class for shapes. @@ -115,7 +115,7 @@ function Shape(options){ * @type {Number} */ this.collisionMask = options.collisionMask !== undefined ? options.collisionMask : EVERYTHING_EXCEPT_PLAYER | PLAYER; - + /** * Material to use in collisions for this Shape. If this is set to null, the world will use default material properties instead. * @property material @@ -244,4 +244,4 @@ Shape.prototype.computeAABB = function(out, position, angle){ */ Shape.prototype.raycast = function(result, ray, position, angle){ // To be implemented in each subclass -}; \ No newline at end of file +}; diff --git a/src/world/IslandManager.js b/src/world/IslandManager.js index bebfe712..6bcd5f9b 100644 --- a/src/world/IslandManager.js +++ b/src/world/IslandManager.js @@ -167,10 +167,14 @@ IslandManager.prototype.split = function(world){ j=bodies.indexOf(eq.bodyB), ni=nodes[i], nj=nodes[j]; - ni.neighbors.push(nj); - nj.neighbors.push(ni); - ni.equations.push(eq); - nj.equations.push(eq); + if (ni) { + ni.neighbors.push(nj); + ni.equations.push(eq); + } + if (nj) { + nj.neighbors.push(ni); + nj.equations.push(eq); + } } // Move old islands to the island pool