mirror of
https://github.com/liabru/matter-js.git
synced 2025-02-07 19:06:26 -05:00
added clamping to position resolver damping
This commit is contained in:
parent
fba5af2116
commit
7c6cda00f8
1 changed files with 2 additions and 2 deletions
|
@ -69,7 +69,7 @@ var Bounds = require('../geometry/Bounds');
|
||||||
bodyBtoAY,
|
bodyBtoAY,
|
||||||
positionImpulse,
|
positionImpulse,
|
||||||
timeScale = delta / Common._timeUnit,
|
timeScale = delta / Common._timeUnit,
|
||||||
impulseCoefficient = Resolver._positionDampen * timeScale;
|
damping = Common.clamp(Resolver._positionDampen * timeScale, 0, 1);
|
||||||
|
|
||||||
for (i = 0; i < bodies.length; i++) {
|
for (i = 0; i < bodies.length; i++) {
|
||||||
var body = bodies[i];
|
var body = bodies[i];
|
||||||
|
@ -103,7 +103,7 @@ var Bounds = require('../geometry/Bounds');
|
||||||
separation = normalX * bodyBtoAX + normalY * bodyBtoAY;
|
separation = normalX * bodyBtoAX + normalY * bodyBtoAY;
|
||||||
pair.separation = separation;
|
pair.separation = separation;
|
||||||
|
|
||||||
positionImpulse = (separation - pair.slop) * impulseCoefficient;
|
positionImpulse = (separation - pair.slop) * damping;
|
||||||
|
|
||||||
if (bodyA.isStatic || bodyB.isStatic)
|
if (bodyA.isStatic || bodyB.isStatic)
|
||||||
positionImpulse *= 2;
|
positionImpulse *= 2;
|
||||||
|
|
Loading…
Add table
Reference in a new issue