A few gotchas when using jbullet-jme

I just switched from using jmephysics to jbullet-jme in stardust.

Mostly the switch was very smooth, a big thanks to the jme-jbullet developers.

2 Problems i encountered:

  1. calling PhysicsNode.setLocalTranslation() inside a Controller causes an endless loop. (StackOverflow)

    PhysicsNode.applyTranslation() calls updateGeometricState() again which in turn executes the Controllers again.

    The workaround i used is to deactivate the controller inside the Controller.update() method.


    public void update(float time) {


    // do all the work



    I’m not sure how to solve this better or different.

  2. like mentioned on the jme-jbullet wiki: here

    “getLocalTranslation().set() does not set the physics object location, use setLocalTranslation(), same applies for getLocalRotation()”

    Its quite hard to find all the places where someone calls getLocalTranslation().set() / getLocalRotation().set() .

    It would be great if this restriction could be resolved somehow.

    I think it would be best if getLocalTranslation() would return a unmodifiable Vector if using jme-jbullet, but i guess thats not an option.

The problem is that jbullet uses javax.vecmath, so you cannot directly use that vector. There would have to be some kind of listener/callback when the local translation Vector3f is set via getLocalTranslation().set()…

The extra calling of updateGeometricState() is unfortunate but necessary in jME2 because well, the update handling in jME2 is bad… Maybe you could add a second setter that doesnt call updateGeometricState().