Skip to content

Commit

Permalink
Optimized Body's hidden class
Browse files Browse the repository at this point in the history
  • Loading branch information
bchevalier committed Nov 24, 2017
1 parent 0895d81 commit b3220cf
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/body/Body.js
Expand Up @@ -20,6 +20,7 @@ var Common = require('../core/Common');
var Bounds = require('../geometry/Bounds');
var Axes = require('../geometry/Axes');


(function() {

Body._inertiaScale = 4;
Expand Down Expand Up @@ -82,7 +83,22 @@ var Axes = require('../geometry/Axes');
yOffset: 0
},
lineWidth: 0
}
},

events: null,
bounds: null,
chamfer: null,
circleRadius: 0,

This comment has been minimized.

Copy link
@getkey

getkey Dec 1, 2019

This broke my code because I was using circleRadius !== undefined to check if the body was a circle (I don't like loose equality). Imo that change should be documented in the release notes for the next version. 🙂

positionPrev: null,
anglePrev: 0,
parent: null,

axes: null,
area: 0,
mass: 0,
inertia: 0,

_original: null
};

var body = Common.extend(defaults, options);
Expand Down Expand Up @@ -166,24 +182,18 @@ var Axes = require('../geometry/Axes');
* Prefer to use the actual setter functions in performance critical situations.
* @method set
* @param {body} body
* @param {} settings A property name (or map of properties and values) to set on the body.
* @param {} value The value to set if `settings` is a single property name.
* @param {object} settings A map of properties and values to set on the body.
*/
Body.set = function(body, settings, value) {
var property;

if (typeof settings === 'string') {
property = settings;
settings = {};
settings[property] = value;
}
Body.set = function(body, settings) {
var property,
value;

for (property in settings) {
value = settings[property];

if (!settings.hasOwnProperty(property))
continue;

value = settings[property];
switch (property) {

case 'isStatic':
Expand Down Expand Up @@ -269,7 +279,7 @@ var Axes = require('../geometry/Axes');
part.inverseMass = part._original.inverseMass;
part.inverseInertia = part._original.inverseInertia;

delete part._original;
part._original = null;
}
}
};
Expand Down

0 comments on commit b3220cf

Please sign in to comment.