Jitter fix

If you have issues with objects never coming to rest, like balls bouncing endlessly with high gravity, try this fix:

In b2ContactSolver.as
replace the lines:

Code:
if (vRel > -b2Settings.b2_velocityThreshold)
{
    ccp.velocityBias += -cc.restitution * vRel;
}


with:

Code:
var restEffect:Number = -cc.restitution * vRel;
if(restEffect>0)
{
    if (vRel > -b2Settings.b2_velocityThreshold) restEffect *= vRel / -b2Settings.b2_velocityThreshold;
    ccp.velocityBias += restEffect;
}

Then, increase b2Settings.b2_velocityThreshold, keep it as low as possible while still solving the jitter issue. 6 works well for me.

This makes the inelastic collision threshold a slope rather than a cutoff. I have high gravity and restitutions near 1 without jitter. There may be some side effects I'm not thinking of though.
Also, a parabolic curve might even work better - I'll let someone else figure that out.

Original thread: https://box2d.org/forum/viewtopic.php?t=5835