From 490fc96ea613294475cb137433327b90f8fbb197 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 3 Oct 2006 20:20:23 +0000 Subject: [PATCH] From John Aughey, "Attached is the Optimizer.cpp file that has the fix to duplicate vertex and normal arrays if there is more than one reference to the data. This fixes the problem where the transforms are applied to the same vertex array multiple times if that vertex array is re-used within the model. " --- src/osgUtil/Optimizer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 19263d158..3b84e8f9c 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -1096,6 +1096,16 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Geode& geode) { for(unsigned int i=0;iasGeometry(); + if(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)); } }