Few things in game development are as conceptually difficult or annoying to debug as a physics engine. Building a physics engine from scratch was one of the biggest challenges I have ever faced. There are a lot of factors that need to be taken into account: forces, torques, integration, numerical stability, deterministic behavior, mass and inertia, object representation, spaces, orientation, collisions detection, penetration, impulses, dampening and stabilization, contact discovery, contact caching, collision graphs, sleeping, resting contact, rolling, sliding, friction, constraint solving… *takes a deep breath*… the list keeps on going. The even bigger problem is that finding out where to start or what to do next is like trying to find Atlantis underneath Mount Everest; it’s takes a lot of time and focus.
Having said that, I was able to persevere through a lot of the gory details (with the help of my Professor Erik Mohrmann) and the result was a mini physics engine. This implementation features constraint solving taken from Erin Catto’s thesis paper, as well as the other bunch of expected features in a physics engine. Overall I must admit, at the end of the project I was not at all happy with my physics engine, but having said that I know a lot more than I did and know exactly what I would change or do differently next time. Here’s a few videos taken from the engine while it was in development.