Commit 2a3a9ba2 authored by Jan Möbius's avatar Jan Möbius

Added a find_hinnen_node action to find nodes that are hidden.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@19878 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1c20d8ed
......@@ -83,6 +83,22 @@ BaseNode* find_node(BaseNode* _root, unsigned int _node_idx)
}
//----------------------------------------------------------------------------
/** \brief Find a node in the scene graph
*
*
* Traverses scenegraph just like the find_node function, but includes hidden nodes.
*
**/
BaseNode* find_hidden_node(BaseNode* _root, unsigned int _node_idx)
{
FindNodeAction action(_node_idx);
traverse_all(_root, action);
return action.node_ptr();
}
//----------------------------------------------------------------------------
......
......@@ -192,6 +192,51 @@ traverse( BaseNode* _node, Action& _action )
//---------------------------------------------------------------------------------
/** Traverse the scenegraph exactly like the traverse() function does,
but also include hidden nodes.
**/
template <class Action>
void
traverse_all( BaseNode* _node, Action & _action)
{
if(_node)
{
bool process_children(true);
// Executes this nodes enter function (if available)
if_has_enter(_action, _node);
// Test rendering order. If NodeFirst, execute this node and the children later.
if(_node->traverseMode() & BaseNode::NodeFirst)
process_children &= _action(_node);
if(process_children)
{
BaseNode::ChildIter cIt, cEnd(_node->childrenEnd());
// Process all children which are not second pass
for (cIt = _node->childrenBegin(); cIt != cEnd; ++cIt)
if (~(*cIt)->traverseMode() & BaseNode::SecondPass)
traverse_all(*cIt, _action);
// Process all children which are second pass
for (cIt = _node->childrenBegin(); cIt != cEnd; ++cIt)
if ((*cIt)->traverseMode() & BaseNode::SecondPass)
traverse_all(*cIt, _action);
}
// If the children had to be rendered first, we now render the node afterwards
if (_node->traverseMode() & BaseNode::ChildrenFirst)
_action(_node);
// Call the leave function of the node.
if_has_leave (_action, _node);
}
}
//---------------------------------------------------------------------------------
/** Traverse the scenegraph starting at the node \c _node and apply
the action \c _action to each node. This traversal function will call the
enter/leave functions of the action if they have been implemented.
......@@ -505,6 +550,9 @@ private:
ACGDLLEXPORT
BaseNode* find_node( BaseNode* _root, unsigned int _node_idx );
ACGDLLEXPORT
BaseNode* find_hidden_node( BaseNode* _root, unsigned int _node_idx );
//----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment