skip to content

Continuous Collision Detection

Why fast or thin bodies tunnel under discrete steps and how swept tests, conservative advancement and speculative contacts catch the time of impact. Interviewers pose tunnelling as a diagnosis task.

on this pageshow

explore

questions

5

What is tunnelling in discrete collision detection, and when does a fast projectile pass straight through a thin wall?

level: middleimportance: must knowfreq 62%

answer

  1. sampling, not sweeping
  2. positions checked only at step ends
  3. distance per step against thickness
  4. overlap window: wall plus body extent

basics

~20 s

Tunnelling is a fast body skipping through an obstacle because discrete detection only tests positions at each step's end. When distance per step exceeds the wall's thickness plus the body's extent along its motion, no sampled position may overlap.

solid answer

~50 s

Discrete collision detection samples the world: it moves each body to its end-of-step pose and only then asks what overlaps. A body at speed `v` with step `dt` jumps `v*dt` between samples, and it can only be caught while it sits inside an overlap window as long as the wall's thickness plus the body's own extent along the motion. Once `v*dt` exceeds that window, catching it is luck: a 300 m/s projectile with a 0.02 m radius on a 1/60 s step moves 5 m per step, so a 0.2 m wall catches it about 4.8% of the time (0.24 / 5). A milder form starts earlier: an overlap caught past the wall's middle can be pushed out of the far side. Slow, large bodies against thick walls never notice; fast, small bodies against thin walls do.

go deeper

for a junior

Recall that discrete detection only looks at positions at the end of each step, so a fast enough body can skip a thin obstacle entirely.

for a middle

Explain the overlap window, wall thickness plus the body's extent along its motion, compare it with distance per step, and show the arithmetic for a concrete projectile.

for a senior

Diagnose a report from logged speed and step length, separate full tunnelling from deep overlaps resolved out the far side, and include rotation and single-sided geometry in the check.

for a principal

Turn the tunnelling condition into content and runtime policy: minimum collider thickness, the longest step the game may run, and which bodies need a continuous remedy at all.

