Bodies do not move again after standing still for 3 seconds

Post Reply
Phillemann
Posts: 9
Joined: Tue Feb 03, 2009 6:36 pm

Bodies do not move again after standing still for 3 seconds

Post by Phillemann »

Hi

I'm using only the bullet collision detection (there's no collision response, bodies may penetrate each other). It works fine, until a body has a linear velocity of 0 for about 3 seconds. After that, it doesn't move at all, no matter what linear velocity I set - like it's stuck.

Here are some details on how I use bullet:
  • I use btDbvtBroadphase, btSequentialImpulseConstraintSolver and btDiscreteDynamicsWorld.
  • I derived my own dispatcher from btCollisionDispatcher which calls setNearCallback in it's constructor and emits a signal in the near callback function. It does, not call btCollisionDispatcher::defaultNearCallback.
  • After creating the world, I call world->getPairCache()->setOverlapFilterCallback(&callback);, where callback is derived from btOverlapFilterCallback. I use this for deciding which bodies can collide with each other.
  • Since the game I'm working on is 2D, each body gets a constraint exactly like the one in the FAQ entry on this topic.
  • I set the bodies' velocity using setLinearVelocity. Each body has a custom motion state derived from btMotionState which updates the sprite which is connected to the body. The objects' position might be updated externally by the game. Since I've found no other way to inform the body about that position change, I just call body->setMotionState(&motion_state); where motion_state is the same motion state it had before. The body then calls getWorldTransform and the position is updated (maybe this is my mistake)?
I hope you can help me, since I find this problem pretty hard to debug. Thanks in advance :)
User avatar
nikki
Posts: 22
Joined: Sat Jun 14, 2008 3:38 pm
Location: Doha, Qatar.
Contact:

Re: Bodies do not move again after standing still for 3 seconds

Post by nikki »

I'm guessing its because they're being deactivated. Just do:-

Code: Select all

mBody->setActivationState(DISABLE_DEACTIVATION);
Phillemann
Posts: 9
Joined: Tue Feb 03, 2009 6:36 pm

Re: Bodies do not move again after standing still for 3 seconds

Post by Phillemann »

nikki wrote:I'm guessing its because they're being deactivated. Just do:-

Code: Select all

mBody->setActivationState(DISABLE_DEACTIVATION);
Oh, great, this seems to solve the issue, thanks! :)

However, couldn't it be considered a bug that a sleeping body is not awakened by a call to setLinearVelocity?
ratmice
Posts: 1
Joined: Thu Feb 05, 2009 8:33 am

Re: Bodies do not move again after standing still for 3 seconds

Post by ratmice »

no things don't reactivate themselves automatically, you need to call

Code: Select all

if (!mBody->isActive()) mBody->activate(true); 
i think
Post Reply