March 24th, 2010
Last week, I switched the Overgrowth physics engine from ODE (Open Dynamics Engine) to Bullet. This prompted a few questions from blog readers. What are ODE and Bullet? Why did we switch? Why weren't we using Bullet from the start?
What are ODE and Bullet?
ODE and Bullet are both open-source physics engines. What are physics engines? To put it simply, physics engines track all of the physically-active objects in the game, and take into account gravity, collisions, and other constraints to determine how each object's position and orientation changes from one frame to the next.
The "open-source" part is important for two reasons. First, it makes cross-platform development a lot easier. For example, the public SDKs for Havok and PhysX don't currently work on Mac and Linux, and without the source code, there's nothing that users can do about it. Second, with source-code access, users can change anything that isn't working just how they want, and then submit their improvements so that others can use them as well.
Why did we switch from ODE to Bullet?
Open Dynamics Engine has been used in a number of well-known games since 2001, including STALKER and World of Goo. It is powerful and well-documented. So why did we switch? Simply because Bullet is now faster, more accurate, and more fully-featured.
When I tried dropping four hundred boxes on the Overgrowth "desert fort" scene, Bullet performed the simulation twice as fast as ODE did, even without Bullet's optional performance features like multi-threading and OpenCL. One of the factors in its speed is its use of Sony's newly open-sourced SIMD vector math library, which you can find here if you'd like to use it separately.
I say Bullet is more accurate because it provides stable results without as many compromises. In ODE, I often had to use soft constraint-force-mixing parameters in order to prevent complex systems from exploding, which gave collisions a slightly squishy appearance. Bullet seems to handle hard constraints reliably without any visible softening.
Bullet also supports several features that ODE doesn't have yet, including native convex hull support. Convex hulls are essentially just 3D shapes that have a well-defined inside and outside (created by a set of infinite planes). In games, these are used to define every physics object that is not a standard primitive like a box, sphere or capsule. In Overgrowth we will need high-quality convex hull simulation for weapons and other irregularly-shaped props, so this was a big win for Bullet.
So given all these advantages...
Why weren't we using Bullet from the start?
I wrote the physics wrapper for the Phoenix engine a couple years ago, back when Bullet was still quite immature -- it had only recently added support for constraints and motors. Eventually it started to become clear that Bullet was improving faster than ODE, but I was holding off because ODE was already working well in the engine, and I kept hearing that it would take a long time to switch because of Bullet's spotty documentation.
One great thing about ODE is its excellent documentation, especially the online manual. Even though I had written some basic physics engines before, it was a daunting task to figure out how to use a third-party rigid body dynamics library; there are a lot of basic concepts that are not particularly intuitive. For example, collision shapes are different from rigid bodies, and giant immobile objects have a mass of 0. Without good documentation, it would have been more difficult to figure out the patterns behind how large-scale rigid body physics engines work.
Bullet, on the other hand, evolves too fast to have great documentation -- as soon as someone writes nice comments or detailed wiki pages, they are out of date, and worse than having no documentation at all. However, since it's open-source, I don't think this is as big of a problem as people say. When porting the Overgrowth physics from ODE to Bullet, I mostly just looked at the source code of the demos and libraries to find out what was going on. Bullet also has a great forum that is frequented by the developers, who provide quick answers to any appropriately specific questions.
We switched from ODE to Bullet because it's faster, more accurate, and supports important features like convex hulls. On the other hand, starting with a stable, documented physics library like ODE may have given me the experience I needed to be able to understand and use a more rapidly-changing physics library like Bullet.
Do any of you have experience using ODE or Bullet, or have any further questions about them?