Page 1 of 1

callback when body falls in sleep

Posted: Sun Mar 04, 2012 12:03 pm
by pwr
Hi!
I'm quite new to bullet and haven't really learned the design yet. I'm trying to find out when a body have stopped moving. From what I understand, this is called that the body has fallen into sleep. Is there some way to get a callback when a specific body has fallen in sleep? The reason is that I want to be able to drop a body and then get the final position of the body.

BR
pwr

Re: callback when body falls in sleep

Posted: Sun Mar 04, 2012 3:21 pm
by kloplop321
You can edit the source code for that.
You should only need to edit two functions that would call the callback, and add a function which adds a callback pointer on rigid body or collision object.

Be aware though that if the callback pointer goes bad, you'll have a segfault.

Re: callback when body falls in sleep

Posted: Mon Mar 05, 2012 8:19 am
by pwr
Hi! Editing the bullet source is not really an alternative for me. So I guess I'm stuck with testing the body until it stopps moving. Tried that yesterday. One problem I have is that it is not really clear how to test if the body acutally has stopped moving. btCollisionObject::getActivationState does not seem to do the trick. I have tested it's return value with ISLAND_SLEEPING and it didn't trigger.
Does anyone have any good tips on how to do this or an tutorial about moving states?

BR
pwr