diff --git a/include/osgUtil/Optimizer b/include/osgUtil/Optimizer index 83f29df0e..df712d447 100644 --- a/include/osgUtil/Optimizer +++ b/include/osgUtil/Optimizer @@ -125,6 +125,7 @@ class OSGUTIL_EXPORT Optimizer osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _optimizer(optimizer) {} + virtual void apply(osg::Node& geode); virtual void apply(osg::Geode& geode); virtual void apply(osg::Billboard& geode); virtual void apply(osg::Transform& transform); @@ -142,10 +143,12 @@ class OSGUTIL_EXPORT Optimizer typedef std::vector TransformStack; typedef std::set DrawableSet; typedef std::set BillboardSet; + typedef std::set NodeSet; typedef std::set TransformSet; Optimizer* _optimizer; TransformStack _transformStack; + NodeSet _excludedNodeSet; DrawableSet _drawableSet; BillboardSet _billboardSet; TransformSet _transformSet; diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 9bbf57f04..ca6e4d2d1 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -548,6 +548,15 @@ class CollectLowestTransformsVisitor : public osg::NodeVisitor } + void collectDataFor(osg::Node* node) + { + _currentObjectList.push_back(node); + + node->accept(*this); + + _currentObjectList.pop_back(); + } + void collectDataFor(osg::Billboard* billboard) { _currentObjectList.push_back(billboard); @@ -578,9 +587,13 @@ class CollectLowestTransformsVisitor : public osg::NodeVisitor inline bool isOperationPermissableForObject(const osg::Object* object) { + // disable if cannot apply transform functor. const osg::Drawable* drawable = dynamic_cast(object); if (drawable && !drawable->supports(_transformFunctor)) return false; + // disable if object is a light point node. + if (strcmp(object->className(),"LightPointNode")==0) return false; + return _optimizer ? _optimizer->isOperationPermissableForObject(object,Optimizer::FLATTEN_STATIC_TRANSFORMS) : true; } @@ -903,9 +916,17 @@ bool CollectLowestTransformsVisitor::removeTransforms(osg::Node* nodeWeCannotRem return transformRemoved; } +void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Node& node) +{ + if (strcmp(node.className(),"LightPointNode")==0) + { + _excludedNodeSet.insert(&node); + } + traverse(node); +} + void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Geode& geode) { - if (!_transformStack.empty()) { for(unsigned int i=0;i