skip to content

Game Physics & Collision

Rigid-body dynamics, stable integration, collision detection, contact solvers and particle-based cloth. Interviewers probe it because physics bugs are everyday gameplay bugs.

on this pageshow

explore

questions

page 1 of 2

What problem does the broad phase of collision detection solve, and why do bounding volumes make it cheap?

level: juniorimportance: must knowfreq 70%

answer

  1. count the pairs first
  2. n(n-1)/2 grows quadratically
  3. conservative cheap rejection
  4. sphere, AABB, OBB: fit vs cost
  5. false positive cheap, miss fatal

basics

~10 s

The broad phase cheaply shortlists pairs of bodies whose simple bounding volumes overlap, so the expensive exact shape test runs only on those candidates instead of on all n(n-1)/2 pairs every physics step.

solid answer

~40 s

Testing every pair is quadratic: 5,000 debris pieces make 12,497,500 pairs per step. The broad phase wraps each body in a simple **bounding volume** that fully contains its shape (an axis-aligned box, a sphere or an oriented box) and organises those volumes with sweep-and-prune, a grid or a dynamic AABB tree, so most far-apart pairs are never even visited. Its output is a **conservative** candidate list: a false positive costs one wasted narrow-phase test, but a missed pair means two bodies pass through each other. Axis-aligned boxes dominate because their overlap test is two comparisons per axis and they sort, bucket and nest easily; spheres ignore rotation but fit long objects badly; oriented boxes fit tightly but cost far more to test.

go deeper

for a junior

Recall the quadratic pair count, that the broad phase shortlists candidates with simple bounding volumes, and that the narrow phase then does the exact test.

for a middle

Explain why the shortlist must be conservative, how a rotating body's AABB is refreshed, and why axis-aligned boxes beat spheres and oriented boxes for this job.

for a senior

Show you know where the broad phase stops helping: truly overlapping heaps, oversized static boxes, and filtering that should reject pairs before any narrow-phase cost.

for a principal

Frame the broad phase as a budget line: how bounding-volume looseness, collision-group design and the chosen structure trade CPU against false candidates across a whole game.

