Skip to content

Commit

Permalink
Fixes for Uniqifier to handle Drawables as Nodes per the
Browse files Browse the repository at this point in the history
change to OSG in OSG v3.3.2.
  • Loading branch information
pmartz committed Dec 12, 2015
1 parent 334b045 commit 6ac6eeb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
14 changes: 9 additions & 5 deletions include/osgwTools/Uniqifier.h
Expand Up @@ -67,11 +67,13 @@ OSGWTOOLS_EXPORT osg::NodePath uniqify( const osg::NodePath& np );
Note regarding Geometry and Drawable Handling
Around OSG v3.5.1, Geode was made to derive from Group, and Drawable made to
derive from Node, such that Geodes have Drawable children. Prior to this change,
the Uniqifier visitor did not make Drawables unique, as they were data, not
Nodes. For backwards compatibility, Uniqifier still treats Drawables as data
and makes no attempt to make them unique.
Around OSG v3.3.2, Geode was made to derive from Group, and Drawable made to
derive from Node, such that Geodes have Drawable children. osgWorks v3.00.02
treats Drawables as Node objects, which means the Uniqifier ensures that all
Drawables are made unique. Prior to osgWorks v3.00.02, Drawables are treated as
data rather than Node objects, which is just how OSG treated them prior to this
change. As a result, pre-v3.00.02 osgWorks does not create unique Drawables.
Drawables that are shared by multiple Geodes will remain shared after Uniqification.
*/
class OSGWTOOLS_EXPORT Uniqifier : public osg::NodeVisitor
{
Expand All @@ -80,7 +82,9 @@ class OSGWTOOLS_EXPORT Uniqifier : public osg::NodeVisitor

virtual void apply( osg::Node& node );
virtual void apply( osg::Group& node );
#if( OSGWORKS_OSG_VERSION < 30302 )
virtual void apply( osg::Geode& node );
#endif

protected:
};
Expand Down
8 changes: 7 additions & 1 deletion src/osgwTools/Uniqifier.cpp
Expand Up @@ -77,7 +77,7 @@ Uniqifier::Uniqifier( osg::NodeVisitor::TraversalMode mode )

void Uniqifier::apply( osg::Node& node )
{
#if( OSGWORKS_OSG_VERSION < 30501 )
#if( OSGWORKS_OSG_VERSION < 30302 )
// Unusual. A node that is neither a Group nor a Geode.
osg::notify( osg::WARN ) << "Uniqifier: apply(osg::Node&)" << std::endl;
// But, for OSG v3.5.1 and later, not so unusual. Drawables
Expand Down Expand Up @@ -111,11 +111,17 @@ void Uniqifier::apply( osg::Group& node )

traverse( node );
}
#if( OSGWORKS_OSG_VERSION < 30302 )
// Prior to the OSG change that made Geode derive from Group,
// back when Geode derived from Node instead, it was OK to have
// this no-op stub function. But now we must comment it out and
// let apply(Group&) handle the Geode objects.
void Uniqifier::apply( osg::Geode& node )
{
// Nothing to do here.
traverse( node );
}
#endif


// osgwTools
Expand Down
10 changes: 0 additions & 10 deletions tests/testuniqifier/testuniqifier.cpp
Expand Up @@ -87,16 +87,6 @@ class NodeCounter : public osg::NodeVisitor

virtual void apply( osg::Node& node )
{
#if( OSGWORKS_OSG_VERSION >= 30501 )
if( node.asDrawable() != NULL )
{
// In OSG v3.05.01 (and perhaps earlier?), Drawables
// are now Nodes. For backwards compatibility, don't
// count them. Uniqifier currently doesn't operate on
// them, so counting them would cause the test to fail.
return;
}
#endif
_totalNodes++;
_uniqueNodes.insert( &node );
traverse( node );
Expand Down

0 comments on commit 6ac6eeb

Please sign in to comment.