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