Hi,

I'm currently trying to understand the details of the
RenderTraversalAction and a couple of questions have come up:

1) RTA::recurceNoNodeCallbacks looks as if it should be used from cores
that want to traverse the tree below the current node (it basically does
the same as Action::recurse but does not call callEnter/callLeave on the
current node).  If that is the intended use then it is broken for the
case where _newList is used and two or more passes over the subtree are
required, because the first call to callNewList will destroy the
contents of _newList.  Is this a known/intended limitation ?  I think
this can be fixed by introducing a special variant of callNewList that
swaps the local nodeList with _newList before it returns. [1]

2) It looks as if the usage of e.g. Stages can create dependencies
between partitions, because one draws into a FBO and its contents are
used as a texture elsewhere.  How can one ensure the correct order ?

3) What are partition groups ?  What is the difference between creating
multiple partitions with or without surrounded by
beginPartitionGroup/endPartitionGroup ?

4) How does the sort key generation work, from a high level point of
view ?  What is the idea behind the various uiKeyGen ?

5) The DataSlot mechanism seems to allow a core to attach additional
state to the RTAction, right ?  Are there examples where this is used ?

        Thanks,
                Carsten


[1] Patch attached, it also moves the functionality into Action and
renames it to recurseChildren
diff -r ec6ec2099a07 Source/System/Action/Base/OSGAction.cpp
--- a/Source/System/Action/Base/OSGAction.cpp	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/System/Action/Base/OSGAction.cpp	Wed Jul 18 15:13:35 2007 +0200
@@ -320,9 +320,9 @@ ActionBase::ResultE Action::recurse(Node
     
     if(core == NullFC)
     {
-        SWARNING << "recurse: core is Null,  don't know what to do!" 
-                 << std::endl;
-        return Quit;                    
+        SWARNING << "Action::recurse: core is Null, don't know what to do!"
+                 << endLog;
+        return Quit;
     }
     
     Action::ResultE result;
@@ -380,6 +380,59 @@ ActionBase::ResultE Action::recurse(Node
     return result;
 }
 
+ActionBase::ResultE Action::recurseChildren(NodePtrConstArg node)
+{
+    if(node == NullFC)
+        return Continue;
+
+    if((node->getTravMask() & getTravMask()) == 0)
+        return Continue;
+
+#if OSG_1_COMPAT
+    if(node->getOcclusionMask() & 1)
+        return Continue;
+#endif
+
+    NodeCorePtr core = node->getCore();
+    
+    if(core == NullFC)
+    {
+        SWARNING << "Action::recurseChildren: core is Null, don't know what to do!"
+                 << endLog;
+        return Quit;
+    }
+    
+    Action::ResultE result;
+
+    _actList = NULL;
+    _actNode = node;
+
+    if(! _newList.empty())
+    {
+        result = callNewListChildren();
+    }
+    else if(! _useNewList) // new list is empty, but not used?
+    {
+        std::vector<NodePtr>::const_iterator nodeIt  = node->getMFChildren()->begin();
+        std::vector<NodePtr>::const_iterator nodeEnd = node->getMFChildren()->end();
+
+        for(; nodeIt != nodeEnd; ++nodeIt)
+        {
+            result = recurse(*nodeIt);
+
+            if(result != Continue)
+                break;
+        }
+    }
+
+    _actNode = node;
+
+    if(result == Skip)
+        return Continue;
+
+    return result;
+}
+
 // call the _newList objects
 ActionBase::ResultE Action::callNewList(void)
 {
@@ -391,13 +444,14 @@ ActionBase::ResultE Action::callNewList(
 
     nodeList.swap(_newList);
 
-    std::vector<NodePtr>::iterator it;
-
     _actList = &nodeList;
-
-    for(it = nodeList.begin(); it != nodeList.end(); ++it)
-    {
-        result = recurse(*it);
+    
+    std::vector<NodePtr>::const_iterator nodeIt  = nodeList.begin();
+    std::vector<NodePtr>::const_iterator nodeEnd = nodeList.end();
+
+    for(; nodeIt != nodeEnd; ++nodeIt)
+    {
+        result = recurse(*nodeIt);
 
         if(result != Continue)
             break;
@@ -406,6 +460,32 @@ ActionBase::ResultE Action::callNewList(
     return result;
 }
 
+ActionBase::ResultE Action::callNewListChildren(void)
+{
+    ResultE              result = Continue;
+    std::vector<NodePtr> nodeList;
+    
+    // copy _newList, so it can be used on the next level
+    nodeList.swap(_newList);
+    
+    _actList = &nodeList;
+    
+    std::vector<NodePtr>::const_iterator nodeIt  = nodeList.begin();
+    std::vector<NodePtr>::const_iterator nodeEnd = nodeList.end();
+    
+    for(; nodeIt != nodeEnd; ++nodeIt)
+    {
+        result = recurse(*nodeIt);
+        
+        if(result != Continue)
+            break;
+    }
+    
+    // restore _newList for next pass
+    nodeList.swap(_newList);
+    
+    return result;
+}
 
 // call the start function and its results
 
diff -r ec6ec2099a07 Source/System/Action/Base/OSGAction.h
--- a/Source/System/Action/Base/OSGAction.h	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/System/Action/Base/OSGAction.h	Wed Jul 18 15:32:14 2007 +0200
@@ -181,7 +181,12 @@ class OSG_SYSTEM_DLLMAPPING Action : pub
     // addNode() for every node to traverse, or not at all. 
 
     void         useNodeList(void            ); 
-   
+    
+    // recurse through the node
+    
+    ResultE recurse        (NodePtrConstArg node);
+    ResultE recurseChildren(NodePtrConstArg node);
+    
     /*------------------------- assignment ----------------------------------*/
 
     UInt32 getTravMask (void      ) const;
@@ -238,13 +243,10 @@ class OSG_SYSTEM_DLLMAPPING Action : pub
     virtual ResultE start(void       );  
     virtual ResultE stop (ResultE res); // res is the exit code of the action
     
-    // recurse through the node
-    
-    ResultE recurse(NodePtrConstArg node);
-    
     // call the _newList list of nodes
     
-    ResultE callNewList(void);
+    ResultE callNewList        (void);
+    ResultE callNewListChildren(void);
 
     // access default functors
 
diff -r ec6ec2099a07 Source/System/Action/RenderTraversal/OSGRenderTraversalAction.cpp
--- a/Source/System/Action/RenderTraversal/OSGRenderTraversalAction.cpp	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/System/Action/RenderTraversal/OSGRenderTraversalAction.cpp	Thu Jul 19 12:59:39 2007 +0200
@@ -437,59 +437,6 @@ UInt32 RenderTraversalAction::getCurrent
     return _currentBuffer;
 }
 
-
-/*-------------------------- your_category---------------------------------*/
-
-ActionBase::ResultE RenderTraversalAction::recurceNoNodeCallbacks(
-    NodePtrConstArg node)
-{
-    if(node == NullFC)
-        return Continue;
-
-    if((node->getTravMask() & getTravMask()) == 0)
-        return Continue;
-
-    NodeCorePtr core = node->getCore();
-
-    if(core == NullFC)
-    {
-        SWARNING << "recurse: core is Null,  don't know what to do!"
-                 << std::endl;
-        return Quit;
-    }
-
-    Action::ResultE result;
-
-    _actList = NULL;
-    _actNode = node;
-
-
-    if(! _newList.empty())
-    {
-        result = callNewList();
-    }
-    else if(! _useNewList) // new list is empty, but not used?
-    {
-        std::vector<NodePtr>::const_iterator it;
-
-        for(  it  = node->getMFChildren()->begin();
-              it != node->getMFChildren()->end();
-            ++it)
-        {
-            result = recurse(*it);
-
-            if(result != Continue)
-                break;
-        }
-    }
-
-    _actNode = node;
-
-    if(result == Skip)
-        return Continue;
-
-    return result;
-}
 
 Action::ResultE RenderTraversalAction::start(void)
 {
diff -r ec6ec2099a07 Source/System/Action/RenderTraversal/OSGRenderTraversalAction.h
--- a/Source/System/Action/RenderTraversal/OSGRenderTraversalAction.h	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/System/Action/RenderTraversal/OSGRenderTraversalAction.h	Thu Jul 19 12:58:45 2007 +0200
@@ -133,10 +133,6 @@ class OSG_RENDERTRAV_DLLMAPPING RenderTr
     //-----------------------------------------------------------------------
 
     virtual ~RenderTraversalAction(void);
-
-    /*------------------------- your_category -------------------------------*/
-
-    ResultE recurceNoNodeCallbacks(NodePtrConstArg node);
 
     /*------------------------- your_operators ------------------------------*/
 
diff -r ec6ec2099a07 Source/System/Action/RenderTraversal/OSGRenderTraversalActionInit.cpp
--- a/Source/System/Action/RenderTraversal/OSGRenderTraversalActionInit.cpp	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/System/Action/RenderTraversal/OSGRenderTraversalActionInit.cpp	Wed Jul 18 14:01:29 2007 +0200
@@ -865,7 +865,7 @@ ActionBase::ResultE HDRStageRenderEnter(
             
             NodePtr pActNode = a->getActNode();
             
-            a->recurceNoNodeCallbacks(pActNode);
+            a->recurseChildren(pActNode);
         }
         a->popPartition();
         
diff -r ec6ec2099a07 Source/System/NodeCores/Groups/Light/Shadow/Engines/OSGSimpleShadowMapEngine.cpp
--- a/Source/System/NodeCores/Groups/Light/Shadow/Engines/OSGSimpleShadowMapEngine.cpp	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/System/NodeCores/Groups/Light/Shadow/Engines/OSGSimpleShadowMapEngine.cpp	Wed Jul 18 14:02:38 2007 +0200
@@ -579,7 +579,7 @@ void SimpleShadowMapEngine::doLightPass(
 
 //    lightRenderEnter(pLight, pAction);
 
-    pAction->recurceNoNodeCallbacks(pActNode);
+    pAction->recurseChildren(pActNode);
 
     pAction->popState();
 
@@ -621,7 +621,7 @@ void SimpleShadowMapEngine::doAmbientPas
                  << std::endl;
     }
     
-    pAction->recurceNoNodeCallbacks(pAction->getActNode());
+    pAction->recurseChildren(pAction->getActNode());
 
     pAction->popState();
     
@@ -784,7 +784,7 @@ void SimpleShadowMapEngine::doFinalPass(
     
     lightRenderEnter(pLight, pAction);
 
-    pAction->recurceNoNodeCallbacks(pAction->getActNode());
+    pAction->recurseChildren(pAction->getActNode());
  
     pAction->popState();
 
@@ -828,22 +828,22 @@ ActionBase::ResultE SimpleShadowMapEngin
     {
         if(0x0000 != (bvMask & bvDiffusePassMask))
         {
-            pAction->recurceNoNodeCallbacks(pAction->getActNode());
+            pAction->recurseChildren(pAction->getActNode());
             
             setupCamera    (pLight, eType, pAction, pEngineData);
-            doFinalPass    (pLight,  pAction, pEngineData);
+            doFinalPass    (pLight,        pAction, pEngineData);
         }
 
         if(0x0000 != (bvMask & bvAmbientPassMask))
         {
-            pAction->recurceNoNodeCallbacks(pAction->getActNode());
+            pAction->recurseChildren(pAction->getActNode());
             
             setupLightChunk(pLight, eType, pAction, pEngineData);
         }
 
         if(0x0000 != (bvMask & bvLightPassMask))
         {
-            pAction->recurceNoNodeCallbacks(pAction->getActNode());
+            pAction->recurseChildren(pAction->getActNode());
             
             doLightPass    (pLight,        pAction, pEngineData);
         }
diff -r ec6ec2099a07 Source/Test/RenderTraversalLib/OSGRenderTraversalActionTestInit.cpp
--- a/Source/Test/RenderTraversalLib/OSGRenderTraversalActionTestInit.cpp	Thu Jul 05 10:28:45 2007 +0200
+++ b/Source/Test/RenderTraversalLib/OSGRenderTraversalActionTestInit.cpp	Wed Jul 18 14:03:22 2007 +0200
@@ -203,7 +203,7 @@ ActionBase::ResultE TestMultiPartStageRe
                 
                 NodePtr pActNode = a->getActNode();
                 
-                a->recurceNoNodeCallbacks(pActNode);
+                a->recurseChildren(pActNode);
             }
             pStage->popPartition(a);
         }
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core

Reply via email to