Skip to content

Commit 500d566

Browse files
committed
fix Demo.reset to fully reset ids
1 parent 19656cd commit 500d566

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

demo/js/Demo.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
}
2525

2626
// Matter aliases
27-
var Example = Matter.Example,
27+
var Body = Matter.Body,
28+
Example = Matter.Example,
2829
Engine = Matter.Engine,
2930
World = Matter.World,
3031
Common = Matter.Common,
@@ -295,6 +296,9 @@
295296
demo.sceneEvents = [];
296297

297298
// reset id pool
299+
Body._nextCollidingGroupId = 1;
300+
Body._nextNonCollidingGroupId = -1;
301+
Body._nextCategory = 0x0001;
298302
Common._nextId = 0;
299303

300304
// reset random seed

src/body/Body.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ var Axes = require('../geometry/Axes');
2424
(function() {
2525

2626
Body._inertiaScale = 4;
27-
28-
var _nextCollidingGroupId = 1,
29-
_nextNonCollidingGroupId = -1,
30-
_nextCategory = 0x0001;
27+
Body._nextCollidingGroupId = 1;
28+
Body._nextNonCollidingGroupId = -1;
29+
Body._nextCategory = 0x0001;
3130

3231
/**
3332
* 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');
10099
*/
101100
Body.nextGroup = function(isNonColliding) {
102101
if (isNonColliding)
103-
return _nextNonCollidingGroupId--;
102+
return Body._nextNonCollidingGroupId--;
104103

105-
return _nextCollidingGroupId++;
104+
return Body._nextCollidingGroupId++;
106105
};
107106

108107
/**
@@ -112,8 +111,8 @@ var Axes = require('../geometry/Axes');
112111
* @return {Number} Unique category bitfield
113112
*/
114113
Body.nextCategory = function() {
115-
_nextCategory = _nextCategory << 1;
116-
return _nextCategory;
114+
Body._nextCategory = Body._nextCategory << 1;
115+
return Body._nextCategory;
117116
};
118117

119118
/**

0 commit comments

Comments
 (0)