Why can Baumgarte stabilisation make stacked crates pop apart or a ball bounce too high, and how do split impulses avoid it?
answer
- velocity solvers let positions drift
- penetration fed back as velocity
- the bias velocity survives
- pseudo-velocity, then discard
basics
~20 sBaumgarte feeds penetration back as extra separating velocity, and that velocity stays in the bodies after the overlap is gone, adding energy. Split impulses solve the correction in a separate pseudo-velocity that moves positions and is then discarded.
solid answer
~40 sA velocity-level solver never fixes positions, so overlap and joint drift accumulate. **Baumgarte** adds a bias to the contact's target separating velocity, `bias = (beta / h) * max(d - slop, 0)`, closing about a fraction `beta` of the penetration per step. That bias impulse is real momentum: once the overlap closes, the bodies keep moving apart, so a deeply overlapped crate launches, stacks jitter and a ball that sank into the floor can rebound above its restitution; lowering `beta` instead lets stacks sink. **Split impulses** solve the bias with the same Jacobians but on a second set of pseudo-velocities, use them only to move positions in this step, then zero them. The overlap still closes, but no separating speed carries into the next step, at the price of a second iteration loop.
go deeper
Recall that a velocity solver lets bodies stay slightly overlapped and that something must push them apart, either through velocity or a separate position fix.
Explain the Baumgarte bias formula, the role of slop, and why the factor beta trades sinking against popping.
Diagnose popping, sinking and over-bouncing from the symptom, and explain why split impulses remove the correction's energy while still closing overlap.
Weigh the cost of a second velocity loop or a position-projection pass against the artefacts the game tolerates, such as spawning overlaps, ragdolls and tall stacks.
## Why a velocity solver drifts A sequential-impulse solver works on **velocities**: it makes contacts stop approaching and joints stop pulling apart. It never looks at positions directly, so position errors survive and accumulate: - bodies that were already overlapping when the step began stay overlapping, because a zero approach speed holds them where they are; - the integrator moves bodies along straight lines while constraints are curved, so joint anchors drift a little each step; - an unconverged solve leaves small approach speeds, which become new overlap after integration. Something has to push the positions back. The two classic answers are **Baumgarte stabilisation** and **split impulses**; a third is a separate position-projection pass. ## Baumgarte: penetration as a velocity bias Baumgarte stabilisation folds the position error into the velocity target. For a contact with penetration depth `d` (positive when overlapping) and step length `h`: 1. Subtract a small allowance, often called **slop**, so a resting contact keeps a sliver of overlap and stays in contact. 2. Compute a bias: `bias = (beta / h) * max(d - slop, 0)`, with `beta` between 0 and 1. 3. Ask the solver for a separating normal velocity of at least `bias` instead of zero. With that velocity, the step closes roughly a fraction `beta` of the excess penetration. The same idea works for joints: the bias is `beta / h` times the joint's position error. ## Where the extra energy comes from The bias impulse is **real momentum**. Once the overlap has closed, the bodies keep the separating velocity the bias gave them. Consider a scenario's figures: a crate spawned 0.5 m deep inside another, `beta = 0.2`, a step of 1/60 s, slop ignored. - The first step's bias is `0.2 * 0.5 * 60 = 6 m/s`. - That speed carries the crate out of the overlap in a few steps; gravity has only taken a little off by then. - It leaves at roughly 5 m/s, enough to fly more than a metre into the air. The same mechanism shows up subtly everywhere: - in a solver that adds the bias to the bounce target, a fast ball that sinks deep into the floor during one long step rebounds higher than its restitution says; - in a stack, each correction overshoots slightly, the crate lifts, falls back and overlaps again: **jitter**; - turning `beta` down stops the popping but leaves overlap uncorrected, so the stack **sinks**. `beta` is a compromise between those two failure modes, which is why one value rarely satisfies both stacks and fast impacts. ## Split impulses **Split impulses** keep the correction but throw away its momentum. Each body gets a second, temporary pair of **pseudo-velocities**: 1. Solve the contacts for real velocities with a bias of zero (plus restitution), exactly as before. 2. Solve them again with the same Jacobians and effective masses, but on the pseudo-velocities, targeting the Baumgarte bias. 3. Integrate positions using the real velocity plus the pseudo-velocity. 4. Discard the pseudo-velocities. The overlap still closes over a few steps, but no separating speed survives into the next step, so crates do not launch and balls bounce as their restitution says. The cost is a second iteration loop over the contacts. ## Comparing the position fixes | method | how positions are fixed | energy added | cost | |---|---|---|---| | Baumgarte | bias in the real velocity target | yes, proportional to `beta` and depth | lowest | | split impulses | bias in pseudo-velocities, then discarded | none from the correction | a second velocity loop | | position projection | iterate directly on positions after integration, using the current geometry | none | recomputes contact geometry, highest of the three | Position projection, often described as **nonlinear Gauss-Seidel**, handles large joint errors best because it recomputes the constraint at the new positions each iteration. ## Reading the symptom - Bodies pop apart or launch after an overlap: Baumgarte energy; lower `beta` or move to split impulses. - Stacks slowly sink or joints sag: too little position correction, or a velocity solve that has not converged. - A ball bounces higher than its restitution: the bias is being added on top of the bounce target. - Resting contacts tremble with no visible overlap: slop of zero, so contacts break and re-form every step. Knowing which of the two problems you have, energy or drift, tells you which way to turn the correction.
- Why do solvers leave a small slop of allowed penetration instead of driving overlap to zero?With zero slop, the bias pushes a resting contact all the way to just touching; on the next step the shapes may no longer overlap, the contact can be dropped, gravity brings it back and it re-forms, so the stack trembles. A small allowed overlap keeps the contact alive and stable; the bias only acts on penetration beyond it.
- Why do joints often need position projection rather than Baumgarte alone?A joint error can be large after a violent hit, and Baumgarte would turn it into a large velocity, flinging the linked bodies. Position projection iterates on positions directly and recomputes the joint's geometry at each iteration, so it removes big separations without injecting momentum, at a higher cost.
- Baumgarte stabilisation removes overlap without changing the bodies' kinetic energy.
- Setting the Baumgarte factor to 1 removes all drift with no side effects.
- Split impulses keep the correction velocity for the next step's warm start.
- A velocity-level solver also fixes penetration that existed before the step.
- Popping crates are best fixed by setting restitution to zero.