Archive for January, 2007

The gPhysics Engine

Back in 1999 I wrote a physics engine using joint coordinates (Featherstone) and a direct LCP solver (Lemke). By no coincidence, the engine was called gPhysics.

The Lemke solver sucks. It is slow and has numerical problems. However, I am now again interested in joint coordinates. So I dusted off my old code and came across these demos.

The gPhysics engine proves that you can extend Featherstone’s algorithm to simulate trees, detached bodies, and contact. Now I just need to hook it up to a better contact solver.

Split Impulses and Post Projection

I’ve been tinkering with Box2D.

The original version uses Baumgarte stabilization of position errors. The problem with Baumgarte is that it affects the momentum, leading to bouncy or spongy constraints. I’ve attempted to address that problem with Split Impulses and Post Projection

Split Impulses works by making a separate set of pseudo velocities and impulses that serve to reduce position error and don’t influence the velocity solver. This is a fairly cheap solution because it is mixed in with the velocity solver. It works great for contact constraints. However, it does not work so well for joints. I don’t know why it doesn’t work well for joints, but on the other hand, I don’t know why it works so well for contact.

Post Projection is a more mathematically correct method of dealing with position errors. Post Projection (PP) waits until the velocity solver is done and the positions are integrated. PP then attempts to solve the position errors. PP introduces an outer iteration loop which recomputes the Jacobians and updates the positions. PP is the most expensive solution so far, but it is also the most effective.

See this post on Erwin’s site for more info: Bullet Forum Discussion

I also added correct handling of joint softness. This allow me to simulate a suspension bridge with soft joints and gets rid of the relaxation hack.

Box2D Super Split