Skip to content

Commit

Permalink
fix Body.setStatic(body, false), closes #187
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 4, 2016
1 parent c72a9d0 commit a815ce4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/body/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ var Axes = require('../geometry/Axes');
part.isStatic = isStatic;

if (isStatic) {
part._original = {
restitution: part.restitution,
friction: part.friction,
mass: part.mass,
inertia: part.inertia,
density: part.density,
inverseMass: part.inverseMass,
inverseInertia: part.inverseInertia
};

part.restitution = 0;
part.friction = 1;
part.mass = part.inertia = part.density = Infinity;
Expand All @@ -249,6 +259,16 @@ var Axes = require('../geometry/Axes');
part.speed = 0;
part.angularSpeed = 0;
part.motion = 0;
} else if (part._original) {
part.restitution = part._original.restitution;
part.friction = part._original.friction;
part.mass = part._original.mass;
part.inertia = part._original.inertia;
part.density = part._original.density;
part.inverseMass = part._original.inverseMass;
part.inverseInertia = part._original.inverseInertia;

delete part._original;
}
}
};
Expand Down

0 comments on commit a815ce4

Please sign in to comment.