## Why testing every pair is too many A physics world with `n` bodies has `n(n-1)/2` distinct pairs. For 100 bodies that is 4,950 pairs, which is harmless. For a destruction scene where a wall has just shattered into 5,000 debris pieces it is 12,497,500 pairs, every physics step. If each exact shape test took a quarter of a microsecond, that alone would be about three seconds of work per step. Yet almost all of those pairs are far apart: a chunk of rubble at one end of the level cannot touch one at the other end. The **broad phase** exists to skip those pairs without examining them one by one, and to hand the **narrow phase** (the exact, expensive shape-versus-shape test) a short list of **candidate pairs**. ## Bounding volumes: a cheap, conservative stand-in Each body is wrapped in a simple **bounding volume** that fully contains its collision shape. If two bounding volumes do not overlap, the shapes inside cannot touch, so the pair is rejected. If they do overlap, the shapes might touch, and the pair goes on. Three properties follow: - **False positives are acceptable.** A pair whose volumes overlap but whose shapes do not costs one wasted narrow-phase test. - **False negatives are bugs.** A pair the broad phase drops never reaches the narrow phase, so no contact is generated and the bodies pass through each other. - **Static-static pairs are skipped.** Two pieces of level geometry that never move never need a contact, so broad phases normally do not consider them at all. | Volume | Overlap test | Fit | Cost when the body rotates | |---|---|---|---| | Sphere | squared centre distance against the squared sum of radii | loose for long or flat shapes | none: a sphere is rotation-invariant | | Axis-aligned box (AABB) | two comparisons per axis, with early exit | good for axis-aligned shapes, looser as they rotate | must be recomputed for the new orientation | | Oriented box (OBB) | a separating-axis test over many candidate axes | tight for box-like shapes | rotates with the body, no refit | Axis-aligned boxes win in most broad phases. Their test is tiny, and boxes that share the same axes can be sorted along an axis, dropped into grid cells and nested inside one another in a tree, which are the three families of broad-phase structure. Spheres appear where bodies are roughly round or as an extra quick rejection. Oriented boxes are more at home inside the narrow phase than in front of it. ## Keeping the bounds current An AABB lives in world space, so it changes whenever its body moves or rotates. Common ways to refresh it: 1. **Rotate the local box's extents.** With column vectors and a rotation matrix `R` that maps body space to world space, a local box with half-extents `h` has world half-extents `abs(R) * h`, where `abs(R)` replaces every entry by its absolute value, centred on the transformed local centre. It is cheap and conservative, but looser than the shape. 2. **Ask the shape.** A sphere or capsule yields an exact box in a few operations; a convex hull can scan its vertices, which is exact but costs a pass over them. 3. **Enlarge it.** Many broad phases pad the box with a margin, or stretch it along the body's motion, so it stays valid for several steps. These are the "fat" bounds used by dynamic AABB trees. ## The structures that avoid visiting every pair Testing every pair of AABBs is still quadratic, just with a cheaper test. The real saving comes from organising the boxes so that far-apart pairs are never examined: - **Sweep-and-prune** sorts box endpoints along an axis and pairs only boxes whose intervals overlap. - **Uniform grids and spatial hashes** bucket boxes by cell, so only bodies sharing a cell are paired. - **Dynamic AABB trees** nest boxes in a hierarchy, so a query descends only into branches whose boxes overlap it. On well-spread scenes each brings the cost down to roughly linear or `n log n` in the number of bodies, plus the number of pairs reported. None of them can report fewer pairs than truly overlap: a heap of debris whose boxes overlap many neighbours stays expensive whichever structure holds it. ## What the broad phase hands on The output is a list, or a persistent set, of candidate pairs, often already filtered by collision groups so that, for example, small debris never pairs with other small debris. The narrow phase runs the exact test on each survivor and builds contact points for the solver. Keeping that list short, without ever dropping a real pair, is the broad phase's whole job.

  • Why not use the tightest possible bounding volume, such as the convex hull itself?
    The broad phase runs its test on many more pairs than the narrow phase, so its test must be nearly free, and its volumes must sort, bucket or nest cleanly. A convex hull test costs about as much as the narrow phase it is meant to avoid. A slightly loose box that sends a few extra pairs on is cheaper overall than an exact volume tested everywhere.
  • How does the broad phase handle a rotating body whose AABB keeps changing shape?
    It recomputes the world AABB each step from the shape and its orientation: for a box-like bound, the world half-extents are the absolute-valued rotation matrix times the local half-extents. Many broad phases also enlarge the box by a margin so small changes do not force a structure update every step; the box stays conservative, just looser.
  • Where should collision-group filtering happen relative to the broad phase?
    As early as possible: either inside the broad phase, rejecting a pair before it is stored, or immediately after it, before any narrow-phase work. A pair the game never wants to collide, such as debris against debris, should never cost a cached entry or an exact shape test.

Before asking whether two guests at a huge conference have met, you only compare people standing in the same room: two guests in different rooms certainly are not talking, and two in the same room still need a closer look.

  • Says the broad phase decides whether two bodies actually touch.
  • Thinks occasional missed pairs are fine because the solver corrects penetration later.
  • Believes an AABB stays valid when its body rotates.
  • Claims testing every pair of AABBs is fine because the AABB test is cheap.
  • Confuses broad-phase pair pruning with frustum culling for rendering.
open as a page

When two rigid bodies collide in a game physics simulation, what do the coefficient of restitution and the coefficient of friction each control?

level: juniorimportance: must knowfreq 55%

basics

~20 s

Restitution sets how much approach speed along the contact normal returns as separation speed: 0 is no bounce, 1 a perfectly elastic one. Friction resists sliding in the tangent plane, capped at the coefficient times the normal impulse.

open as a page

In narrow-phase collision, what does a contact test return for two overlapping spheres, and how does a capsule reuse that test?

level: juniorimportance: must knowfreq 55%

basics

~20 s

A narrow-phase test returns a unit contact normal, a penetration depth and contact points, not just yes or no. Spheres get all three from the centre-to-centre vector; a capsule finds the closest point on its core segment, then reuses the sphere test.

open as a page

In game physics, how do a raycast, a shape cast and an overlap query differ, and when would you choose each one?

level: juniorimportance: must knowfreq 62%

basics

~20 s

