Erin Catto on Video Game Physics Engines

Software Engineering Radio - the podcast for professional software developers

Host Jason Davey interviews Aaron Kato about the complex engineering required to power video game physics engines. The discussion covers the

Key takeaways

  • Physics engines utilize a multi-stage process including broad phase culling, narrow phase contact computation, and a solver phase.
  • The 'broad phase' uses axis-aligned bounding boxes to quickly eliminate non-colliding pairs of objects.

Main topics

  • Collision detection and raycasting
  • Rigid body vs. soft body simulation

Notable quotes

The primary thing that you'll find in games is that it is used for collision.

Conclusion

The episode provides a deep technical look at how developers balance m

Transcript preview

Speaker 1 (0:00) This is Software Engineering Radio, the podcast for professional developers, on the web at se-radio.net. SE Radio is brought to you by the IEEE Computer Society and by IEEE Software Magazine. Online at computer.org slash software. Speaker 2 (0:18) Welcome to Software Engineering Radio. I'm your host Jason Davey, and our guest today is Aaron Kato, who will be chatting with us about video game physics engines. Aaron is a video game developer who started in the industry at Crystal Dynamics, working on the Tomb Raider series, and later went on to contribute to the physics engine powering Diablo 3, Overwatch, World of Warcraft, and more at Blizzard. Today he is at indie studio Kintsugiyama, developing a new title, The Legend of California. But Aaron is perhaps best known as the developer of Box2D. an open-source physics engine used in titles including Angry Birds, Noita, Crayon Physics, and more. In 2026, he released Box3D, which brings this much-loved physics engine to the third dimension. Welcome, Aaron. Before we move on, is there anything you'd like to add to your bio? Speaker 3 (1:01) Oh, that all sounds good. Yeah. Speaker 2 (1:03) Awesome. I'm excited to get into the topic with you. If listeners would like some additional context, we have a couple of shows in our archive on related topics, including episode 175 on game development with Andrew Brownsword, and episode 536 with Ryan McGee on software engineering in physics research. So Aaron, let's start by defining some key terms. When people hear physics engine, what exactly are we talking about? What responsibilities broadly does a physics engine have in a video game? Speaker 3 (1:30) Right, so a physics engine is responsible for a lot of things. The primary thing that you'll find in games is that it is used for collision. So if you think about old games like... Pac-Man or Pong, those needed to have collisions so that objects wouldn't go through walls or whatever. But it was very simple, fixed function things. With modern games, you have more complex environments, especially when you go into three dimensions. You need some way of shooting a ray through the world and finding out what does that ray hit. That's the most bread and butter thing you'll find in a physics engine is just that collision detection. Physics engines these days also bring other things to the table, such as rigid body simulation. So you may want to have a box that tumbles across the ground realistically to create that sense of immersion into a 3D world. And so we need to simulate the physics of that. So that involves the collision detection, involves solving differential equations, solving constraints, friction, contact. Lots of things go into that. And then furthermore, physics engines are very important for performance. They're kind of a key aspect of the game loop that you'll find in a game. So it needs to have very good performance. Speaker 2 (2:54) Awesome. Let's dig into a few terms you mentioned there. So you alluded to the fact that all the games used fixed function physics. What does that mean exactly? Speaker 3 (3:03) So if you take a game like Pong, for example, there's a ball that's moving up and down and you have a paddle. You would just have some simple logic in your game that will check, did the ball reach the paddle? Is it between the left and right side of the paddle? If so, okay, change the velocity of that ball to go the opposite way. Speaker 2 (3:24) Okay, and newer games are... generally based on a rigid body system. I think listeners might intuitively have a sense of what a rigid body is, but can you make that a little bit more concrete? Speaker 3 (3:33) Right. So rigid bodies aim to simulate Newton's laws of motion fundamentally. And it does that for objects that are of fixed shape. So the shape cannot deform. So if you have a box, it's always a box and you can't squash it or stretch it. Given those limitations, we can do fairly efficient simulation of how that box may translate, how it may rotate, and how it moves through the world and collide with the world. Speaker 2 (4:04) Okay, so that makes sense. Box2D, as I understand it, is a rigid-body physics engine. But are other forms of physics, like a soft body or deformable objects, used in games? Where do those have their place? Speaker 3 (4:15) Soft bodies are a little bit more niche. I think what you'll find in a lot of 3D games you may not notice, though, is there is a lot of claw simulation. Because if you see a AAA game, you see lots of interesting characters wearing interesting clothing, and you want those characters to move through the world and seem natural in their inertia, their secondary motion of their items of clothing. So you would want a claw simulation there. And that's typically considered. soft body collision or soft body simulation. Other kinds of soft body simulation you may find are things like water simulation or maybe something like more deformable. Those exist, but they're more niche in games these days. Speaker 2 (5:04) Okay, that makes sense. So you mentioned secondary motion. I think that's also a principle that animators may be aware of. I think it's the idea that if you stop moving, then your clothes continue to have some momentum. They continue to... swing, your hair moves with you and you don't seem like a stiff artificial object? Speaker 3 (5:21) Correct. So if you imagine that an animator would have to animate every piece of clothing to represent that little bit of inertia, that little bit of responsiveness to movement, that would be fairly intractable. It would be a huge amount of data, a huge amount of labor. So we fall back to simulation to cover the gaps there in that presentation. Speaker 2 (5:43) Okay. I think we'll touch later more on how physics integrates with other systems, but it sounds like often animators will hand animate something and physics simulation is actually applied on top to create this secondary motion. Is that fair to say? Speaker 3 (5:56) That's correct. So in your game engine, you would have an animation system. It would take all the animation data, it would blend it together, produce the final pose. And then after that runs, then you would kick off to the cloth simulation where it takes that change in pose and then applies that to some cloth simulation that then tries to respond to that movement. Speaker 2 (6:19) Okay, awesome. So getting back to some of the fundamentals, people from high school may remember terms like a force, an impulse, a torque. Can you explain and give us a quick recap on what those are? Speaker 3 (6:30) Right. So these terms are related to Newton's laws of motion. So a force is something when you apply it to an object, it causes that object to accelerate. there's a proportionality there and that proportionality is expressed through the mass of the object. So the greater the mass of something, the lower the acceleration will be when you apply the same force. So force is just something external coming in and pushing. It could be like a jet engine, it could be an explosion, it could be a muscle, things like that. These can all apply forces. And then torque is the angular counterpart of that. So a great example of torque is when you're on a seesaw. You may have played on a seesaw as a kid, and you may have noticed that if you sit at the end of the seesaw, you will have more leverage on the person on the other side. But if you scooted in towards the pivot point, you would have a lower leverage on the person on the other side. And that's a consequence of the torque being a force at a distance. Speaker 2 (7:43) Awesome, thanks. That makes sense. And maybe continuing with the seesaw example, it leads on to another question, which is that seesaw is presumably attached or anchored in the middle. Can you talk about what a constraint or a joint is in a physics engine and maybe relate it to that example or any others that help to illustrate that? Speaker 3 (8:01) Yes. So rigid bodies on their own are interesting. They can move and tumble through the world, but they also become interesting in other ways when you can constrain them, limit their motion in some ways along certain degrees of freedom. So if you look at a seesaw, it has a pivot in the middle. And if you think about how can that seesaw move at that point, it really can only rotate. It can't translate. And there's some axes where it cannot rotate about. So it can't like spin along the long axis. It only can spin around that middle axis there. So that is one example of a constraint. There's many other examples of constraints you'll find in physics engines, such as slider constraints, distance constraints. And the most fundamental that you'll find is the contact constraint. That Speaker 2 (8:52) leads us on, I suppose, to what is the contact constraint? Speaker 3 (8:55) So a contact constraint is used to keep a rigid body from basically falling through the floor. So when a box falls on the floor in a physics engine, what happens is there will be a collision detection system there that detects that the box is now touching the floor. And then it will use some sort of algorithm to compute contact points. For example, you can think of a box we might determine at the four corners. where the box is touching the floor, we would create contact points there. And then we would hand those contact points off to the rest of the physics engine, which then tries to constrain that movement. So you would first, at each corner of the box, you would want to prevent that corner from going deeper into the ground. So that's a normal constraint. That's one aspect of contact. And then you may also want to apply some friction in that ground plane. to slow down the movement of that corner of the box. And Speaker 2 (9:57) when you say normal constraint, you don't mean normal in terms of regular, you mean normal in terms of something acting at right angles or pushing away from the surface? Speaker 3 (10:06) Correct. So that refers to the normal vector of the surface, which is basically up. So it's the opposite of tangent. Speaker 2 (10:16) Okay. Something else you mentioned in passing was the idea of casting a ray into the world. Can you talk about these kinds of query operations and how those fit into a physics engine? Speaker 3 (10:26) Right. So there are two fundamental operations you'll do for collision. One is the raycast. So you can think of a raycast as I'm looking into the world through my reticle. If you imagine like a first person game, you might have a reticle, which is maybe a UI element in the middle of your screen. And then as you hover over things in the world, it may indicate that, oh, you're pointing at this treasure chest. And then that treasure chest might highlight or get some glow effect on it. And you need a raycast to go through the world, examine what's in the world, and then see what is the first thing that is hit. So it is basically a line that starts at some origin point, say at your eye, and then goes straight out along some path through the world. And then... the Raycast query on the world will tell you, this is the point you hit, this is the object you hit, and all sorts of data that you can collect from that. Speaker 2 (11:28) I suppose it may not be immediately obvious that this is really a physics operation. It's something within the realms of the physics engine to resolve that because that's the part of the system that understands the physicality of the space and the objects in the world. Speaker 3 (11:40) Right. So these things tend to all come together in the physics engine because First of all, if you're going to have rigid body simulation, you need all those shapes to be there already to provide those contact constraints. For example, you're going to need that floor there so that the box doesn't fall through the floor. If there's a treasure chest there, you probably also want the box to bounce off that treasure chest. So it becomes much more convenient just to put all that into one simulation. Speaker 2 (12:08) Awesome. Thank you. I think that covers the basics for us. Speaker 1 (12:12) A new benchmark for software excellence is here. The IEEE Computer Society created the Software Professional Certifications to help you evaluate candidates and encourage growth across your teams. Find out how to turn your individual contributors into a unified team that delivers excellence at computer.org slash certification. Speaker 2 (12:35) Let's move on to a little more of the nitty-gritty of how this works. As I understand it, physics engines have something you might call a simulation step or a time step. Can you walk us through each frame of the game or each time the physics engine updates? What are the stages that happen and what are the responsibilities of each stage? Speaker 3 (12:53) Yeah, so physics engines have fairly well-defined stages that you'll find in just