|
From: <cn...@us...> - 2009-08-11 02:26:32
|
Revision: 471
http://hgengine.svn.sourceforge.net/hgengine/?rev=471&view=rev
Author: cnlohr
Date: 2009-08-11 02:26:25 +0000 (Tue, 11 Aug 2009)
Log Message:
-----------
add self-traversal code for nodes.
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-08-11 02:01:09 UTC (rev 470)
+++ Mercury2/src/MercuryNode.cpp 2009-08-11 02:26:25 UTC (rev 471)
@@ -128,7 +128,27 @@
return ret;
}
+MercuryNode * MercuryNode::TraversalNextNode( MercuryNode * stopnode )
+{
+ if( !m_children.empty() )
+ return *(m_children.begin());
+ else if( m_nextSibling )
+ return m_nextSibling;
+ else if( m_parent )
+ {
+ MercuryNode * ret = m_parent;
+ while( ret && ret != stopnode && !ret->m_nextSibling )
+ ret = ret->m_parent;
+
+ if( !ret || ret == stopnode )
+ return 0;
+ return ret->m_nextSibling;
+ }
+ else
+ return 0;
+}
+
void MercuryNode::RecursiveUpdate(float dTime)
{
Update(dTime);
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-08-11 02:01:09 UTC (rev 470)
+++ Mercury2/src/MercuryNode.h 2009-08-11 02:26:25 UTC (rev 471)
@@ -52,6 +52,11 @@
/** Traversal is from the closest parent on upward */
MercuryNode* FindParent( const MString & sNameOfNode, int depth = MAXINT );
+ ///Get the next node in an in-order traversal
+ /** In the traversal, stopnode indicates the node that when passing
+ by on returning up the tree haults traversal. */
+ MercuryNode * TraversalNextNode( MercuryNode * stopnode );
+
virtual void Update(float dTime) {};
virtual void RecursiveUpdate(float dTime);
void ThreadedUpdate(float dTime);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|