From ce8321a082a66f1f9ed7eab50e0c05c72d729af5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 11 Feb 2005 20:43:50 +0000 Subject: [PATCH] Added --prune-StateSet option into osgconv for bottleneck testing. --- examples/osgconv/osgconv.cpp | 71 ++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/examples/osgconv/osgconv.cpp b/examples/osgconv/osgconv.cpp index 6a7ad0896..0cdd2b793 100644 --- a/examples/osgconv/osgconv.cpp +++ b/examples/osgconv/osgconv.cpp @@ -252,6 +252,9 @@ public: case(MAKE_ALL_STATESET_OPAQUE): makeNonTransparent = true; break; + default: + makeNonTransparent = false; + break; } if (makeNonTransparent) @@ -278,6 +281,57 @@ public: FixTransparencyMode _mode; }; +class PruneStateSetVisitor : public osg::NodeVisitor +{ +public: + + PruneStateSetVisitor(): + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), + _numStateSetRemoved(0) + { + std::cout<<"Running PruneStateSet..."<getStateSet()) + { + drawable->setStateSet(0); + ++_numStateSetRemoved; + } + } + + traverse(node); + } + + unsigned int _numStateSetRemoved; +}; + + static void usage( const char *prog, const char *msg ) { @@ -300,10 +354,10 @@ static void usage( const char *prog, const char *msg ) osg::notify(osg::NOTICE)<<" --compressed-dxt3 - Enable the usage of S3TC DXT3 compressed textures"<< std::endl; osg::notify(osg::NOTICE)<<" --compressed-dxt5 - Enable the usage of S3TC DXT5 compressed textures"<< std::endl; osg::notify(osg::NOTICE)<< std::endl; - osg::notify(osg::NOTICE)<<" --fixTransparency - fix stateset which are curerntly declared as transprent,"<< std::endl; + osg::notify(osg::NOTICE)<<" --fix-transparency - fix stateset which are curerntly declared as transprent,"<< std::endl; osg::notify(osg::NOTICE)<<" but should be opaque. Defaults to using the "<< std::endl; osg::notify(osg::NOTICE)<<" fixTranspancyMode MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE."<< std::endl; - osg::notify(osg::NOTICE)<<" --fixTransparencyMode - fix stateset which are curerntly declared as"<< std::endl; + osg::notify(osg::NOTICE)<<" --fix-transparency-mode - fix stateset which are curerntly declared as"<< std::endl; osg::notify(osg::NOTICE)<<" transprent but should be opaque. The mode_string determines"<< std::endl; osg::notify(osg::NOTICE)<<" algorithm is used to fix the transparency, options are: "<< std::endl; osg::notify(osg::NOTICE)<<" MAKE_OPAQUE_TEXTURE_STATESET_OPAQUE,"< root = osgDB::readNodeFiles(fileNames); + if (pruneStateSet) + { + PruneStateSetVisitor pssv; + root->accept(pssv); + } + if (fixTransparencyMode != FixTransparencyVisitor::NO_TRANSPARANCY_FIXING) { FixTransparencyVisitor atv(fixTransparencyMode);