In my Ogre3d application I am first changing the parent of a node like this:
// save object "Cube" into node*; then ... Vector3 absPos(node->_getDerivedPosition()); Quaternion absOrient(node->_getDerivedOrientation()); node->getParent()->removeChild(node); m_pSceneMgr->getRootSceneNode()->getChild("NewParentNode")->addChild(node); node->_setDerivedPosition(absPos); node->_setDerivedOrientation(absOrient);
The idea is that after the parent node has been changed the object's position and orientation should remain the same. However, even though this is working fine, it seems that afterwards bullet is again overwriting the object's position. If I remove the object's rigid body from bullet, then everything works fine. If not, then as soon as I change the parent the object's position is changed.
So I thought I simply need to update bullet as well:
btRigidBody* rigid = getBtRigid(String("Cube")); btTransform tr = rigid->getWorldTransform(); tr.setOrigin(BtOgre::Convert::toBullet(absPos)); tr.setRotation(BtOgre::Convert::toBullet(absOrient)); rigid->setWorldTransform(tr);
However, that doesn't work, the object still jumps to another position after the parent is changed. But it is related to bullet for sure, because as said if I remove the object from bullet physics, then it works.
Any ideas what I am missing here?