mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
Optimized Body's hidden class
This commit is contained in:
parent
0895d81fa1
commit
b3220cf3e8
1 changed files with 23 additions and 13 deletions
|
@ -20,6 +20,7 @@ var Common = require('../core/Common');
|
||||||
var Bounds = require('../geometry/Bounds');
|
var Bounds = require('../geometry/Bounds');
|
||||||
var Axes = require('../geometry/Axes');
|
var Axes = require('../geometry/Axes');
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
Body._inertiaScale = 4;
|
Body._inertiaScale = 4;
|
||||||
|
@ -82,7 +83,22 @@ var Axes = require('../geometry/Axes');
|
||||||
yOffset: 0
|
yOffset: 0
|
||||||
},
|
},
|
||||||
lineWidth: 0
|
lineWidth: 0
|
||||||
}
|
},
|
||||||
|
|
||||||
|
events: null,
|
||||||
|
bounds: null,
|
||||||
|
chamfer: null,
|
||||||
|
circleRadius: 0,
|
||||||
|
positionPrev: null,
|
||||||
|
anglePrev: 0,
|
||||||
|
parent: null,
|
||||||
|
|
||||||
|
axes: null,
|
||||||
|
area: 0,
|
||||||
|
mass: 0,
|
||||||
|
inertia: 0,
|
||||||
|
|
||||||
|
_original: null
|
||||||
};
|
};
|
||||||
|
|
||||||
var body = Common.extend(defaults, options);
|
var body = Common.extend(defaults, options);
|
||||||
|
@ -166,24 +182,18 @@ var Axes = require('../geometry/Axes');
|
||||||
* Prefer to use the actual setter functions in performance critical situations.
|
* Prefer to use the actual setter functions in performance critical situations.
|
||||||
* @method set
|
* @method set
|
||||||
* @param {body} body
|
* @param {body} body
|
||||||
* @param {} settings A property name (or map of properties and values) to set on the body.
|
* @param {object} settings A map of properties and values to set on the body.
|
||||||
* @param {} value The value to set if `settings` is a single property name.
|
|
||||||
*/
|
*/
|
||||||
Body.set = function(body, settings, value) {
|
Body.set = function(body, settings) {
|
||||||
var property;
|
var property,
|
||||||
|
value;
|
||||||
if (typeof settings === 'string') {
|
|
||||||
property = settings;
|
|
||||||
settings = {};
|
|
||||||
settings[property] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (property in settings) {
|
for (property in settings) {
|
||||||
value = settings[property];
|
|
||||||
|
|
||||||
if (!settings.hasOwnProperty(property))
|
if (!settings.hasOwnProperty(property))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
value = settings[property];
|
||||||
switch (property) {
|
switch (property) {
|
||||||
|
|
||||||
case 'isStatic':
|
case 'isStatic':
|
||||||
|
@ -269,7 +279,7 @@ var Axes = require('../geometry/Axes');
|
||||||
part.inverseMass = part._original.inverseMass;
|
part.inverseMass = part._original.inverseMass;
|
||||||
part.inverseInertia = part._original.inverseInertia;
|
part.inverseInertia = part._original.inverseInertia;
|
||||||
|
|
||||||
delete part._original;
|
part._original = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue