Box2D bug hunting in libgdx

It’s been a while since i’ve coded anything significant for libgdx. Well, today i found an hour to start actually working on the Box2D test bed port. It went pretty smooth so far. I found a couple of bugs in the JNI Wrapper (nothing concerning the motor or joint stuff though), implemented a base class for all tests, much like in the original testbed and included a Box2DDebugRenderer which you can also use in your projects. The renderer is nearly done, i only need to implement two functions (rendering the joints and contacts) which are probably about 15 lines of code. I’ll add them as soon as i start implementing the joint related tests. Note: the debug renderer is not intended to be used for production. You also shouldn’t expect decent performance from it on an Android device. It’s a quick and dirty way to render the world and by no means optimized (uses IntermediateModeRenderer which itself is a slow bitch but is incredibly easy to use).

In any case, the thing is not finished yet but porting a test takes around 2 minutes so i should have all of the tests done by tomorrow. If there are any bugs in the joint wrappers i’ll find them :). Note that so far only the shared library for Windows is up to date, if you want to try the fixed wrapper out on your device you’ll have to compile the native parts yourself in the mean time. Once i have ported all the tests and fixed any potential bug i’ll release libgdx 0.6 and all should be well.

Side note: i’ll tweak the performance of the World.getFixtures(), World.getBodies() and World.getContacts() methods a little. As it is the first two return a collection so this will change to a List in the near future as it avoids instantiating iterators. The later will have some internal tuning. I also plan on finally getting rid of the java.util.HashMap used to track fixtures and bodies and replace it with a Trove like primitive type map implementation.

Since i haven’t posted code in a while, here’s the libgdx port of the pyramid example from the original Box2D testbed:

And that’s the original:

Ok, that’s it for now. Feels good to be back 🙂

2 thoughts on “Box2D bug hunting in libgdx

Leave a Reply

Your email address will not be published.