osgEarth的Rex引擎原理分析(三十)RexTerrainEngineNode中_mapFrame的作用

本文详细分析了osgEarth的Rex引擎中RexTerrainEngineNode的_mapFrame组件。MapFrame是对Map的封装,用于监控地图图层变化,管理地图版本、影像层等。它主要应用于计算瓦片包围盒和地图同步。文章列举了一系列后续要探讨的问题,涉及osgEarth的各个核心组件和功能。
摘要由CSDN通过智能技术生成

目标:(十二)中问题13

是Map的时间快照,如注释所说的那样:

/**
     * A "snapshot in time" of a Map model revision. Use this class to get a safe "copy" of
     * the map model lists that you can use without worrying about the model changing underneath
     * you from another thread.
     */
    class OSGEARTH_EXPORT MapFrame

osgEarth::MapFrame,是对Map的更高一级封装,经过MpaFrame包装Map可以监控地图图层的变化情况。

对地图进行了一层封装,能够管理地图的版本号、影像层、高层层等。MapFrame的版本号的含义主要是用来判断是否与Map的版本号一致,如果不一致就需要对MapFram和Map进行同步。

osgEarth/MapFrame.cpp
bool
MapFrame::needsSync() const
{
    if ( !isValid() )
        return false;

    osg::ref_ptr<const Map> map;
    return 
        _map.lock(map) &&
        (map->getDataModelRevision() != _mapDataModelRevision || !_initialized);
}

使用的场合:

1、计算瓦片包围盒时,包围盒回调函数会放入rex引擎的上下文环境中,供使用

osgEarthDrivers/engine_rex/RexTerrainEngineNode.cpp
void
RexTerrainEngineNode::setMap(const Map* map, const TerrainOptions& options)
{
    _modifyBBoxCallback = new ModifyBoundingBoxCallback(_mapFrame);
    _engineContext = new EngineContext(
        getMap(),
        this, // engine
        _geometryPool.get(),
        _loader.get(),
        _unloader.get(),
        _rasterizer,
        _liveTiles.get(),
        _renderBindings,
        _terrainOptions,
        _selectionInfo,
        _modifyBBoxCallback.get());
}
osgEarthDrivers/engine_rex/TileDrawable
    struct ModifyBoundingBoxCallback : public osg::Referenced
    {
        void operator()(const TileKey& key, osg::BoundingBox& bbox) const
        {
            if (_frame.needsSync())
            {
                Threading::ScopedMutexLock lock(_mutex);
                _frame.sync();
            }

            for (LayerVector::const_iterator layer = _frame.layers().begin();
                layer != _frame.layers().end();
                ++layer)
            {
                if (layer->valid())
                {
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值