“You’re Building a What Now?” Before thinking about building a Physics Engine, you have to stop and ask yourself a very important question, “why on Earth would you want to build a Physics Engine?” In many respects, a Physics Engine is a solved problem. There are really good ones available, open source, for free (thank you Bullet). Unless you’re a PhD with some fancy new algorithm to try out, you’re not gonna beat any of the existing engines. So why bother?
I didn’t start out trying to build a Physics Engine. I started out (back in 2001) trying to build a really cool space dog fighting game. I didn’t have any really original ideas, but I wanted to combine all of my favorite bits from various games of the genre, and see what I could make. I knew I would never be able to complete it, but I thought it would be interesting to try. As different aspects of the game started coming together, I would occasionally read people mentioning Physics Engines, but I always figured they just weren’t very smart. Everyone knows Physics, right? v=d/t
like from High School. I just coded that up and got back to work. But as the game started to take shape, I noticed that ships didn’t move right. Like if you shot a missile into a wing tip, the whole ship would lurch backwards, instead of going into a spin. So I started reading a bit more about the mysterious Physics Engines. Eventually I became so engrossed I stopped working on the game at all, and just learned Physics.
So this brings us to today. I have found that the world of Physics Engines falls into two categories:
- Well written articles, but not enough detail and no code.
- Code with absolutely no explanation.
So here’s the pitch. I have written a basic but functional Physics Engine. Now I’d like to write about it. The goal is to produce blog posts, that together with the source, will create the world’s first understandable explanation of a Physics Engine. This should be the guide I always wished was available to me.
Let me throw out some buzzwords to explain what it is I have to write about. I’ve written a Rigid Body, Discrete Engine. I use GJK and EPA to do my collision detection. And I wrote a Sequential Constraint Solver to do collision resolution. If you don’t know what any of those terms mean, that’s fine, we’ll go over them all. If you’ve come here looking for information on any of those, then you’re in luck, ’cause that’s what I got.
I call it the Dubious Engine. The full source is available online at: https://github.com/SaintDubious/DubiousEngine. I will try to refer to the actual source with each blog post, so you can see working code, and follow along with the reasoning behind each piece. I hope you find this information useful as you work to create your own Physics Engine. As for my initial question, “Why on Earth would you want to build a Physics Engine?” Simple answer really, it’s a lot of fun.
Contents | See Also >> |