本文整理汇总了C++中EngineContext::getLoader方法的典型用法代码示例。如果您正苦于以下问题:C++ EngineContext::getLoader方法的具体用法?C++ EngineContext::getLoader怎么用?C++ EngineContext::getLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EngineContext
的用法示例。
在下文中一共展示了EngineContext::getLoader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
TileNode::load(osg::NodeVisitor& nv)
{
// Access the context:
EngineContext* context = static_cast<EngineContext*>( nv.getUserData() );
// Create a new load request on demand:
if ( !_loadRequest.valid() )
{
Threading::ScopedMutexLock lock(_mutex);
if ( !_loadRequest.valid() )
{
_loadRequest = new LoadTileData( this, context );
_loadRequest->setName( _key.str() );
_loadRequest->setTileKey( _key );
}
}
// Prioritize by LOD. (negated because lower order gets priority)
float priority = - (float)getTileKey().getLOD();
if ( context->getOptions().highResolutionFirst() == true )
priority = -priority;
// then sort by distance within each LOD.
float distance = nv.getDistanceToViewPoint( getBound().center(), true );
priority = 10.0f*priority - log10(distance);
// testing intermediate loading idea...
//if ( getTileKey().getLOD() == 5 )
// priority += 100.0f;
// Submit to the loader.
context->getLoader()->load( _loadRequest.get(), priority, nv );
}
示例2: lock
void
TileNode::load(osg::NodeVisitor& nv)
{
// Access the context:
EngineContext* context = VisitorData::fetch<EngineContext>(nv, ENGINE_CONTEXT_TAG);
// Create a new load request on demand:
if ( !_loadRequest.valid() )
{
Threading::ScopedMutexLock lock(_mutex);
if ( !_loadRequest.valid() )
{
_loadRequest = new LoadTileData( this, context );
_loadRequest->setName( _key.str() );
_loadRequest->setTileKey( _key );
}
}
// Construct the load PRIORITY: 0=lowest, 1=highest.
const SelectionInfo& si = context->getSelectionInfo();
int lod = getTileKey().getLOD();
int numLods = si.numLods();
// LOD priority is in the range [0..numLods]
float lodPriority = (float)lod;
if ( context->getOptions().highResolutionFirst() == false )
lodPriority = (float)(numLods - lod);
float distance = nv.getDistanceToViewPoint(getBound().center(), true);
// dist priority uis in the range [0..1]
float distPriority = 1.0 - distance/si.visParameters(0)._visibilityRange;
// add thenm together, and you get tiles sorted first by lodPriority (because of
// the biggest range), and second by distance.
float priority = lodPriority + distPriority;
// normalize the composite priority to [0..1].
priority /= (float)(numLods+1);
// Submit to the loader.
context->getLoader()->load( _loadRequest.get(), priority, nv );
}
示例3: lock
void
TileNode::expireChildren(osg::NodeVisitor& nv)
{
OE_DEBUG << LC << "Expiring children of " << getTileKey().str() << "\n";
EngineContext* context = static_cast<EngineContext*>( nv.getUserData() );
if ( !_expireRequest.valid() )
{
Threading::ScopedMutexLock lock(_mutex);
if ( !_expireRequest.valid() )
{
_expireRequest = new ExpireTiles(this, context);
_expireRequest->setName( getTileKey().str() + " expire" );
_expireRequest->setTileKey( _key );
}
}
// Low priority for expiry requests.
const float lowPriority = -100.0f;
context->getLoader()->load( _expireRequest.get(), lowPriority, nv );
}