diff --git a/include/osgUtil/Optimizer b/include/osgUtil/Optimizer index d0a1937b5..665eafb91 100644 --- a/include/osgUtil/Optimizer +++ b/include/osgUtil/Optimizer @@ -275,7 +275,7 @@ class OSGUTIL_EXPORT Optimizer BaseOptimizerVisitor(optimizer, FLATTEN_STATIC_TRANSFORMS) {} virtual void apply(osg::Node& geode); - virtual void apply(osg::Geode& geode); + virtual void apply(osg::Drawable& drawable); virtual void apply(osg::Billboard& geode); virtual void apply(osg::ProxyNode& node); virtual void apply(osg::PagedLOD& node); diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 9c7d525ac..ddacb8800 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -1173,26 +1173,19 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::PagedLOD& node) traverse(node); } - -void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Geode& geode) +void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Drawable& drawable) { - if (!_transformStack.empty()) + osg::Geometry *geometry = drawable.asGeometry(); + if((geometry) && (isOperationPermissibleForObject(&drawable))) { - for(unsigned int i=0;iasGeometry(); - if((geometry) && (isOperationPermissibleForObject(&geode)) && (isOperationPermissibleForObject(geometry))) - { - if(geometry->getVertexArray() && geometry->getVertexArray()->referenceCount() > 1) { - geometry->setVertexArray(dynamic_cast(geometry->getVertexArray()->clone(osg::CopyOp::DEEP_COPY_ALL))); - } - if(geometry->getNormalArray() && geometry->getNormalArray()->referenceCount() > 1) { - geometry->setNormalArray(dynamic_cast(geometry->getNormalArray()->clone(osg::CopyOp::DEEP_COPY_ALL))); - } - } - _drawableSet.insert(geode.getDrawable(i)); + if(geometry->getVertexArray() && geometry->getVertexArray()->referenceCount() > 1) { + geometry->setVertexArray(dynamic_cast(geometry->getVertexArray()->clone(osg::CopyOp::DEEP_COPY_ALL))); + } + if(geometry->getNormalArray() && geometry->getNormalArray()->referenceCount() > 1) { + geometry->setNormalArray(dynamic_cast(geometry->getNormalArray()->clone(osg::CopyOp::DEEP_COPY_ALL))); } } + _drawableSet.insert(&drawable); } void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Billboard& billboard)