0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

optimised Resolver.solveVelocity

This commit is contained in:
liabru 2021-05-02 23:06:50 +01:00
parent e4b3bcd69e
commit 30b899c862

View file

@ -290,7 +290,7 @@ var Bounds = require('../geometry/Bounds');
// coulomb friction // coulomb friction
var normalOverlap = pair.separation + normalVelocity; var normalOverlap = pair.separation + normalVelocity;
var normalForce = normalOverlap > 1 ? 1 : normalOverlap; var normalForce = Math.min(normalOverlap, 1);
normalForce = normalOverlap < 0 ? 0 : normalForce; normalForce = normalOverlap < 0 ? 0 : normalForce;
var frictionLimit = normalForce * friction; var frictionLimit = normalForce * friction;
@ -327,7 +327,7 @@ var Bounds = require('../geometry/Bounds');
// impulse constraint tends to 0 // impulse constraint tends to 0
var contactNormalImpulse = contact.normalImpulse; var contactNormalImpulse = contact.normalImpulse;
contact.normalImpulse += normalImpulse; contact.normalImpulse += normalImpulse;
contact.normalImpulse = contact.normalImpulse < 0 ? contact.normalImpulse : 0; contact.normalImpulse = Math.min(contact.normalImpulse, 0);
normalImpulse = contact.normalImpulse - contactNormalImpulse; normalImpulse = contact.normalImpulse - contactNormalImpulse;
} }