Skip to content

Commit

Permalink
Patch ClampableNode to discover MapNode since the post merge op for m…
Browse files Browse the repository at this point in the history
…apnodeobserver is .... gone
  • Loading branch information
gwaldron committed Feb 9, 2017
1 parent a3d7284 commit de15bee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/osgEarth/ClampableNode
Expand Up @@ -39,6 +39,11 @@ namespace osgEarth
class OSGEARTH_EXPORT ClampableNode : public OverlayNode, public DepthOffsetInterface
{
public:
/**
* Constructs a new Clampable Node.
*/
ClampableNode();

/**
* Constructs a new clampable node.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/osgEarth/ClampableNode.cpp
Expand Up @@ -40,6 +40,13 @@ namespace

//------------------------------------------------------------------------

ClampableNode::ClampableNode() :
OverlayNode(0L, true, &getTechniqueGroup),
_updatePending(false)
{
_adapter.setGraph( this );
}

ClampableNode::ClampableNode( MapNode* mapNode, bool active ) :
OverlayNode( mapNode, active, &getTechniqueGroup ),
_updatePending( false )
Expand Down
1 change: 1 addition & 0 deletions src/osgEarth/OverlayNode
Expand Up @@ -85,6 +85,7 @@ namespace osgEarth
bool _newActive;
osg::observer_ptr<MapNode> _mapNode;
TechniqueProvider _getGroup;
bool _needsMapNode;

void applyChanges();
};
Expand Down
18 changes: 18 additions & 0 deletions src/osgEarth/OverlayNode.cpp
Expand Up @@ -163,6 +163,13 @@ _getGroup ( provider )
OE_WARN << LC << "Overlay technique not available; disabled." << std::endl;
}
}

// If we don't have a map node, try to find one during UPDATE
if (mapNode == 0L)
{
_needsMapNode = true;
ADJUST_UPDATE_TRAV_COUNT(this, +1);
}
}

OverlayNode::~OverlayNode()
Expand Down Expand Up @@ -310,6 +317,17 @@ OverlayNode::traverse( osg::NodeVisitor& nv )
_dirty = false;
ADJUST_UPDATE_TRAV_COUNT( this, -1 );
}

if (_needsMapNode)
{
MapNode* m = osgEarth::findInNodePath<MapNode>(nv);
if (m)
{
_needsMapNode = false;
ADJUST_UPDATE_TRAV_COUNT(this, -1);
setMapNode(m);
}
}

// traverse children directly, regardles of active status
osg::Group::traverse( nv );
Expand Down

0 comments on commit de15bee

Please sign in to comment.