[BUG] node's bodies updated in local space instead of global

Nodrev

09-09-2010 15:32:42

Hi,

I use a node hierarchy in my application, so the nodes associated to the bodies do not have for direct parent the Root scene Node.
But, the position and orientation of nodes are setted localy, instead of global space, and it results sometimes a difference beetween the physic position and the visual object position.

Here the correction, to apply the position and orientation in global space terms (compatible for Ogre 1.6.x and 1.7.x):
// In "void Body::updateNode(Ogre::Real interpolatParam)" function)

//m_node->setPosition(m_nodePosit);
//m_node->setOrientation(m_nodeRotation);

// Set position in global terms.
Ogre::Node* m_nodeParent = m_node->getParent();
m_node->setPosition((m_nodeParent->_getDerivedOrientation().Inverse() * (m_nodePosit - m_nodeParent->_getDerivedPosition()) / m_nodeParent->_getDerivedScale()));
m_node->setOrientation((m_nodeParent->_getDerivedOrientation().Inverse() * m_nodeRotation));


Can't commit it, so i let the concerned people to apply this patch :)

kallaspriit

09-09-2010 18:19:45

Thanks for the patch, SVN has been updated :)

Nodrev

13-09-2010 14:17:59

Hi,

More bugs corrections related to the local space conversions problem (getScale function replaced by _getDerivedScale):
In "OgreNewt_CollisionPrimitives.cpp", line 131:
// get scale, if attached to node
Ogre::Node * node = obj->getParentNode();
if (node)
scale = node->_getDerivedScale();


and line 268:
// get scale, if attached to node
Ogre::Node * node = obj->getParentNode();
if (node)
scale = node->_getDerivedScale();


I didn't checked everything, just corrected what went wrong for my app, so maybe more issues with _getGlobalScale are still over there...

kallaspriit

13-09-2010 20:38:00

Added the patch :)

PJani

05-10-2010 09:02:56

Just warning the methods marked with _ in front are slower than others with out _.

Nodrev

05-10-2010 09:47:12

Of course, cause they contains some math functions to change the referential space (parent.Orientation().Inverse() * child.Orientation() for sample, if i remind well maths classes :) )
But they are needed to overidde Ogre's nodes hierarchie.

SFCBias

05-10-2010 16:50:03

Just warning the methods marked with _ in front are slower than others with out _.

As well they are internal functions and return different values than the others.