Skip to content

Commit 9655785

Browse files
committed
fixed Body.setStatic when applied multiple times, closes #641
1 parent b88c82f commit 9655785

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/body/Body.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,19 @@ var Axes = require('../geometry/Axes');
260260
Body.setStatic = function(body, isStatic) {
261261
for (var i = 0; i < body.parts.length; i++) {
262262
var part = body.parts[i];
263-
part.isStatic = isStatic;
264263

265264
if (isStatic) {
266-
part._original = {
267-
restitution: part.restitution,
268-
friction: part.friction,
269-
mass: part.mass,
270-
inertia: part.inertia,
271-
density: part.density,
272-
inverseMass: part.inverseMass,
273-
inverseInertia: part.inverseInertia
274-
};
265+
if (!part.isStatic) {
266+
part._original = {
267+
restitution: part.restitution,
268+
friction: part.friction,
269+
mass: part.mass,
270+
inertia: part.inertia,
271+
density: part.density,
272+
inverseMass: part.inverseMass,
273+
inverseInertia: part.inverseInertia
274+
};
275+
}
275276

276277
part.restitution = 0;
277278
part.friction = 1;
@@ -296,6 +297,8 @@ var Axes = require('../geometry/Axes');
296297

297298
part._original = null;
298299
}
300+
301+
part.isStatic = isStatic;
299302
}
300303
};
301304

0 commit comments

Comments
 (0)