osgEarth的Rex引擎原理分析(十九)request請求載入瓦片優先順序的含義
阿新 • • 發佈:2018-11-25
目標:(十七)中的問題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); }