From 7c6cda00f88f2f22857a1c8c66ea4afeff84b33a Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 1 Sep 2019 16:57:16 +0100 Subject: [PATCH] added clamping to position resolver damping --- src/collision/Resolver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/collision/Resolver.js b/src/collision/Resolver.js index 4ebe999..c8cb873 100644 --- a/src/collision/Resolver.js +++ b/src/collision/Resolver.js @@ -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;