Steamlined the handling of osg::Geometry

This commit is contained in:
Robert Osfield
2017-10-05 12:45:47 +01:00
parent 95de3a460e
commit c918916bcb
2 changed files with 15 additions and 22 deletions

View File

@@ -546,27 +546,27 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) {
}
void OBJWriterNodeVisitor::apply(osg::Geometry& geometry)
{
osg::Matrix m = osg::computeLocalToWorld(getNodePath());
pushStateSet(geometry.getStateSet());
processGeometry(&geometry,m);
popStateSet(geometry.getStateSet());
}
void OBJWriterNodeVisitor::apply( osg::Geode &node )
{
pushStateSet(node.getStateSet());
_nameStack.push_back(node.getName());
osg::Matrix m = osg::computeLocalToWorld(getNodePath());
unsigned int count = node.getNumDrawables();
for ( unsigned int i = 0; i < count; i++ )
{
osg::Geometry *g = node.getDrawable( i )->asGeometry();
if ( g != NULL )
{
pushStateSet(g->getStateSet());
processGeometry(g,m);
popStateSet(g->getStateSet());
}
node.getDrawable( i )->accept(*this);
}
popStateSet(node.getStateSet());
_nameStack.pop_back();
}

View File

@@ -65,9 +65,10 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor {
}
}
virtual void apply(osg::Geode &node);
virtual void apply(osg::Geometry & geometry);
virtual void apply(osg::Geode & node);
virtual void apply(osg::Group &node)
virtual void apply(osg::Group & node)
{
pushStateSet(node.getStateSet());
_nameStack.push_back( node.getName().empty() ? node.className() : node.getName() );
@@ -78,14 +79,6 @@ class OBJWriterNodeVisitor: public osg::NodeVisitor {
traverse( node );
_nameStack.pop_back();
popStateSet(node.getStateSet());
}
void traverse (osg::Node &node)
{
pushStateSet(node.getStateSet());
osg::NodeVisitor::traverse( node );
popStateSet(node.getStateSet());
}