A raycast traces a thin line and reports hits along it; a shape cast sweeps a sphere, capsule or box along a path and reports where it first touches; an overlap query lists what intersects a stationary shape.

open as a page

How do static, kinematic and dynamic rigid bodies differ, and which type should an animated sliding door use?

level: juniorimportance: must knowfreq 65%

basics

~20 s

Static bodies never move; kinematic bodies are moved by game code or animation with infinite mass, pushing others but never pushed back; dynamic bodies have finite mass and are moved by the simulation. An animated sliding door should be kinematic.

open as a page

In a rigid-body simulation, what is the difference between applying a force and applying an impulse, and when do you use each?

level: juniorimportance: must knowfreq 70%

basics

~20 s

A force is a rate of momentum change, multiplied by the step length, so it suits continuous pushes like thrust. An impulse is the momentum change itself, applied at once (velocity jumps by J/m), so it suits instant events like explosions.

open as a page

How does sweep-and-prune find candidate collision pairs, and why does frame-to-frame coherence make it fast?

level: middleimportance: must knowfreq 55%

basics

~10 s

Sweep-and-prune projects each body's AABB onto an axis, keeps the interval endpoints sorted and sweeps them, pairing overlapping intervals. Bodies move little per step, so last step's order needs only a few insertion-sort swaps.

open as a page

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

level: middleimportance: must knowfreq 62%

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.

open as a page

How do you derive the normal impulse that resolves a collision between two rotating rigid bodies at a single contact point?

level: middleimportance: must knowfreq 50%

basics

~20 s

Require the relative normal velocity of the two contact points to become -e times its old value and solve for one scalar impulse: j = -(1 + e) * vn / K, with K the inverse effective mass including rotation.

open as a page

What are the stages of one position-based dynamics (PBD) step for cloth particles, and how are velocities obtained afterwards?

level: middleimportance: must knowfreq 32%

basics

~10 s

PBD predicts each particle's position from its velocity and external forces, repeatedly projects those predicted positions onto the constraints, then sets each velocity to the position change divided by the step length.

open as a page

How do sleeping and simulation islands work in physics middleware, and why might toppled furniture keep costing CPU after it stops?

level: middleimportance: must knowfreq 48%

basics

~20 s

Middleware groups dynamic bodies linked by contacts or joints into islands and sleeps a whole island once every body has stayed below a speed threshold for a set time. One jittering or repeatedly woken body keeps its island simulated.

open as a page

What is the difference between explicit Euler and semi-implicit (symplectic) Euler integration, and why does the update order decide whether an orbit stays closed?

level: middleimportance: must knowfreq 65%

basics

~20 s

Explicit Euler moves position with the old velocity; semi-implicit Euler updates velocity first and moves position with the new one. Same cost and order, but the semi-implicit form keeps spring and orbit energy bounded instead of growing every step.

open as a page

What does the separating axis theorem say, and which candidate axes must a collision test check for two oriented boxes in 3D?

level: middleimportance: must knowfreq 60%

basics

~20 s

Two convex shapes are disjoint exactly when some axis separates their projections. For two oriented boxes in 3D, testing 15 axes is enough: the 3 face normals of each box and the 9 cross products of one box's edge directions with the other's.

open as a page

How does a kinematic character controller's collide-and-slide loop work, and how should it treat walkable slopes differently from steep walls?

level: middleimportance: must knowfreq 60%

basics

~20 s

Each step the controller sweeps its capsule along the desired move, stops just short of the first hit, removes the part of the remaining motion that pushes into the surface and repeats; the slope angle decides whether a surface is ground or wall.

open as a page

Why does a PBD cloth's stiffness change with the solver iteration count and step length, and how does XPBD compliance fix it?

level: seniorimportance: must knowfreq 28%

basics

~20 s

PBD has no physical stiffness: softness is whatever the solve leaves unconverged, so more iterations or shorter steps make cloth stiffer. XPBD adds compliance and a per-constraint Lagrange multiplier, so the requested stiffness becomes a material property.

open as a page

A stiff spring rope is stable at a fixed 1/120 s physics step but explodes at 1/60 s; what causes it, and how do substeps fix it?

level: seniorimportance: must knowfreq 55%

basics

