目标:(三十)中的问题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