目标:(七十二)中的问题151
主要是分析瓦片什么时候进入场景树,什么时候从场景树中移出
1、初始化

osgEarthDrivers/engine_rex/RexTerrainEngineNode.cpp
void
RexTerrainEngineNode::dirtyTerrain()
{
// Build the first level of the terrain.
// Collect the tile keys comprising the root tiles of the terrain.
std::vector<TileKey> keys;
_mapFrame.getProfile()->getAllKeysAtLOD( *_terrainOptions.firstLOD(), keys );
for( unsigned i=0; i<keys.size(); ++i )
{
TileNode* tileNode = new TileNode();
// Next, build the surface geometry for the node.
tileNode->create( keys[i], 0L, _engineContext.get() );
// Add it to the scene graph
_terrain->addChild( tileNode );
// And load the tile's data synchronously (only for root tiles)
tileNode->loadSync();
}
}
2、进入场景树
在裁剪遍历时,判断是否要创建新的瓦片加入到场景树,判断的依据是瓦片是否可见。

3、移出场景树
在遍历rex引擎的卸载器_unloader时,根据情况将瓦片移出场景树,条件是累积的休眠瓦片树达到一定阈值(默认300)。

osgEarthDrivers/engine_rex/Unloader.cpp
void
UnloaderGroup::traverse(osg::NodeVisitor& nv)
{
parentNode->removeSubTiles();
}
判断瓦片是否休眠,要满足帧数、时间等条件:
osgEarthDrivers/engine_rex/TileNode.cpp
bool
TileNode::isDormant(const osg::FrameStamp* fs) const
{
const unsigned minMinExpiryFrames = 3u;
bool dormant =
fs &&
fs->getFrameNumber() - _lastTraversalFrame > std::max(_minExpiryFrames, minMinExpiryFrames) &&
fs-

本文深入剖析osgEarth的Rex引擎在瓦片管理中的关键过程,包括瓦片何时进入和离开场景树的判断逻辑,以及资源的分配与释放,特别是针对内存泄漏的讨论。同时,列出了一系列后续分析的主题,涵盖rex引擎的多个核心组件和功能。
最低0.47元/天 解锁文章
754

被折叠的 条评论
为什么被折叠?



