Lessons
How physics engines work, and how games use them
What happens inside a physics step, built up from a small 2D engine you can pause, step and poke: finding pairs, finding contact points, solving them so stacks stand still, putting bodies to sleep, catching fast ones, joints, and the queries characters are built from. Then the real thing: Jolt, Box3D and Bullet running side by side in your browser on the same scene, what Unreal's Chaos and PhysX do differently, and how to wire a physics engine into an ECS through handles.
Concepts
- 1What a physics step doesThe shape of every rigid-body engine: bodies and shapes, the six phases of a step, why games step physics at a fixed rate and draw between steps, substeps, and the units the tolerances assume.
- 2Broadphase and filteringTurning n² possible pairs into the few dozen worth testing: bounding boxes, sort and sweep, the trees real engines use, fattened bounds, and collision filtering with categories, masks and Jolt's two kinds of layer.
- 3Narrowphase: SAT, GJK and contact manifoldsThe exact test for a pair of shapes and what it has to produce: separating axes, GJK and EPA on the Minkowski difference, reference faces and clipping, feature ids that let contacts persist, and the rounded shapes and margins engines use to keep it robust.
- 4Solving contactsWhy a stack of boxes is the hardest thing a physics engine does: contacts as velocity constraints, sequential impulses and accumulated clamping, friction, warm starting, Baumgarte against soft constraints, and the substepped "soft step" solver Box2D v3 and Box3D use. With every combination measured on the same two stacks.
- 5Sleeping and fast bodiesThe two ends of the speed range. Islands and sleep make bodies at rest cost nothing; tunnelling, speculative contacts and time-of-impact sweeps keep fast bodies from passing through walls. What Jolt, Box3D and Bullet do for each.
- 6JointsConstraints that hold bodies together: what a joint removes, the point constraint behind hinges and ragdolls, rods, ropes and springs, motors, the soft spring behind every "drag this with the mouse", and why chains and heavy loads are hard.
- 7Queries and charactersAsking the physics world questions (rays, shape casts, overlaps) and building characters from the answers: kinematic movers that collide and slide, climb steps and stick to slopes, against characters that are ordinary rigid bodies. How Jolt, Box3D, PhysX and Unreal each do it.
Engines
- 8Jolt, Box3D and BulletThree open-source 3D engines running side by side in your browser on the same scenes: the newest (Box3D), the one big games ship with now (Jolt) and the one a generation of engines and tools grew up on (Bullet). Where each comes from, handles, the step and threading, tall stacks, fast bodies, determinism, characters, and what each has that the others don't.
- 9Chaos and PhysXThe engines inside the big two game engines. Unreal's Chaos: why Epic built it, destruction and fields, the async physics thread and what it costs in input latency, networked physics, a position-based solver. NVIDIA's PhysX: still Unity's physics, open source down to its GPU kernels, two solvers, a kinematic character controller. And a word on Havok.
Integration
The 2D engine behind the concept lessons uses only operations that round identically in every browser, so every scene replays exactly. Code examples are in C++.