Game Physics: Stability – Slops

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.

Penetration Slop

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:

    \[ -\frac{\beta}{\Delta t} \cdot d,  \]

where d is the penetration depth.

If we allow a penetration slop, denoted Slop_P (I usually use a value around 0.5mm), then the Baumgarte term becomes:

    \[ -\frac{\beta}{\Delta t} \cdot max(d - Slop_P, 0)  \]

The Baumgarte term can reduce to zero if the penetration depth is less than the penetration slop.

Restitution 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:

    \[ C_R \, V_C,  \]

where V_C is the closing speed:

    \[ V_C = (-\overrightarrow{V_A} - \overrightarrow{\omega_A} \times \overrightarrow{r_A} + \overrightarrow{V_B} + \overrightarrow{\omega_B} \times \overrightarrow{r_B}) \cdot \overrightarrow{n} \]

If we allow a restitution slop as a tolerance of the closing speed, denoted Slop_R (I usually use a value around 0.5 m/s), then the restitution term becomes:

    \[ C_R \, max(V_C - Slop_R, 0) \]

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.

About Allen Chou

Physics / Graphics / Procedural Animation / Visuals
This entry was posted in Gamedev, Physics. Bookmark the permalink.

One Response to Game Physics: Stability – Slops

  1. CyrusFiredawn says:

    Awesome! Keep it up, this is really helping me <3

Leave a Reply