0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-27 13:59:01 -05:00

fix Demo.reset to fully reset ids

This commit is contained in:
liabru 2015-12-25 15:57:27 +00:00
parent 19656cd5d1
commit 500d566772
2 changed files with 12 additions and 9 deletions

View file

@ -24,7 +24,8 @@
} }
// Matter aliases // Matter aliases
var Example = Matter.Example, var Body = Matter.Body,
Example = Matter.Example,
Engine = Matter.Engine, Engine = Matter.Engine,
World = Matter.World, World = Matter.World,
Common = Matter.Common, Common = Matter.Common,
@ -295,6 +296,9 @@
demo.sceneEvents = []; demo.sceneEvents = [];
// reset id pool // reset id pool
Body._nextCollidingGroupId = 1;
Body._nextNonCollidingGroupId = -1;
Body._nextCategory = 0x0001;
Common._nextId = 0; Common._nextId = 0;
// reset random seed // reset random seed

View file

@ -24,10 +24,9 @@ var Axes = require('../geometry/Axes');
(function() { (function() {
Body._inertiaScale = 4; Body._inertiaScale = 4;
Body._nextCollidingGroupId = 1;
var _nextCollidingGroupId = 1, Body._nextNonCollidingGroupId = -1;
_nextNonCollidingGroupId = -1, Body._nextCategory = 0x0001;
_nextCategory = 0x0001;
/** /**
* Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults. * Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults.
@ -100,9 +99,9 @@ var Axes = require('../geometry/Axes');
*/ */
Body.nextGroup = function(isNonColliding) { Body.nextGroup = function(isNonColliding) {
if (isNonColliding) if (isNonColliding)
return _nextNonCollidingGroupId--; return Body._nextNonCollidingGroupId--;
return _nextCollidingGroupId++; return Body._nextCollidingGroupId++;
}; };
/** /**
@ -112,8 +111,8 @@ var Axes = require('../geometry/Axes');
* @return {Number} Unique category bitfield * @return {Number} Unique category bitfield
*/ */
Body.nextCategory = function() { Body.nextCategory = function() {
_nextCategory = _nextCategory << 1; Body._nextCategory = Body._nextCategory << 1;
return _nextCategory; return Body._nextCategory;
}; };
/** /**