Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Bullet and want to take some action once all objects in a dynamic world have reached 0 velocity (or at least a value that's very close).

I was trying to iterate over all of them all the time and when a counter equals getNumCollisionObjects() then do that action. But it's a complex procedure and I'm beginning to think it's unnecessary.

Is there a better way, perhaps by comparing two frames or a Bullet built-in?

share|improve this question
Are there not callbacks for objects coming to rest and awakening? – Patrick Hughes Jan 16 '12 at 22:49

You can call isActive() on each btCollisionObject. It just returns a boolean, so it's easy to work with.

Alternatively, you can call getActivationState() which returns an int representing one of these values, but you shouldn't need to.

To optimize, if you really need to, I'd just add all collision objects to a list. Loop through this list every frame, removing each inactive object you come across until you find a single active one, then break out of the loop. Or just loop through all objects every frame. Premature optimization is usually not worth it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.