callback when body falls in sleep

Post Reply
pwr
Posts: 12
Joined: Sat Sep 24, 2011 4:58 pm

callback when body falls in sleep

Post 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
kloplop321
Posts: 55
Joined: Sun Jan 01, 2012 7:37 pm

Re: callback when body falls in sleep

Post 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.
pwr
Posts: 12
Joined: Sat Sep 24, 2011 4:58 pm

Re: callback when body falls in sleep

Post 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
Post Reply