Skip to content

Commit d249165

Browse files
committed
added Body.nextCategory
1 parent 5888ffc commit d249165

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/body/Body.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ var Body = {};
1616
Body._inertiaScale = 4;
1717

1818
var _nextCollidingGroupId = 1,
19-
_nextNonCollidingGroupId = -1;
19+
_nextNonCollidingGroupId = -1,
20+
_nextCategory = 0x0001;
2021

2122
/**
2223
* Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults.
@@ -89,6 +90,17 @@ var Body = {};
8990
return _nextCollidingGroupId++;
9091
};
9192

93+
/**
94+
* Returns the next unique category bitfield (starting after the initial default category `0x0001`).
95+
* There are 32 available. See `body.collisionFilter` for more information.
96+
* @method nextCategory
97+
* @return {Number} Unique category bitfield
98+
*/
99+
Body.nextCategory = function() {
100+
_nextCategory = _nextCategory << 1;
101+
return _nextCategory;
102+
};
103+
92104
/**
93105
* Initialises body properties.
94106
* @method _initProperties

0 commit comments

Comments
 (0)