From 009ddf1b1e75fce8f8b7ae774456d1e1e1093a16 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 8 Apr 2009 10:48:22 +0000 Subject: [PATCH] From Glenn Waldron, "Attached is a patch for osgUtil::Optimizer. If you run the SpatializeGroupsVisitor on a scene graph containing Geodes, StateSets attached to Geodes can be lost. The problem is in SpatializeGroupsVisitor::divide(osg::Geode*, unsigned int) where the code creates a new Group and divides up the input Geode into one Geode per Drawable. I fixed the problem by assigning the Geode's stateset to the new parent group. To replicate the bug, see attached osg/dds files: osgviewer b.osg -- model renders correctly set OSG_OPTIMIZER="SPATIALIZE_GROUPS" osgviewer b.osg -- textures are missing." --- src/osgUtil/Optimizer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 0a482864a..f8496e579 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -2822,6 +2822,8 @@ bool Optimizer::SpatializeGroupsVisitor::divide(osg::Geode* geode, unsigned int } osg::ref_ptr group = new osg::Group; + group->setName(geode->getName()); + group->setStateSet(geode->getStateSet()); for(i=0; igetNumDrawables(); ++i) { osg::Geode* newGeode = new osg::Geode;