Bizarre behaviour setting position of btRigidBody

Post Reply
ed_welch
Posts: 43
Joined: Wed Mar 04, 2015 6:16 pm

Bizarre behaviour setting position of btRigidBody

Post by ed_welch »

I discovered some bizzarre behaviour of a btRigidBody (with CF_KINEMATIC_OBJECT flag) when you try to set the position of the object.
If set activation state to ISLAND_SLEEPING, then the position can be modified with this code:
btTransform& t = m_pRigidBody->getWorldTransform();
t.setOrigin(btVector3(m_x, m_y, m_z));

however if activation state is DISABLE_SIMULATION the above code does not work. The only way to update position is as follows:
btTransform& t = m_pRigidBody->getWorldTransform();
t.setOrigin(btVector3(m_x, m_y, m_z));
m_pRigidBody->getMotionState()->setWorldTransform(t);
m_pRigidBody->getWorldTransform().setIdentity();
m_pRigidBody->getWorldTransform().setOrigin(btVector3(m_x, m_y, m_z));

even if you remove the line m_pRigidBody->getMotionState()->setWorldTransform(t) it will not work, which makes no sense
Post Reply