目标:(十七)中的问题40
这要先从TileNode的load说起,它会计算出一个priority,但这个优先级还不是request的优先级
osgEarthDrivers/engine_rex/TileNode.cpp
void
TileNode::load(TerrainCuller* culler)
{
const SelectionInfo& si = _context->getSelectionInfo();
int lod = getKey().getLOD();
int numLods = si.getNumLODs();
// LOD priority is in the range [0..numLods]
float lodPriority = (float)lod;
if ( _context->getOptions().highResolutionFirst() == false )
lodPriority = (float)(numLods - lod);
float distance = culler->getDistanceToViewPoint(getBound().center(), true);
// dist priority uis in the range [0..1]
float distPriority = 1.0 - distance/si.visParameters(0)._visibilityRange;
// add them 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); // GW: moved this to the PagerLoader.
// Submit to the loader.
_context->getLoader()->load( _loadRequest.get(), priority, *culler );
}
紧接着在PagerLoader的load函数中会根据上面生成的优先级设置request的优先级
osgEarthDrivers/engine_rex/Loader.cpp
bool
PagerLoader::load(Loader::Request* request, float priority, osg::NodeVisitor& nv)
{
// update the priority, scale and bias it, and then normalize it to [0..1] range.
unsigned lod = request->getTileKey().getLOD();
float p = priority * _priorityScales[lod] + _priorityOffsets[lod];
request->_priority = p / (float)(_numLODs+1);
}