From Glen 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."

Merged from svn/trunk using:

svn merge -r 9986:9987 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk/src/osgUtil/Optimizer.cpp
This commit is contained in:
Robert Osfield
2009-04-08 10:50:30 +00:00
parent c78d065d51
commit d3d0c28f61

View File

@@ -2792,6 +2792,8 @@ bool Optimizer::SpatializeGroupsVisitor::divide(osg::Geode* geode, unsigned int
}
osg::ref_ptr<osg::Group> group = new osg::Group;
group->setName(geode->getName());
group->setStateSet(geode->getStateSet());
for(i=0; i<geode->getNumDrawables(); ++i)
{
osg::Geode* newGeode = new osg::Geode;