Tuesday, February 1, 2011

Box2dWeb Physics Engine

The Render Engine was using a customized build of the Box2DJS physics engine, which has now been replaced with Box2dWeb.  This makes using the physics engine a bit more simple, even though there was one place where it created a class collision.  I had to modify the code so that it didn't end up clobbering the Sylvester Vector class.

The only issue now is that to have physics, your game will need to load a 200kb file.  It's not the ideal solution, but it takes some of the worry about keeping up to date with the library.  If Box2dWeb is updated, I can drop in a new lib and get any fixes or new features, whereas before I had to mix and match the code if there were going to be any updates.

I've converted the PhysicsDemo to use the new physics lib, but it still needs some tweaking.  It also exposed an issue with R.struct.Container's append() method.  There appears to be an issue with it where it will create a circular reference and send the JavaScript VM spinning out of control.  I'm looking into that and will hopefully have an update soon.

1 comment:

  1. Wow, great job!

    I like all the performance boots you add to TRE :)

    ReplyDelete