skip to content

How do speculative contacts stop fast bodies from tunnelling, and why can they cause ghost collisions?

level: seniorimportance: should knowfreq 40%

answer

  1. contacts before touching
  2. a positive gap the solver may close
  3. approach no faster than gap over step
  4. a plane from start-of-step features
  5. blocked by an edge it would miss

basics

~20 s

Speculative contacts are made for pairs still apart but able to meet this step; the solver lets each close its gap and no more, so fast bodies stop at the surface. Built from start-of-step features, they can block paths that miss.

solid answer

~50 s

Contact generation runs with a margin that grows with the pair's relative speed, so a pair still separated by a gap `d > 0` that it could close this step gets a contact anyway. In the velocity solver that contact's rule becomes 'approach along the normal no faster than `d / dt`' instead of 'no faster than zero': if the bodies would not close the gap, the clamped impulse stays zero and nothing happens; if they would, the impulse trims the approach so they arrive just touching at the end of the step. There is no time-of-impact search, and the contact is solved with every other contact, so it is cheap. The price is ghost collisions: the contact plane comes from the closest features at the start of the step and acts as if it were infinite, so a ball skimming just above a crate's top edge can be slowed in mid-air by that edge's plane.

go deeper

for a junior

Recall that speculative contacts are contacts created slightly before two bodies touch, so the solver can stop a fast body at the surface.

for a middle

Explain the positive gap, the rule that limits approach speed to the gap over the step, and why the impulse stays zero when the bodies would not meet.

for a senior

Diagnose ghost collisions, weak bounces and spinning-body misses from their symptoms, and trace each back to start-of-step features or margins.

for a principal

Decide where speculative contacts are the default and which bodies still need a precise time-of-impact method because ghost hits or misses would be visible.

## Let the solver see contacts before they happen Ordinary contact generation reports pairs that **overlap** at the sampled instant, and the solver's job is to stop them approaching further and push them apart. A fast body that has not reached the wall yet produces no contact, so nothing slows it, and by the next sample it may be through. **Speculative contacts** close that gap by reporting contacts for pairs that are still apart but **could** meet within the coming step, and by telling the solver exactly how much approach is allowed. ## How the constraint works 1. **Generate with a margin.** Bounds in the broad phase and the contact distance in the narrow phase are enlarged by roughly the distance the pair can close this step, relative speed times step length, plus a small constant. 2. **Record the gap.** For a pair still apart, the contact stores the closest points, a normal `n` pointing from A to B, and a **positive separation** `d`. 3. **Change the velocity rule.** Let `vn` be B's velocity relative to A along `n` at the contact point; negative means approaching. An ordinary contact requires `vn >= 0` once the bodies touch. A speculative contact requires only `vn >= -d / dt`: the bodies may approach, but only fast enough to close the gap by the end of the step. 4. **Clamp as usual.** The contact impulse may only push, never pull, so its accumulated value is clamped at zero or above. If the bodies are not going to close the gap, the rule is already satisfied, the impulse stays at zero, and the contact has no effect at all. 5. **Arrive just touching.** If they would close the gap, the impulse removes exactly the excess approach, and the bodies end the step at, or very near, contact. Next step it is an ordinary contact. ## Why the method is popular - **No time-of-impact search**: one extra contact per close pair, not an iterative root finder per fast body. - **No lost time**: bodies are not halted at an impact and do not forfeit the rest of the step. - **One solver for everything**: speculative and ordinary contacts are solved together, so a fast box landing on a stack interacts correctly with every other contact in the stack. - **Cheap to apply broadly**: many bodies can use it, not just a handful flagged as critical. ## Ghost collisions The weakness is in step 2. The contact is built from the **closest features at the start of the step**, and the solver treats the contact as a plane through those features that extends without limit. The real feature is finite. Take the reserved picture of a ball skimming just over a crate. The ball's centre moves horizontally a hair above the height that would make it touch the crate's top face, approaching the crate's top edge from the side. At the start of the step the closest feature is that edge, and the normal points diagonally from the edge toward the ball's centre. The ball's horizontal velocity has a component against that normal, so it counts as approaching, and if it could close the diagonal gap within the step, the solver removes the excess approach. The ball is slowed or nudged upward by a surface it would never have touched. That is a **ghost collision**: a response to a contact that the real path never makes. The symptoms are characteristic: - Fast objects hitch or bump as they pass close to edges and corners. - A projectile grazing a doorway slows down without visibly hitting anything. - Debris flying past a table's edge deflects slightly in mid-air. ## Other limits - **Restitution**: the solver trims the approach to `d / dt`, so at the start of the next step the recorded impact speed is below the real one, and a bounce computed from it is too weak or arrives a step late. Handling restitution properly needs the pre-trim speed to be remembered. - **Fast rotation**: a margin sized from linear speed alone misses a long body whose tips sweep fast; the margin must include angular speed times the body's radius. - **More pairs**: larger margins enlarge broad-phase bounds and create more contacts, which costs solver time in dense scenes. - **Wrong features**: in one step the body can reach a feature that was not closest at the start, so a very fast body can still pass a thin edge it was never given a contact for. | Aspect | Speculative contacts | Swept time of impact | |---|---|---| | Extra work per pair | one more contact in the solver | an iterative or analytic search | | Lost time at impact | none | yes, unless the rest of the step is re-simulated | | False hits | ghost collisions near edges and corners | rare | | Missed hits | possible when features change mid-step | rare for flagged bodies | | Restitution | needs special handling | natural at the impact time | The usual result is a mix: speculative contacts as the broad, cheap default, and a precise time-of-impact method reserved for the few bodies where a ghost hit or a miss would be noticed.

  • Why does a fast ball bounce too weakly off a wall when speculative contacts handle the impact?
    The solver trims the ball's approach so it only closes the gap, so the ball arrives at the wall still moving at `d / dt` toward it, not at its real speed. Next step the contact is ordinary, and restitution is computed from that reduced approach speed, giving a weak bounce. Fixes remember the pre-trim approach speed or treat bouncy contacts with a time-of-impact method.
  • How can ghost collisions be reduced without giving up speculative contacts?
    Keep margins as small as each pair's real closing distance allows instead of one large fixed margin, check that the motion actually reaches the finite feature rather than its infinite plane before keeping the contact, and route the few bodies where a ghost hit would be noticed to a precise time-of-impact method.
  • Does a speculative contact protect a long, thin body that is spinning very fast?
    Only if the margin accounts for rotation. A margin sized from linear speed misses tips that sweep at angular speed times their distance from the centre, so the contacts are not generated in time. Including that angular term in the margin, or using a time-of-impact method that models rotation, closes the hole.

  • Speculative contacts push bodies apart before they touch.
  • A speculative contact always applies an impulse to its pair.
  • Speculative contacts compute an exact time of impact for each pair.
  • Ghost collisions are bodies that passed through a wall.
  • Speculative contacts handle restitution exactly like ordinary contacts.