~20 s

The integrator crossed its stability limit: semi-implicit Euler stays bounded only while the fastest mode's angular frequency times the step is below 2. Substeps integrate several shorter steps per physics step, raising the limit proportionally at proportional cost.

open as a page

How is a rope or a cloth sheet represented as particles and constraints in a position-based physics simulation?

level: juniorimportance: should knowfreq 30%

basics

~20 s

A rope or cloth is a set of point-mass particles joined by constraints: distance constraints along chain or grid edges, diagonals against shear, and longer-reach or angle constraints against bending; pinned particles get zero inverse mass.

open as a page

Why does physics middleware expect a world built in metres and kilograms, and what goes wrong when a game uses another scale?

level: juniorimportance: should knowfreq 42%

basics

~20 s

Middleware tunes gravity, contact tolerances and sleep thresholds as absolute numbers in metres, kilograms and seconds. At another scale those numbers are off by the scale factor: objects fall too slowly, or jitter and never rest.

open as a page

In game physics, how does a trigger volume differ from a solid collider, and how do layer masks decide what collides or gets queried?

level: juniorimportance: should knowfreq 55%

basics

~20 s

A solid collider takes part in contact resolution, so bodies push against it; a trigger only detects overlap and reports enter and exit events. Layer masks filter which collider pairs are tested and which colliders a query may hit.

open as a page

In a uniform grid or spatial hash broad phase, how do you choose the cell size, and what goes wrong at either extreme?

level: middleimportance: should knowfreq 50%

basics

~10 s

Size grid cells near the largest common moving body so each body touches only a few cells. Too small, and bodies span many cells; too large, and crowded cells bring back the pairwise cost.

open as a page

Why does a physics broad phase keep a persistent pair cache, and how does it report pairs that begin and end overlapping?

level: middleimportance: should knowfreq 42%

basics

~20 s

A persistent pair cache remembers last step's candidate pairs, so only bodies that moved need new queries, and comparing old and new pairs yields begin and end events that create and destroy the narrow phase's per-pair contact data.

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 is a hinge joint, such as a door on its frame, expressed as constraints and solved by an impulse-based rigid-body solver?

level: middleimportance: should knowfreq 40%

basics

~20 s

A hinge pins a door point to a frame point (three equations) and keeps their hinge axes aligned (two more), leaving one rotation. The solver applies unclamped impulses zeroing each constraint's velocity error; limits and motors add clamped rows.

open as a page

How do you integrate a rigid body's orientation quaternion from its angular velocity over one physics step, and why must you renormalise it?

level: middleimportance: should knowfreq 45%

basics

~20 s

Treat world-space angular velocity as a pure quaternion, add 0.5*dt*(0, ω)*q to the orientation, then normalise. The additive step lengthens the quaternion, and a non-unit quaternion becomes a matrix that scales and skews the body.

open as a page

What happens to a rigid body's linear and angular motion when a force is applied away from its centre of mass?

level: middleimportance: should knowfreq 55%

basics

~20 s

The centre of mass accelerates by F/m exactly as if the force went through it, and the force also produces a torque r × F, with r running from the centre of mass to the point of application, which spins the body.

open as a page

How does a dynamic AABB tree with fat bounds keep broad-phase updates cheap when thousands of debris pieces move beside a static level?

level: seniorimportance: should knowfreq 45%

basics

~20 s

A dynamic AABB tree stores each body as a leaf with an enlarged (fat) box, removes and reinserts it only when its tight box escapes, and keeps the static level in a separate tree that never queries itself.

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

Why can Baumgarte stabilisation make stacked crates pop apart or a ball bounce too high, and how do split impulses avoid it?

level: seniorimportance: should knowfreq 36%

basics

~20 s

Baumgarte 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.

open as a page

In a sequential-impulse solver, why do accumulated-impulse clamping and warm starting decide whether a tall stack of crates rests or jitters and sinks?

level: seniorimportance: should knowfreq 42%

basics

~20 s

An iterative sequential-impulse solver relays a stack's weight contact by contact and converges slowly. Clamping the accumulated impulse lets later iterations undo overshoot; warm starting from last step's impulses begins near the answer, so a few iterations suffice.

open as a page

showing 1–30 of 47