Show
Ignore:
Timestamp:
03/10/09 15:15:59 (5 years ago)
Author:
robert
Message:

From Roland Smeenk, "While working on the Collada plugin I noticed that all geometry created by the dae reader result in slow path geometry.
Because there already exists the option to convert slow path geometry to the fast path by computing an internal fast path alternative, I added a new optimizer option that automatically does this. To check the results I also made some changes to the statistics gathering and rendering.

Somewhat unrelated, but also part of the optimizer I disabled removal of CameraView? nodes during RemoveRedundantNodes? optimization.
As discussed on the ML, CameraViews? were removed from the scenegraph. This solves that issue.

Summary:
-Geometry::areFastPathsUsed now also looks at internalOptimizedGeometry
-Added Optimize option to make all slow path geometry compute their internal fast path alternative
-Added fast geometry counter to the statistics
-Disabled removel of CameraViews? in optimizer
"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgUtil/Optimizer.cpp

    r9703 r9886  
    2222#include <osg/LOD> 
    2323#include <osg/Billboard> 
     24#include <osg/CameraView> 
    2425#include <osg/Geometry> 
    2526#include <osg/Notify> 
     
    110111        if(str.find("~CHECK_GEOMETRY")!=std::string::npos) options ^= CHECK_GEOMETRY; 
    111112        else if(str.find("CHECK_GEOMETRY")!=std::string::npos) options |= CHECK_GEOMETRY; 
     113 
     114        if(str.find("~MAKE_FAST_GEOMETRY")!=std::string::npos) options ^= MAKE_FAST_GEOMETRY; 
     115        else if(str.find("MAKE_FAST_GEOMETRY")!=std::string::npos) options |= MAKE_FAST_GEOMETRY; 
    112116         
    113117        if(str.find("~FLATTEN_BILLBOARDS")!=std::string::npos) options ^= FLATTEN_BILLBOARDS; 
     
    277281 
    278282        CheckGeometryVisitor mgv(this); 
     283        node->accept(mgv); 
     284    } 
     285 
     286    if (options & MAKE_FAST_GEOMETRY) 
     287    { 
     288        osg::notify(osg::INFO)<<"Optimizer::optimize() doing MAKE_FAST_GEOMETRY"<<std::endl; 
     289 
     290        MakeFastGeometryVisitor mgv(this); 
    279291        node->accept(mgv); 
    280292    } 
     
    13091321        // only remove empty groups, but not empty occluders. 
    13101322        if (group.getNumChildren()==0 && isOperationPermissibleForObject(&group) &&  
    1311             (typeid(group)==typeid(osg::Group) || dynamic_cast<osg::Transform*>(&group))) 
     1323            (typeid(group)==typeid(osg::Group) || (dynamic_cast<osg::Transform*>(&group) && !dynamic_cast<osg::CameraView*>(&group)))) 
    13121324        { 
    13131325            _redundantNodeList.insert(&group); 
     
    17811793            { 
    17821794                geom->computeCorrectBindingsAndArraySizes(); 
     1795            } 
     1796        } 
     1797    } 
     1798} 
     1799 
     1800void Optimizer::MakeFastGeometryVisitor::checkGeode(osg::Geode& geode) 
     1801{ 
     1802    if (isOperationPermissibleForObject(&geode)) 
     1803    { 
     1804        for(unsigned int i=0;i<geode.getNumDrawables();++i) 
     1805        { 
     1806            osg::Geometry* geom = geode.getDrawable(i)->asGeometry(); 
     1807            if (geom && isOperationPermissibleForObject(geom)) 
     1808            { 
     1809                if (!geom->areFastPathsUsed() && !geom->getInternalOptimizedGeometry()) 
     1810                { 
     1811                    geom->computeInternalOptimizedGeometry(); 
     1812                } 
    17831813            } 
    17841814        }