Motor Physics: Collision demo

Finally I’ve put all the new physics code together and created a first demo which takes advantage of the brand new collision system.

Collisions are resolved using a very simple but fast method which doesn’t support rotational effects – basically the collision model just applies an impulse based on the velocities and masses of both bodies along the normal of collision to separate them, and computes some sort of dynamic friction along the normals tangential component. A restitution factor is used to simulate energy loss (blend between perfect elastic and inelastic collisions).

As a downside, it suffers badly from jitter and bouncy behavior when bodies are stacked or compressed (turn gravity on/off to see this effect). But because of its speed it might be useful for situations when you have a large amount of particle-like objects, no gravity, or you simply don’t need much accuracy.

Anyway this demo should show the potential of the changes. I am currently working on implementing an iterative impulse solver, based on Erin Cattos great Box2D demo, which of course is going to require more processing time (contact point calculation, iterative impulses). So for the final release I am targeting about 50-100 objects at 30+ fps on a average machine (2Ghz) with full rigid body dynamics, stacking, friction and no noticeable jitter.

(keep mouse inside stage, ‘a’: add box, ‘g’: toggle gravity, ‘f’: flip gravity)