btRigidBody accelerating slower than it should

Post Reply
Silverlan
Posts: 27
Joined: Thu Oct 30, 2014 9:15 pm

btRigidBody accelerating slower than it should

Post by Silverlan »

I have a btRigidBody with a mass of 1.0 and a linear damping of 0.0. Bullet's default gravity is disabled, and physics are simulated 60 times per second.
There is no air resistance or wind, and no forces affecting the body, except for my custom gravity, which is applied every game tick:

Code: Select all

const btVector3 gravity(0.0,-15.0,0.0);
rigidBody->applyCentralForce(gravity *tDelta); // tDelta = Time between last tick and current tick
If I drop the object from standstill and check its speed (magnitude of getLinearVelocity) after 1 second, the result is exactly 10 every time.
Where could this discrepancy come from? Why is it slower than expected?
My physics knowledge isn't the best, so maybe I'm missing something? Are there any other forces involved that could affect the outcome?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: btRigidBody accelerating slower than it should

Post by drleviathan »

There are two problems:

(1) Your calculation of the force of gravity is wrong. You're computing the delta velocity after one timestep: deltaVelocity = acceleration * deltaTime and then submitting that as a force. Instead you should use this formula: force = mass * acceleration

(2) The btDiscreteDynamicsWorld is hard coded to initialize its gravity to <0, -10, 0> and all dynamic objects that are added to the world will inherit that acceleration by default unless they have manually been set otherwise. This means you're trying to apply gravity wrong. Instead do something like this just once:

Code: Select all

rigidBody->setGravity(btVector3(0.0, -15.0, 0.0));
Alternatively if you want all objects to use that acceleration of gravity you could do this after initializing the world:

Code: Select all

world->setGravity(btVector3(0.0, -15.0, 0.0));
Post Reply