Skip to content

Commit de4784c

Browse files
committed
changed friction impulse limiting approach
1 parent d55c700 commit de4784c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/collision/Resolver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ var Resolver = {};
279279
// modify impulses accounting for mass, inertia and offset
280280
var oAcN = Vector.cross(offsetA, normal),
281281
oBcN = Vector.cross(offsetB, normal),
282-
share = contactShare / (bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN);
282+
denom = bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN;
283283

284-
normalImpulse *= share;
285-
tangentImpulse *= Math.min(share, 1);
284+
normalImpulse *= contactShare / denom;
285+
tangentImpulse *= contactShare / (1 + denom);
286286

287287
// handle high velocity and resting collisions separately
288288
if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) {

0 commit comments

Comments
 (0)