0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

changed friction impulse limiting approach

This commit is contained in:
liabru 2015-05-08 00:14:24 +01:00
parent d55c7003e9
commit de4784c492

View file

@ -279,10 +279,10 @@ var Resolver = {};
// modify impulses accounting for mass, inertia and offset // modify impulses accounting for mass, inertia and offset
var oAcN = Vector.cross(offsetA, normal), var oAcN = Vector.cross(offsetA, normal),
oBcN = Vector.cross(offsetB, 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; normalImpulse *= contactShare / denom;
tangentImpulse *= Math.min(share, 1); tangentImpulse *= contactShare / (1 + denom);
// handle high velocity and resting collisions separately // handle high velocity and resting collisions separately
if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) { if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) {