remove of RigidBody does not work

Xemame
Posts: 8
Joined: Mon Dec 20, 2010 3:47 pm

remove of RigidBody does not work

Post by Xemame »

Hello,

I remove RigidBodies using removeRigidBody.

However, if I remove a cube, the cube above it does not fall after the removing, as if the first cube was still there.

Do I do something wrong?

Thanks for your replies!
Coderro
Posts: 7
Joined: Fri Jan 21, 2011 4:25 am

Re: remove of RigidBody does not work

Post by Coderro »

This might be a problem with the top cube going into a sleep state and not waking up after you remove the bottom cube. To figure that out, call the top cube's activate function after removing the bottom one.
lulzfish
Posts: 43
Joined: Mon Jan 03, 2011 4:26 pm

Re: remove of RigidBody does not work

Post by lulzfish »

Yeah, this happened with me too, here's what I did:

Before you delete a cube, get its islandTag (This is in the documentation for btRigidBody, I think)
Delete the cube
Iterate over all your other cubes. If a cube has the same islandTag, then that means it was in the same island, and it might be affected by the deletion, so you should reactivate it.

It works decently, although it would be better if Bullet had a "Get all bodies within island i" function.