## What discrete collision detection actually checks Most physics simulations advance in **steps**. Each step integrates every body's velocity into a new position, then runs collision detection on the new poses: a **broad phase** shortlists pairs whose bounds overlap, a **narrow phase** measures how deeply each surviving pair interpenetrates, and a solver pushes the pair apart. This is **discrete collision detection**: it looks at the world only at the sampled instants and never at the path between them. **Tunnelling** is what happens when the interesting moment falls between two samples. A projectile is in front of a wall at one step and behind it at the next; at neither sampled position does it overlap the wall, so no pair is ever reported and nothing stops it. Nothing in the pipeline is broken: it was simply never asked about the path. ## The overlap window and the tunnelling condition Picture a sphere of radius `r` flying straight at a wall of thickness `w`. Its centre overlaps the wall's volume for as long as it lies inside a slab of thickness `w + 2r`: from the moment its front touches the near face until its back leaves the far face. Call that the **overlap window** `L`. Between samples the centre moves `s = v*dt`. 1. If `s <= L`, at least one sample must land inside the window, so the overlap is always caught. 2. If `s > L`, whether a sample lands inside depends on the step's phase relative to the wall. With an arbitrary phase, the chance of a catch is `L / s`. 3. Even when a sample lands inside, the overlap may be deep. If the centre has already passed the wall's middle (a depth greater than `r + w/2`), a narrow phase that resolves along the shortest way out pushes the sphere out of the **far** side. This partial tunnelling starts at speeds well below the full-tunnelling threshold. For a body that is not a sphere, `2r` becomes the body's extent along its direction of motion. A long plank flying end-first has a large window; the same plank flying broadside has a window only as large as its thickness. ## A worked example: the projectile and the wall Take the scenario's figures: a projectile of radius 0.02 m, a wall 0.2 m thick, and a fixed step of 1/60 s. The window is `0.2 + 2*0.02 = 0.24` m. | Speed | Travel per step | Chance the overlap is caught | |---|---|---| | 5 m/s | 0.083 m | always, and never deeper than the wall's middle (0.12 m) | | 30 m/s | 0.5 m | 0.24 / 0.5 = 48%, and about half of those catches are past the middle | | 300 m/s | 5 m | 0.24 / 5 = 4.8% | The 30 m/s row is the instructive one: the wall catches the projectile about half the time, and about half of those catches land deeper than 0.12 m, so only about a quarter of shots stop on the correct side if resolution goes the shortest way out. ## Which bodies tunnel - **Fast bodies**: projectiles, vehicles at top speed, debris thrown by an explosion. - **Small bodies**: the window shrinks with the body's own extent, so pebbles tunnel before boulders. - **Thin geometry**: fences, glass panes, and especially single-sided triangle meshes, which have no volume at all and therefore no inside to catch the body in. - **Long steps**: anything that lengthens `dt`, such as a step that stretches with a slow frame, raises `s` for every body at once. - **Fast rotation**: a spinning plank's tips move at angular speed times their distance from the centre, so a body whose centre is slow can still sweep its ends through a wall. ## Diagnosing a tunnelling report 1. Log the body's speed and the step length at the moment it escaped and compute `v*dt`. 2. Compare it with the window: the body's extent along the motion plus the thickness of the geometry it crossed. 3. Check whether the crossed geometry is a closed volume or a single-sided surface. 4. Halve the step as an experiment. If the escape disappears, the cause is sampling, not a missing collider or a wrong collision filter. ## The remedies, in one line each - **Thicker or closed collision geometry**: costs nothing at runtime and widens the window. - **Swept tests**: solve for the time of impact along the straight path between samples. - **Conservative advancement**: step time forward by safe amounts until the bodies meet, which also handles rotation. - **Speculative contacts**: let the solver see a contact before the bodies touch and limit the approach to the gap. - **Substeps**: shrink `dt` for the whole simulation, paying for every body, not only the fast ones. Each costs something different, and choosing among them per body is a judgment of its own.

  • Why can a body whose overlap was detected still end up on the wrong side of a thin wall?
    Detection happened, but deep. If the sample landed after the body's centre passed the wall's middle, the shortest way out of the overlap is through the far face, and a resolver that separates along the minimum penetration direction pushes the body onward. That is why tunnelling starts at speeds below the full threshold: the safe travel per step is about the body's half-extent plus half the wall, not the whole window.
  • Does a low frame rate make tunnelling worse if physics runs on a fixed step?
    Not by itself. With a fixed step, distance per step depends only on speed and step length, so the render rate does not change it. A low frame rate matters when the step stretches with the frame, or when the loop clamps how many steps it runs and lets simulated time fall behind instead. The condition to check is always `v*dt` against the overlap window.
  • Can a body whose centre barely moves still tunnel?
    Yes, through rotation. A thin plank spinning at angular speed `w` moves its tips at `w*r`, where `r` is the tip's distance from the centre, so its ends can sweep through a wall between samples even though its centre is almost still. Any tunnelling check that looks only at linear velocity misses this case.

A strobe light photographing a sprinter crossing a painted line: if the flashes are far enough apart, no photo shows a foot on the line, even though the sprinter certainly crossed it.

  • Tunnelling only happens when the frame rate drops.
  • Collision detection checks the whole path a body travels during a step.
  • Only the body's speed matters, not its size or the wall's thickness.
  • Any detected overlap is pushed back out the side the body came from.
  • A more detailed render mesh for the wall stops projectiles passing through.
open as a page

How do you compute the time of impact of two moving spheres within one physics step?

level: middleimportance: should knowfreq 45%

basics

~20 s

Subtract one sphere's motion from the other's so one stands still, then solve |s + d*t| = rA + rB for the step fraction t. The smaller root of that quadratic, if it lies in [0, 1], is the time of impact.

open as a page

How does conservative advancement find the time of impact of two rotating convex bodies, and when does it converge slowly?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Conservative advancement repeatedly divides the bodies' closest distance by an upper bound on their approach speed and advances time by that safe amount, never passing contact. It crawls when the bound is loose, as with fast spin near a surface.

open as a page

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

level: seniorimportance: should knowfreq 40%

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.

open as a page

Which bodies in a racing game should get continuous collision detection, and how do you weigh it against substeps and thicker colliders?

level: principalimportance: should knowfreq 35%

basics

~20 s

Give continuous collision only to bodies that move farther per step than their size plus the thinnest geometry they meet, and whose escape would break the game, like cars against barriers. Thicken thin content first; substep only if everything needs it.

open as a page