osgEarth的Rex引擎原理分析(三十九)ModifyBoundingBoxCallback的使用时机和场合

本文详细分析osgEarth中的ModifyBoundingBoxCallback,探讨其在计算瓦片可视性时修正包围立方体的作用。通常在 Rex 引擎构造和瓦片创建时使用,但其执行内容通常为空,主要涉及osgEarth::Layer::modifyTileBoundingBox函数。同时,文章列出了一系列与osgEarth和Rex引擎相关的问题,涵盖地图引擎的各个核心组件和机制。

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

目标:(三十)中的问题90

在计算TIleNode的裁剪遍历时,需要计算瓦片的可视性,这时就需要计算瓦片的包围立方体。每一个几何图形Drawable都会有一个默认的计算包围立方体的方法,这里ModifyBoundingBoxCallback主要是起到修正包围立方体的作用。

在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/TileNode.cpp
void
TileNode::create(const TileKey& key, TileNode* parent, EngineContext* context)
{
    // Create the drawable for the terrain surface:
    TileDrawable* surfaceDrawable = new TileDrawable(
        key, 
        geom.get(),
        context->getOptions().tileSize().get() );

    // Give the tile Drawable access to the render model so it can properly
    // calculate its bounding box and sphere.
    surfaceDrawable->setModifyBBoxCallback(context->getModifyBBoxCallback());

    // Create the node to house the tile drawable:
    _surface = new SurfaceNode(
        key,
        mapInfo,
        context->getRenderBindings(),
        surfaceDrawable );
}
osgEarthDrivers/engine_rex/TileDrawable.cpp
osg::BoundingBox
T
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值