Body gets stuck floating after body below it is removed

Post Reply
byte56
Posts: 5
Joined: Tue Nov 20, 2012 11:04 pm

Body gets stuck floating after body below it is removed

Post by byte56 »

I have a physics body (A) that falls and settles on top of another body (B). Body B is then modified and no longer supporting body A. Body A continues to stay in the air.

I've tried reactivating body A using activate(). I've tried setting it's linear velocity, it moves at first then slows like it's having friction applied to it (while in the air). The only way I can get it to move again is to use applyForce(). And I have to give it enough force to knock it loose. If I apply too little force body A will just shake or swing like it has a corner stuck. I've changed its activation state to 1 as well. I compared all the values I could think to try between a stuck body and one in free-fall. They appeared to be identical in almost every way. (They had different island IDs).

Applying force down on body A causes it to react as if there's still a body there, but only immediately beneath it. If body A moves to the side at all, it will fall.

Body B is a custom implementation. Its shape extends BoxShape, it's collision algorithm extends CollisionAlgorithm and the body extends RigidBody. Everything else about it works perfectly. It just seems that other bodies that land on it do not properly "wake up" after stopping on it.

Where should I be looking to solve this? What about body A should I alter to make it respond to gravity/collisions normally again?

Thanks for your help.
byte56
Posts: 5
Joined: Tue Nov 20, 2012 11:04 pm

Re: Body gets stuck floating after body below it is removed

Post by byte56 »

Bump after 8 days of no response. Thanks for any tips you can give.
zarlox
Posts: 31
Joined: Tue Apr 26, 2011 5:52 pm

Re: Body gets stuck floating after body below it is removed

Post by zarlox »

byte56 wrote:Body B is a custom implementation. Its shape extends BoxShape, it's collision algorithm extends CollisionAlgorithm and the body extends RigidBody.
It quite strainge that body A remain floating after your custom B is moved. Usually its really the body deactivating. You tried using activate(), but just in case, try by disabling deactivation of body A when it is created:

Code: Select all

bodyA->setActivationState(DISABLE_DEACTIVATION);
Also are you sure the body B really moved? maybe only your graphic representation moved but the rigid body shape is still under the body A. Try turning ON the debug drawing and se if the bounding box is shown at the right position.

Also if you can move your custom body to the basic demo and try to reproduce it there...then you could attach the demo in your post.
byte56
Posts: 5
Joined: Tue Nov 20, 2012 11:04 pm

Re: Body gets stuck floating after body below it is removed

Post by byte56 »

Thanks for the reply. I've tried a few more things, still no luck. I do have the debug graphics turned on, and I see that body B is really being removed. Additionally, objects are able to fall right past the stuck object A, right through where body B was. So I'm fairly sure it's gone. I've also tried setting body A to DISABLE_DEACTIVATION. That doesn't work either.

Could it be something in the CollisionAlgorithm? Contact points not getting cleared? Something the shapes or bodies could contain that have something holding them up? What exactly happens when a body is stopped by another body? What gets set and what needs to be cleared?


It's not a trivial task to move it to the basic demo. It's very tied into my game.
zarlox
Posts: 31
Joined: Tue Apr 26, 2011 5:52 pm

Re: Body gets stuck floating after body below it is removed

Post by zarlox »

AFAIK, nothing change when a body settle on another one beside deactivating but as you disabled the deactivation, this is not the case.

Maybe there is somehow a damping on the object? Could you try to look at it, try bodyA->setDamping(0, 0);

However, i really think it must be caused by your overrides of the rigidbody/collision/shape for body B.
So you might want to try commenting out your custom collision algorythm and see what happens.
byte56
Posts: 5
Joined: Tue Nov 20, 2012 11:04 pm

Re: Body gets stuck floating after body below it is removed

Post by byte56 »

Sorry, I neglected to mention that I tried setting the damping to 0 too. Yes, I'm sure it's caused by the overridden collision as well. But I just took the most basic example I could find and modified the portion that checks when there's something solid in the way. It checks against my terrain (body B). So anything I commented out would likely stop it from working, since it's just the bare minimum.

I will work at converting it to the basic demo since there doesn't seem to be another option.
User avatar
majestik666
Posts: 66
Joined: Tue Mar 02, 2010 6:13 am

Re: Body gets stuck floating after body below it is removed

Post by majestik666 »

which bullet version are you using ?

There was a bug recently http://code.google.com/p/bullet/source/detail?r=2593
where the companionId wasn't resetted propertly for kinematic objects
leaving some contacts alive when they should have disapeared
Post Reply