Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
2  
Are there not callbacks for objects coming to rest and awakening? –  Patrick Hughes Jan 16 '12 at 22:49
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.