issue/bug when removing/adding rigid bodies to world
Posted: Thu Aug 02, 2012 2:31 pm
Hi,
I came across an issue, and it took me quite some time to figure out what was going on.
Basically, in our application, kinematic rigid bodies are sometimes removed (not destroyed) from the world, and added again later on.
I agree this is not a typical usage, but this is what we do.
The problem arise in the following case:
and:
And yet, "btCollisionObject::m_worldTransform" hasn't been updated since the rigid body has been removed from the world, it still points to P1 - where the real current location is P2.
I managed to fix this, by manually synchronizing the "m_worldTransform" with my motion state when adding the rigid body to the world.
However, I wonder if this isn't a bug/flaw of Bullet ? Shouldn't "btDiscreteDynamicsWorld::addRigidBody" ensure "btCollisionObject::m_worldTransform" is up-to-date with the optional motion state ?
Thanks for any input !
I came across an issue, and it took me quite some time to figure out what was going on.
Basically, in our application, kinematic rigid bodies are sometimes removed (not destroyed) from the world, and added again later on.
I agree this is not a typical usage, but this is what we do.
The problem arise in the following case:
- rigid body use motion state
- move 3D object (implicitly rigid body because of the motion state usage) to P1
- after some time, remove kinematic rigid body from world
- 3D object moves meantime to P2
- re-add rigid body to world
- add a constraint (btUniversalConstraint for instance)
Code: Select all
btUniversalConstraint::btUniversalConstraint(...)
{
...
// now get constraint frame in local coordinate systems
m_frameInA = rbA.getCenterOfMassTransform().inverse() * frameInW;
m_frameInB = rbB.getCenterOfMassTransform().inverse() * frameInW;
...
Code: Select all
const btTransform& getCenterOfMassTransform() const {
return m_worldTransform;
}
I managed to fix this, by manually synchronizing the "m_worldTransform" with my motion state when adding the rigid body to the world.
However, I wonder if this isn't a bug/flaw of Bullet ? Shouldn't "btDiscreteDynamicsWorld::addRigidBody" ensure "btCollisionObject::m_worldTransform" is up-to-date with the optional motion state ?
Thanks for any input !