osgEarth的Rex引擎原理分析(七十七)rex引擎中绘制瓦片的调度过程原理

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目标:(七十二)中的问题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-
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值