JBullet is a pure Java port of the famous (and awesome) Bullet physics library. I played around it as soon as i got my first Android device in early october and started implementing a Super Monkeyball clone which was actually playable. Back than i wrote a JNI wrapper for the C++ version of Bullet and the performance was really good. Granted my scenery wasn’t all that complex, just a big static mesh, a few kinematic objects and single ball. (Ask me for the code of the wrapper if you want it).
After my small expedition into the realm of float vs fixed-point math in Dalvik a few days back i wrote a simple JBullet demo. It features a plane and 60 cubes that fall down from above, a classic hello world physics demo. The outcome was as expected, the thing is slow:
I get between 4-8fps, the majority of time is taken up by the physics simulation. When the cubes don’t touch the ground plane the simulation takes between 100-120ms, as soon as the cubes touch the ground the time needed goes up to 250ms. That’s not real-time enough i guess :). Never the less, the performance is actually not that bad given the multitude of overhead the Dalvik VM introduces. JBullet uses JStackAlloc to get rid of any heap allocations so garbage collection is not a big deal, as oposed to say JBox2D which is a messy garbage collection monster.
The performance of the JNI wrapper was actually really useable. For the Super Monkeyball setup it took no longer than 4ms, good enough for almost all purposes.
You can find the apk at http://file-pasta.com/file/1/MyriadDemos.apk or use the qr code below with your device