From 33b838e437f7a5d3965a19f847eb0690bb77f8c4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 1 Mar 2016 11:57:02 +0000 Subject: [PATCH] From Jannik Heller, "This submission makes the osgFX::Technique traverse as a normal Group if the visitor is not a cull visitor. As for motivation behind the change, I think it makes more sense that way because only the CullVisitor cares about rendering. Say an intersection visitor or update visitor only needs to traverse the subgraph once, not once for each pass. For these visitors there is no point in traversing the subgraph more than once, since it's exactly the same graph. Another motivation is the performance improvement had when an intersection visitor tests against a multipass Technique." Note about mods by Robert Osfield, "Changed dyanmic_cast<> and check against getTraversalType() to utilize the new asCullVisitor() instead to improve efficiency." --- src/osgFX/Technique.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/osgFX/Technique.cpp b/src/osgFX/Technique.cpp index 0ca7cc85f..1104dadcf 100644 --- a/src/osgFX/Technique.cpp +++ b/src/osgFX/Technique.cpp @@ -42,28 +42,30 @@ void Technique::traverse_implementation(osg::NodeVisitor& nv, Effect* fx) } // special actions must be taken if the node visitor is actually a CullVisitor - osgUtil::CullVisitor *cv = nv.asCullVisitor(); - - // traverse all passes - for (int i=0; ipushStateSet(_passes[i].get()); - } - // traverse the override node if defined, otherwise - // traverse children as a Group would do - osg::Node *override = getOverrideChild(i); - if (override) { - override->accept(nv); - } else { - fx->inherited_traverse(nv); - } + // traverse the override node if defined, otherwise + // traverse children as a Group would do + osg::Node *override = getOverrideChild(i); + if (override) { + override->accept(nv); + } else { + fx->inherited_traverse(nv); + } - // pop the StateSet if necessary - if (cv) { + // pop the StateSet cv->popStateSet(); } } + else + { + fx->inherited_traverse(nv); + } }