Simple Box2D - Better, cleverer, more optimised.

^ This time, that's an image - saves on the page rendering time!

Another update on the Box2D classes I'm working on.  No new features, but some pretty cool expansions and improvements to the library object creation.

If you check out the previous post, you'll see that the the dynamically drawn shapes weren't exactly perfect; nor were they very efficient.  Oh they worked fine, and traced the detail of the shape very well - but it took a decent chunk of system resources to animate and ended up with some overlaid shapes; which all made the Box2D a bit sluggish and the behaviours buggy.

So, stealing incorporating ideas from other projects has been the name of the game - namely the ear clipping optimisation code from, combined with some of my own cobbled-together more optimised code for tracing curved edges.

Live demo:

Mouse interaction is enabled in the below example - click and drag the objects to check out how it works.

[kml_flashembed movie="" height="280" width="500" /]

Download the source code for this demo.

  • The source code isn't exactly cleaned up - sometime, eventually, it will be.