本文整理汇总了C++中osg::NodeVisitor::setUserData方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeVisitor::setUserData方法的具体用法?C++ NodeVisitor::setUserData怎么用?C++ NodeVisitor::setUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeVisitor
的用法示例。
在下文中一共展示了NodeVisitor::setUserData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
MapNode::traverse( osg::NodeVisitor& nv )
{
if ( nv.getVisitorType() == nv.EVENT_VISITOR )
{
unsigned int numBlacklist = Registry::instance()->getNumBlacklistedFilenames();
if (numBlacklist != _lastNumBlacklistedFilenames)
{
//Only remove the blacklisted filenames if new filenames have been added since last time.
_lastNumBlacklistedFilenames = numBlacklist;
RemoveBlacklistedFilenamesVisitor v;
_terrainEngine->accept( v );
}
// traverse:
std::for_each( _children.begin(), _children.end(), osg::NodeAcceptOp(nv) );
}
else if ( nv.getVisitorType() == nv.UPDATE_VISITOR )
{
osg::ref_ptr<osg::Referenced> oldUserData = nv.getUserData();
nv.setUserData( this );
std::for_each( _children.begin(), _children.end(), osg::NodeAcceptOp(nv) );
nv.setUserData( oldUserData.get() );
}
else
{
osg::Group::traverse( nv );
}
}
示例2: QuickReleaseGLObjects
void
RexTerrainEngineNode::traverse(osg::NodeVisitor& nv)
{
if ( nv.getVisitorType() == nv.UPDATE_VISITOR && _quickReleaseInstalled == false )
{
osg::Camera* cam = findFirstParentOfType<osg::Camera>( this );
if ( cam )
{
// get the installed PDC so we can nest them:
osg::Camera::DrawCallback* cbToNest = cam->getPostDrawCallback();
// if it's another QR callback, we'll just replace it.
QuickReleaseGLObjects* previousQR = dynamic_cast<QuickReleaseGLObjects*>(cbToNest);
if ( previousQR )
cbToNest = previousQR->_next.get();
cam->setPostDrawCallback( new QuickReleaseGLObjects(_deadTiles.get(), cbToNest) );
_quickReleaseInstalled = true;
OE_INFO << LC << "Quick release enabled" << std::endl;
// knock down the trav count set in the constructor.
ADJUST_UPDATE_TRAV_COUNT( this, -1 );
}
}
if ( nv.getVisitorType() == nv.CULL_VISITOR )
{
// Inform the registry of the current frame so that Tiles have access
// to the information.
if ( _liveTiles.valid() && nv.getFrameStamp() )
{
_liveTiles->setTraversalFrame( nv.getFrameStamp()->getFrameNumber() );
}
}
#if 0
static int c = 0;
if ( ++c % 60 == 0 )
{
OE_NOTICE << LC << "Live = " << _liveTiles->size() << ", Dead = " << _deadTiles->size() << std::endl;
_liveTiles->run( CheckForOrphans() );
}
#endif
if ( _loader.valid() ) // ensures that postInitialize has run
{
TraversalData* tdata = TraversalData::get(nv);
if ( tdata )
{
RefUID& uid = tdata->getOrCreate<RefUID>("landcover.zone");
getEngineContext()->_landCoverData->_currentZoneIndex = uid;
}
// Pass the tile creation context to the traversal.
osg::ref_ptr<osg::Referenced> data = nv.getUserData();
nv.setUserData( this->getEngineContext() );
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
this->getEngineContext()->startCull( cv );
TerrainEngineNode::traverse( nv );
this->getEngineContext()->endCull( cv );
if ( data.valid() )
nv.setUserData( data.get() );
}
else
{
TerrainEngineNode::traverse( nv );
}
}
示例3: if
void
MapNode::traverse( osg::NodeVisitor& nv )
{
if ( nv.getVisitorType() == nv.EVENT_VISITOR )
{
unsigned int numBlacklist = Registry::instance()->getNumBlacklistedFilenames();
if (numBlacklist != _lastNumBlacklistedFilenames)
{
//Only remove the blacklisted filenames if new filenames have been added since last time.
_lastNumBlacklistedFilenames = numBlacklist;
RemoveBlacklistedFilenamesVisitor v;
_terrainEngine->accept( v );
}
// traverse:
std::for_each( _children.begin(), _children.end(), osg::NodeAcceptOp(nv) );
}
else if ( nv.getVisitorType() == nv.UPDATE_VISITOR )
{
osg::ref_ptr<osg::Referenced> oldUserData = nv.getUserData();
nv.setUserData( this );
std::for_each( _children.begin(), _children.end(), osg::NodeAcceptOp(nv) );
nv.setUserData( oldUserData.get() );
}
else if ( nv.getVisitorType() == nv.CULL_VISITOR )
{
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
if ( cv )
{
#if 1
osg::ref_ptr<osg::Referenced> oldUserData = cv->getUserData();
TraversalData* data = new TraversalData();
cv->setUserData( data );
std::for_each( _children.begin(), _children.end(), osg::NodeAcceptOp(nv) );
cv->setUserData( oldUserData.get() );
#else
// insert traversal data for this camera:
osg::ref_ptr<osg::Referenced> oldUserData = cv->getUserData();
MapNodeCullData* cullData = getCullData( cv->getCurrentCamera() );
cv->setUserData( cullData );
cullData->_mapNode = this;
osg::Vec3d eye = cv->getViewPoint();
// horizon:
if ( !cullData->_horizonInitialized )
{
cullData->_horizonInitialized = true;
cullData->_horizon.setEllipsoid( *getMapSRS()->getEllipsoid() );
}
cullData->_horizon.setEye( eye );
// calculate altitude:
const SpatialReference* srs = getMapSRS();
if ( srs && !srs->isProjected() )
{
GeoPoint lla;
lla.fromWorld( srs, eye );
cullData->_cameraAltitude = lla.alt();
cullData->_cameraAltitudeUniform->set( (float)lla.alt() );
}
else
{
cullData->_cameraAltitude = eye.z();
cullData->_cameraAltitudeUniform->set( (float)eye.z() );
}
// window matrix:
cullData->_windowMatrixUniform->set( cv->getWindowMatrix() );
// traverse:
cv->pushStateSet( cullData->_stateSet.get() );
std::for_each( _children.begin(), _children.end(), osg::NodeAcceptOp(nv) );
cv->popStateSet();
// restore:
cv->setUserData( oldUserData.get() );
#endif
}
}
else
{
osg::Group::traverse( nv );
}
}