Page 1 of 1

Bizarre behaviour setting position of btRigidBody

Posted: Wed Feb 08, 2023 9:06 pm
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