0
0
Fork 0
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:
liabru 2019-09-01 16:57:16 +01:00
parent fba5af2116
commit 7c6cda00f8

View file

@ -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;