FlattenStaticTransformsVisitor: fix handling of Drawables that are directly in the scene graph not attached to a Geode

This commit is contained in:
scrawl 2017-01-20 22:43:58 +01:00
parent ff1a9a195a
commit 41cbf9a45e
2 changed files with 10 additions and 17 deletions

View File

@ -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);

View File

@ -1173,15 +1173,10 @@ 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())
{
for(unsigned int i=0;i<geode.getNumDrawables();++i)
{
osg::Geometry *geometry = geode.getDrawable(i)->asGeometry();
if((geometry) && (isOperationPermissibleForObject(&geode)) && (isOperationPermissibleForObject(geometry)))
osg::Geometry *geometry = drawable.asGeometry();
if((geometry) && (isOperationPermissibleForObject(&drawable)))
{
if(geometry->getVertexArray() && geometry->getVertexArray()->referenceCount() > 1) {
geometry->setVertexArray(dynamic_cast<osg::Array*>(geometry->getVertexArray()->clone(osg::CopyOp::DEEP_COPY_ALL)));
@ -1190,9 +1185,7 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Geode& geode)
geometry->setNormalArray(dynamic_cast<osg::Array*>(geometry->getNormalArray()->clone(osg::CopyOp::DEEP_COPY_ALL)));
}
}
_drawableSet.insert(geode.getDrawable(i));
}
}
_drawableSet.insert(&drawable);
}
void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Billboard& billboard)