applyImpulse works intermittantly

Post Reply
odinsbane
Posts: 6
Joined: Thu Nov 08, 2012 8:51 pm

applyImpulse works intermittantly

Post by odinsbane » Thu Nov 08, 2012 10:26 pm

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.

User avatar
Erwin Coumans
Site Admin
Posts: 4093
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: applyImpulse works intermittantly

Post by Erwin Coumans » Fri Nov 09, 2012 5:47 pm

applyImpulse (and applyForce) doesn't wake up the body once it is fallen asleep.

Call body->activate() first.

odinsbane
Posts: 6
Joined: Thu Nov 08, 2012 8:51 pm

Re: applyImpulse works intermittantly

Post by odinsbane » Fri Nov 09, 2012 9:36 pm

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.

Nickert
Posts: 25
Joined: Sat Dec 29, 2012 7:20 pm

Re: applyImpulse works intermittantly

Post by Nickert » Thu Jan 16, 2014 5:10 pm

Any reason why activate() isn't called by Bullet when applying forces/impulse?

User avatar
Erwin Coumans
Site Admin
Posts: 4093
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: applyImpulse works intermittantly

Post by Erwin Coumans » Thu Jan 16, 2014 5:20 pm

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

Post Reply