Page 1 of 1

applyImpulse works intermittantly

Posted: Thu Nov 08, 2012 10:26 pm
by odinsbane
I have a class member

btRigidBody* carBody;

I created a rigid body they same way it is done in the HelloWorld demo, along with a btDiscreteDynamicsWorld* dynamicsWorld from the demo also.

Later I use carBody->applyImpulse(btVector3(0.f,0.5f, 0.f), btVector3(0.f, 0.f, 0.f)).

If I call applyImpulse early, then the impulse is applied and the block takes off. If I wait some time to use it, then nothing happens and the block stays stationary. I am more than willing to post code, or create a test case, but I have not done so yet, maybe there is something obvious I am missing.

Re: applyImpulse works intermittantly

Posted: Fri Nov 09, 2012 5:47 pm
by Erwin Coumans
applyImpulse (and applyForce) doesn't wake up the body once it is fallen asleep.

Call body->activate() first.

Re: applyImpulse works intermittantly

Posted: Fri Nov 09, 2012 9:36 pm
by odinsbane
Perfect, that is exactly what was happening. The object was going to sleep. If I applied the impulses early it would stay away. Thank you.

Re: applyImpulse works intermittantly

Posted: Thu Jan 16, 2014 5:10 pm
by Nickert
Any reason why activate() isn't called by Bullet when applying forces/impulse?

Re: applyImpulse works intermittantly

Posted: Thu Jan 16, 2014 5:20 pm
by Erwin Coumans
We probably should add a 'wakeUp' argument. In many cases, it is better to let the bodies go asleep, once it reaches a stable state.

I'll re-think about it for the Bullet 3.x API.
Thanks,
Erwin