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 
Offline

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


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

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


Top
 Profile  
 
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: No registered users and 3 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