Fix handling of in-scenegraph Drawables in SmoothingVisitor, TriStripVisitor and GraphicsCostEstimator

This commit is contained in:
scrawl
2017-02-03 17:55:32 +01:00
parent 4e1a2d3246
commit e38c3d0303
5 changed files with 13 additions and 31 deletions

View File

@@ -36,8 +36,8 @@ class OSGUTIL_EXPORT SmoothingVisitor : public osg::NodeVisitor
/// smooth geoset by creating per vertex normals.
static void smooth(osg::Geometry& geoset, double creaseAngle=osg::PI);
/// apply smoothing method to all geode geosets.
virtual void apply(osg::Geode& geode);
/// apply smoothing method to all geometries.
virtual void apply(osg::Geometry& geom);
/// set the maximum angle, in radians, at which angle between adjacent triangles that normals are smoothed
/// for edges that greater the shared vertices are duplicated

View File

@@ -53,7 +53,7 @@ class OSGUTIL_EXPORT TriStripVisitor : public BaseOptimizerVisitor
void stripify();
/// Accumulate the Geometry drawables to make into strips.
virtual void apply(osg::Geode& geode);
virtual void apply(osg::Geometry& geom);
inline void setCacheSize( unsigned int size )
{

View File

@@ -205,15 +205,10 @@ public:
traverse(node);
}
virtual void apply(osg::Geode& geode)
virtual void apply(osg::Geometry& geom)
{
apply(geode.getStateSet());
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
apply(geode.getDrawable(i)->getStateSet());
osg::Geometry* geometry = geode.getDrawable(i)->asGeometry();
if (geometry) apply(geometry);
}
apply(geom.getStateSet());
apply(&geom);
}
void apply(osg::StateSet* stateset)
@@ -282,15 +277,10 @@ public:
traverse(node);
}
virtual void apply(osg::Geode& geode)
virtual void apply(osg::Geometry& geom)
{
apply(geode.getStateSet());
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
apply(geode.getDrawable(i)->getStateSet());
osg::Geometry* geometry = geode.getDrawable(i)->asGeometry();
if (geometry) apply(geometry);
}
apply(geom.getStateSet());
apply(&geom);
}
void apply(osg::StateSet* stateset)

View File

@@ -702,11 +702,7 @@ void SmoothingVisitor::smooth(osg::Geometry& geom, double creaseAngle)
}
void SmoothingVisitor::apply(osg::Geode& geode)
void SmoothingVisitor::apply(osg::Geometry& geom)
{
for(unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
osg::Geometry* geom = dynamic_cast<osg::Geometry*>(geode.getDrawable(i));
if (geom) smooth(*geom, _creaseAngle);
}
smooth(geom, _creaseAngle);
}

View File

@@ -629,11 +629,7 @@ void TriStripVisitor::stripify()
}
}
void TriStripVisitor::apply(Geode& geode)
void TriStripVisitor::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);
}