Physics Simulation Forum


All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Dec 28, 2016 3:57 pm 

Joined: Thu Oct 30, 2014 9:15 pm
Posts: 26
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:
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?

PostPosted: Wed Dec 28, 2016 6:07 pm 
User avatar

Joined: Tue Sep 30, 2014 6:03 pm
Posts: 346
Location: San Francisco
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:
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:
world->setGravity(btVector3(0.0, -15.0, 0.0));

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 16 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group