From de4784c4923777fd9d61583305f06580a7792ae5 Mon Sep 17 00:00:00 2001 From: liabru Date: Fri, 8 May 2015 00:14:24 +0100 Subject: [PATCH] changed friction impulse limiting approach --- src/collision/Resolver.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/collision/Resolver.js b/src/collision/Resolver.js index 42864c3..6ee5b1c 100644 --- a/src/collision/Resolver.js +++ b/src/collision/Resolver.js @@ -279,10 +279,10 @@ var Resolver = {}; // modify impulses accounting for mass, inertia and offset var oAcN = Vector.cross(offsetA, normal), oBcN = Vector.cross(offsetB, normal), - share = contactShare / (bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN); + denom = bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN; - normalImpulse *= share; - tangentImpulse *= Math.min(share, 1); + normalImpulse *= contactShare / denom; + tangentImpulse *= contactShare / (1 + denom); // handle high velocity and resting collisions separately if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) {