|
From: <cn...@us...> - 2009-08-18 05:24:57
|
Revision: 487
http://hgengine.svn.sourceforge.net/hgengine/?rev=487&view=rev
Author: cnlohr
Date: 2009-08-18 05:24:42 +0000 (Tue, 18 Aug 2009)
Log Message:
-----------
add attic
Added Paths:
-----------
Mercury2/attic/
Mercury2/attic/SelfTraversal.txt
Added: Mercury2/attic/SelfTraversal.txt
===================================================================
--- Mercury2/attic/SelfTraversal.txt (rev 0)
+++ Mercury2/attic/SelfTraversal.txt 2009-08-18 05:24:42 UTC (rev 487)
@@ -0,0 +1,135 @@
+(From Charles Lohr)
+
+At one point I was considering stackless traversal of the scene graph for limited sections.
+I chose not to do this in the end due to the limitation of being unable to adaptively change
+it based on which objects are hidden/visible.
+
+This code is below:
+
+void Viewport::GoAll( const float fDtime )
+{
+ MercuryNode * n;
+ int depth = 0;
+
+ if( NeedsRebuild() )
+ {
+ printf( "Xxxx\n" );
+ }
+
+ //Update pass
+ n = this;
+ while( n )
+ {
+ n->Update( fDtime );
+ n = n->TraversalNextNode( this, depth );
+ }
+
+ //Prerender pass
+ n = this;
+ while( n )
+ {
+ //If we're hidden, skip to the next traversable element
+ if( n->IsHidden() )
+ {
+ //Make sure we have a next sibling...
+ while( n && n != this && !n->NextSibling() )
+ {
+ depth--;
+ n = n->Parent();
+ }
+
+ if( !n || n == this )
+ break;
+
+ n = n->NextSibling();
+ }
+
+
+ const MercuryMatrix& matrix = n->FindGlobalMatrix();
+
+ TransformNode * tn = dynamic_cast< TransformNode * >( n );
+ if( tn )
+ tn->HandleMatrixOperations();
+
+ n->PreRender( matrix );
+
+ if( n->Parent() )
+ n->Parent()->SetCulled( n->Parent()->IsCulled() && n->IsCulled() );
+
+ //Traverse next
+/*
+ MercuryNode * ret;
+ if( ret = n->FirstChild() )
+ {
+ depth++;
+ n = ret;
+ }
+ else if( ret = n->NextSibling() )
+ n = ret;
+ else if( ret = n->Parent() )
+ {
+ depth--;
+
+ while( ret && ret != this && !ret->NextSibling() )
+ {
+ depth--;
+ ret = ret->Parent();
+ }
+
+ if( !ret || ret == this )
+ return 0;
+
+ n = ret->m_nextSibling;
+ }
+ else
+ return 0;
+*/
+
+ n = n->TraversalNextNode( this, depth );
+ }
+
+ n = this;
+ while( n )
+ {
+ if( n->IsHidden() || IsCulled() )
+ {
+ //Make sure we have a next sibling...
+ while( n && n != this && !n->NextSibling() )
+ {
+ depth--;
+ n = n->Parent();
+ }
+
+ if( !n || n == this )
+ break;
+
+ n = n->NextSibling();
+ }
+
+ const MercuryMatrix& matrix = n->FindGlobalMatrix();
+ const MercuryMatrix& modelView = n->FindModelViewMatrix(); //get the one computed in the last transform
+
+ glLoadMatrix( modelView );
+
+ ShaderAttribute sa;
+ sa.type = ShaderAttribute::TYPE_MATRIX;
+ sa.value.matrix = matrix.Ptr();
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+
+ if ( n->m_useAlphaPath )
+ CURRENTRENDERGRAPH->AddAlphaNode(n);
+ else
+ n->Render( modelView );
+
+ glLoadMatrix( modelView );
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+
+ if ( !n->m_useAlphaPath )
+ n->PostRender( modelView );
+
+ n = n->TraversalNextNode( this, depth );
+ }
+
+ this->PostRender( FindModelViewMatrix() );
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|