Fix handling of in-scenegraph Drawables in MeshOptimizers

This commit is contained in:
scrawl
2017-02-03 17:48:18 +01:00
parent 9403a4c949
commit e48aa118b6
2 changed files with 6 additions and 15 deletions

View File

@@ -33,7 +33,7 @@ public:
Optimizer::OptimizationOptions options)
: BaseOptimizerVisitor(optimizer, options) {}
void reset();
void apply(osg::Geode& geode);
void apply(osg::Geometry& geom);
typedef std::set<osg::Geometry*> GeometryList;
GeometryList& getGeometryList() { return _geometryList; };
protected:
@@ -77,7 +77,7 @@ class OSGUTIL_EXPORT VertexCacheMissVisitor : public osg::NodeVisitor
public:
VertexCacheMissVisitor(unsigned cacheSize = 16);
void reset();
virtual void apply(osg::Geode& geode);
virtual void apply(osg::Geometry& geom);
void doGeometry(osg::Geometry& geom);
unsigned misses;
unsigned triangles;

View File

@@ -38,13 +38,9 @@ void GeometryCollector::reset()
_geometryList.clear();
}
void GeometryCollector::apply(Geode& geode)
void GeometryCollector::apply(Geometry& geom)
{
for(unsigned int i = 0; i < geode.getNumDrawables(); ++i )
{
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
if (geom) _geometryList.insert(geom);
}
_geometryList.insert(&geom);
}
namespace
@@ -890,14 +886,9 @@ void VertexCacheMissVisitor::reset()
triangles = 0;
}
void VertexCacheMissVisitor::apply(Geode& geode)
void VertexCacheMissVisitor::apply(Geometry& geom)
{
for(unsigned int i = 0; i < geode.getNumDrawables(); ++i )
{
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
if (geom)
doGeometry(*geom);
}
doGeometry(geom);
}
namespace