PhysicsRigidBody.getGravity() returns gravity * mass instead of gravity

Hello there. I found a consistency problem in the PhysicsRigidBody class. I can set the gravity, but calling getGravity() does not return the set gravity. It returns gravity * mass. This leads to very confusing numbers.
I know that the workaround is dividing it myself, but getGravity really should return the gravity in the first place. Or the documentation should tell you that it returns gravity * mass.

This issue should only exist in jbullet, question would be why you can’t remember your own gravity values and have to ask the objects.

  1. The getGravity method should work properly, regardless of whether I can get the info from somewhere else or not.
  2. It may well be that it should work, but it doesn’t. Below code sets a gravity of (0, -9.81, 0) and produces an output of “(0, -981, 0)”:

package start;

import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.objects.PhysicsRigidBody;
import com.jme3.math.Vector3f;

public class GravityTest extends SimpleApplication {

public GravityTest() {

public GravityTest(AppState... initialStates) {

public static void main(String[] args) {
    GravityTest app = new GravityTest();
public void simpleInitApp() {
    CollisionShape shape = new BoxCollisionShape(new Vector3f(1, 1, 1));
    float mass = 100;
    PhysicsRigidBody body = new PhysicsRigidBody(shape, mass);
    body.setGravity(new Vector3f(0f, -9.81f, 0f));


Am I using the wrong class?

EDIT: To clarify, I know how to do a workaround. I just wanted to report this problem.

jME uses jbullet by default.

So the claim that it has been fixed in jbullet simply doesn’t match reality, and jME doesn’t have anything to do with it?

Who claimed it has been fixed in jbullet?

In the link you posted it says “Patch has been applied, finally. Sorry for the huge delay.” (that was in 2008). I’m probably a bit confused, but I assumed that this means it has been fixed. Well, obviously it’s not :frowning:

I think you might have missed the fact that jME wraps the bullet API and uses the java port (jbullet) as default in 3.0 but theres the same API wrapping the native bullet version (bullet) as well (which is in alpha in 3.0). As jbullet isn’t developed any further and due to the developer trying to outsmart the JVM performing very bad on e.g. android future jME versions will use the native bullet version. You can switch them by simply changing the imported jar files.

I’m simply too much of a newbie to have heard of it - I barely knew that jME uses something called “bullet” to do physics stuff. Thank you (again) for clarifying things. You are such an active monkey that I wonder if you ever sleep :stuck_out_tongue:.