mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-23 09:26:51 -05:00
added clamping to position resolver damping
This commit is contained in:
parent
fba5af2116
commit
7c6cda00f8
1 changed files with 2 additions and 2 deletions
|
@ -69,7 +69,7 @@ var Bounds = require('../geometry/Bounds');
|
|||
bodyBtoAY,
|
||||
positionImpulse,
|
||||
timeScale = delta / Common._timeUnit,
|
||||
impulseCoefficient = Resolver._positionDampen * timeScale;
|
||||
damping = Common.clamp(Resolver._positionDampen * timeScale, 0, 1);
|
||||
|
||||
for (i = 0; i < bodies.length; i++) {
|
||||
var body = bodies[i];
|
||||
|
@ -103,7 +103,7 @@ var Bounds = require('../geometry/Bounds');
|
|||
separation = normalX * bodyBtoAX + normalY * bodyBtoAY;
|
||||
pair.separation = separation;
|
||||
|
||||
positionImpulse = (separation - pair.slop) * impulseCoefficient;
|
||||
positionImpulse = (separation - pair.slop) * damping;
|
||||
|
||||
if (bodyA.isStatic || bodyB.isStatic)
|
||||
positionImpulse *= 2;
|
||||
|
|
Loading…
Reference in a new issue