As you said yourself setWorldTransform() will never be called. There is no real reason for it. The physicssimulation calls getWorldTransform() and does not change it, so no new transform has to be set.
I use the same MotionState for both dynamic and kinematic objects. It is very simple and looks more or less like this:
Code: Select all
void MotionState::getWorldTransform(btTransform &transform) const
{
Vector3 pos = m_object->getPos();
transform.setOrigin(btVector3(btScalar(pos.x), btScalar(pos.y), btScalar(pos.z)));
Matrix3 rot = m_object->getRot();
transform.setBasis(btMatrix3x3(btScalar(rot.m00), btScalar(rot.m10), btScalar(rot.m20),
btScalar(rot.m01), btScalar(rot.m11), btScalar(rot.m21),
btScalar(rot.m02), btScalar(rot.m12), btScalar(rot.m22)));
}
void MotionState::setWorldTransform(const btTransform &transform)
{
btScalar m[16];
transform.getOpenGLMatrix(m);
m_object->setPos(Vector3(m[12], m[13], m[14]));
m_object->setRot(Matrix3(m[0], m[1], m[2], m[4], m[5], m[6], m[8], m[9], m[10]));
}
Maybe if you substitute the m_object parts with the corresponding methods of a Ogre scenenode, it will work for you, too.
If I move an object around and it has a kinematic body attached, the physicssimulation will automatically know the new position by querying getWorldTransform().
Kinematic bodys will
never collide with static bodies. They move exactly the way you tell them to.
I don't understand why they don't push away dynamic bodies for you though.