code-google-com / bullet

Automatically exported from code.google.com/p/bullet
0 stars 0 forks source link

Adding parameter to addRigidBody to not set the gravity #324

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Based on the topic
http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4496&start=0
. The method btDiscreteDynamicsWorld::addRigidBody sets the gravity while
adding a rigid body. If the application in question though uses local
gravity this gets overwritten by the gravity set in the world. This in turn
requires tracking addRigidBody calls to reset the gravity. Better would be
to not alter the gravity of the rigid body at all ( which in turn would
make this call one without side effects which is desirable ).

Proposed solution by S.Lundmark to add a parameter changing the method to
look like this:

void btDiscreteDynamicsWorld::addRigidBody(btRigidBody* body, bool
applyGravity){
   if( ! body->isStaticOrKinematicObject() && applyGravity ){
      body->setGravity( m_gravity );
   }
(...)

Original issue reported on code.google.com by rol...@rptd.ch on 30 Dec 2009 at 1:36

GoogleCodeExporter commented 9 years ago
We could use such optional argument (applyGravity), but you still have the 
problem that 
if you call world->setGravity, it will mess with the gravity of all rigid 
bodies.

A flag for each body (ignoreWorldGravity) would solve this.

Original comment by erwin.coumans on 5 Jan 2010 at 12:05

GoogleCodeExporter commented 9 years ago
I solved this by never using setGravity if I have my own gravity control. Not a
problem since if you use your own gravity control you tend to have a list of 
physics
objects around anyways so you can iterate that one forgetting about the bullet 
way.

Original comment by rol...@rptd.ch on 5 Jan 2010 at 7:44

GoogleCodeExporter commented 9 years ago

Fixed in trunk for Bullet 2.76: to disable setting the world gravity, use

rigidbody->setFlags(BT_DISABLE_WORLD_GRAVITY);

Original comment by erwin.coumans on 23 Feb 2010 at 2:36