Made the computeLocalToWorld etc method to use const NodePath's parameters.
This commit is contained in:
@@ -46,10 +46,11 @@ class TransformVisitor : public NodeVisitor
|
||||
}
|
||||
}
|
||||
|
||||
void accumulate(NodePath& nodePath)
|
||||
void accumulate(const NodePath& nodePath)
|
||||
{
|
||||
for(NodePath::iterator itr=nodePath.begin();
|
||||
itr!=nodePath.end();
|
||||
NodePath& non_const_nodePath = const_cast<NodePath&>(nodePath);
|
||||
for(NodePath::iterator itr=non_const_nodePath.begin();
|
||||
itr!=non_const_nodePath.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->accept(*this);
|
||||
@@ -58,7 +59,7 @@ class TransformVisitor : public NodeVisitor
|
||||
|
||||
};
|
||||
|
||||
Matrix osg::computeLocalToWorld(NodePath& nodePath)
|
||||
Matrix osg::computeLocalToWorld(const NodePath& nodePath)
|
||||
{
|
||||
Matrix matrix;
|
||||
TransformVisitor tv(matrix,TransformVisitor::LOCAL_TO_WORLD);
|
||||
@@ -66,7 +67,7 @@ Matrix osg::computeLocalToWorld(NodePath& nodePath)
|
||||
return matrix;
|
||||
}
|
||||
|
||||
Matrix osg::computeWorldToLocal(NodePath& nodePath)
|
||||
Matrix osg::computeWorldToLocal(const NodePath& nodePath)
|
||||
{
|
||||
osg::Matrix matrix;
|
||||
TransformVisitor tv(matrix,TransformVisitor::WORLD_TO_LOCAL);
|
||||
@@ -74,7 +75,7 @@ Matrix osg::computeWorldToLocal(NodePath& nodePath)
|
||||
return matrix;
|
||||
}
|
||||
|
||||
Matrix osg::computeLocalToEye(const Matrix& modelview,NodePath& nodePath)
|
||||
Matrix osg::computeLocalToEye(const Matrix& modelview,const NodePath& nodePath)
|
||||
{
|
||||
Matrix matrix(modelview);
|
||||
TransformVisitor tv(matrix,TransformVisitor::LOCAL_TO_WORLD);
|
||||
@@ -82,7 +83,7 @@ Matrix osg::computeLocalToEye(const Matrix& modelview,NodePath& nodePath)
|
||||
return matrix;
|
||||
}
|
||||
|
||||
Matrix osg::computeEyeToLocal(const Matrix& modelview,NodePath& nodePath)
|
||||
Matrix osg::computeEyeToLocal(const Matrix& modelview,const NodePath& nodePath)
|
||||
{
|
||||
Matrix matrix;
|
||||
matrix.invert(modelview);
|
||||
|
||||
@@ -72,6 +72,16 @@ void NodeTrackerManipulator::setNode(osg::Node* node)
|
||||
if (getAutoComputeHomePosition()) computeHomePosition();
|
||||
}
|
||||
|
||||
void NodeTrackerManipulator::setTrackNode(osg::Node* node)
|
||||
{
|
||||
CollectParentPaths cpp;
|
||||
node->accept(cpp);
|
||||
|
||||
if (!cpp._nodePaths.empty())
|
||||
{
|
||||
_trackNodePath = cpp._nodePaths[0];
|
||||
}
|
||||
}
|
||||
|
||||
const osg::Node* NodeTrackerManipulator::getNode() const
|
||||
{
|
||||
@@ -321,32 +331,19 @@ void NodeTrackerManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||
|
||||
void NodeTrackerManipulator::computeNodeWorldToLocal(osg::Matrixd& worldToLocal) const
|
||||
{
|
||||
if (_trackNode.valid())
|
||||
if (validateNodePath())
|
||||
{
|
||||
CollectParentPaths cpp;
|
||||
NodeTrackerManipulator* non_const_this = const_cast<NodeTrackerManipulator*>(this);
|
||||
non_const_this->_trackNode->accept(cpp);
|
||||
|
||||
if (!cpp._nodePaths.empty())
|
||||
{
|
||||
worldToLocal = osg::computeWorldToLocal(cpp._nodePaths[0]);
|
||||
}
|
||||
worldToLocal = osg::computeWorldToLocal(_trackNodePath);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeTrackerManipulator::computeNodeLocalToWorld(osg::Matrixd& localToWorld) const
|
||||
{
|
||||
if (_trackNode.valid())
|
||||
if (validateNodePath())
|
||||
{
|
||||
CollectParentPaths cpp;
|
||||
NodeTrackerManipulator* non_const_this = const_cast<NodeTrackerManipulator*>(this);
|
||||
non_const_this->_trackNode->accept(cpp);
|
||||
|
||||
if (!cpp._nodePaths.empty())
|
||||
{
|
||||
localToWorld = osg::computeLocalToWorld(cpp._nodePaths[0]);
|
||||
}
|
||||
localToWorld = osg::computeLocalToWorld(_trackNodePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NodeTrackerManipulator::computeNodeCenterAndRotation(osg::Vec3d& nodeCenter, osg::Quat& nodeRotation) const
|
||||
@@ -354,8 +351,8 @@ void NodeTrackerManipulator::computeNodeCenterAndRotation(osg::Vec3d& nodeCenter
|
||||
osg::Matrixd localToWorld;
|
||||
computeNodeLocalToWorld(localToWorld);
|
||||
|
||||
if (_trackNode.valid())
|
||||
nodeCenter = _trackNode->getBound().center()*localToWorld;
|
||||
if (validateNodePath())
|
||||
nodeCenter = _trackNodePath.back()->getBound().center()*localToWorld;
|
||||
else
|
||||
nodeCenter = osg::Vec3d(0.0f,0.0f,0.0f)*localToWorld;
|
||||
|
||||
@@ -482,25 +479,13 @@ bool NodeTrackerManipulator::calcMovement()
|
||||
if (dx==0 && dy==0) return false;
|
||||
|
||||
|
||||
if (_trackNode.valid())
|
||||
if (validateNodePath())
|
||||
{
|
||||
// osg::notify(osg::NOTICE)<<"_trackNode="<<_trackNode->getName()<<std::endl;
|
||||
osg::Matrix localToWorld;
|
||||
localToWorld = osg::computeLocalToWorld(_trackNodePath);
|
||||
|
||||
CollectParentPaths cpp;
|
||||
_trackNode->accept(cpp);
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"number of nodepaths = "<<cpp._nodePaths.size()<<std::endl;
|
||||
|
||||
if (!cpp._nodePaths.empty())
|
||||
{
|
||||
osg::Matrix localToWorld;
|
||||
localToWorld = osg::computeLocalToWorld(cpp._nodePaths[0]);
|
||||
|
||||
_center = _trackNode->getBound().center() * localToWorld;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
_center = _trackNodePath.back()->getBound().center() * localToWorld;
|
||||
}
|
||||
|
||||
unsigned int buttonMask = _ga_t1->getButtonMask();
|
||||
if (buttonMask==GUIEventAdapter::LEFT_MOUSE_BUTTON)
|
||||
|
||||
Reference in New Issue
Block a user