This post is part of my Game Physics Series.
I previously hinted that there will be stability issues as I covered collision resolution. It is because the logic for collision resolution presented earlier is sort of “naive” in a sense that it tries to perfectly resolve all “conflicts”. Nothing is perfect. If you try to perfectly simulate a stack of boxes, you get jitters. This is when the concept of “slop” is introduced, where we become more forgiving to errors and give everything a little bit of leeway.
As mentioned in the previous post, Baumgarte Stabilization is a technique for correcting positional errors by applying just enough impulse to push penetrating colliders apart. Without slop, if two colliders are just penetrating by a teeny bit, extra impulse is applied. This would result in unnecessary jitter and objects will hardly sit tight when they are supposed to be at rest.
The condition can be greatly improved if we allow objects to penetrate a bit before actually applying Baumgarte Stabiliation. Recall that the Baumgarte term within the bias term of the contact constraint equation is:
where is the penetration depth.
If we allow a penetration slop, denoted (I usually use a value around 0.5mm), then the Baumgarte term becomes:
The Baumgarte term can reduce to zero if the penetration depth is less than the penetration slop.
Another place we can apply the concept of slop is restitution. With a coefficient of restitution of 0.3 between a bouncing ball and the static floor, it is going to take forever for the ball to settle on the floor if no extra care is taken. Because even when the ball is already bouncing very low, it still always gets a non-zero impulse pushing it back upwards as it hits the floor.
With restitution slop, we take away just a little bit of energy every time a collision occur, so that the bouncing ball would eventually settle on the floor, completely at rest.
Recall the restitution term within the bias term of the contact constraint equation is:
where is the closing speed:
If we allow a restitution slop as a tolerance of the closing speed, denoted (I usually use a value around 0.5 m/s), then the restitution term becomes:
The restitution term can reduce to zero if the closing speed of two incident objects is less than the restitution slop.
End of Slops
Here I presented two places in a physics engine where slops can be easily applied to effectively improve the simulation’s stability. I will introduce another technique called “warm starting” in later posts that is also commonly used to improve stability.