目标:(九十九)中的问题179
1、TerrainCuller在遍历每个TileNode时,会将_firstTileDrawCommandForTile=0
2、在遍历TileNode下的SurfaceNode时,会创建绘制瓦片的指令DrawTileCommand
2.1如果瓦片有影像,则生成有影像的绘制指令,并赋给_firstTileDrawCommandForTile。
2.2如果瓦片没有影像(会从父节点继承影像),生成没有影像的绘制指令(默认显示裸球颜色),并赋给_firstTileDrawCommandForTile。
osgEarthDrivers/engine_rex/TerrainCuller.cpp
void
TerrainCuller::apply(osg::Node& node)
{
if (tileNode)
{
_firstTileDrawCommandForTile = 0L;
}
else
{
SurfaceNode* surface = dynamic_cast<SurfaceNode*>(&node);
if (surface)
{
for (unsigned p = 0; p < renderModel._passes.size(); ++p)
{
DrawTileCommand* cmd = addDrawCommand(pass.sourceUID(), &renderModel, &pass, _currentTileNode);
if (cmd)
{
if (_firstTileDrawCommandForTile == 0L)
{
_firstTileDrawCommandForTile = cmd;
}
else if (cmd->_order < _firstTileDrawCommandForTile->_order)
{
//_firstTileDrawCommandForTile->_order = 1;
_firstTileDrawCommandForTile = cmd;
}
}
}
// If the culler added no draw commands for this tile... we still need
// to draw something or else there will be a hole! So draw a blank tile.
// UID = -1 is the special UID code for a blank.
if (_firstTileDrawCommandForTile == 0L)
{
//OE_INFO << LC << "Adding blank render for tile " << _currentTileNode->getKey().str() << std::endl;
DrawTileCommand* cmd = addDrawCommand(-1, &renderModel, 0L, _currentTileNode);
if (cmd)
cmd->_order = 0;
}
// Set the layer order of the first draw command for this tile to zero,
// to support proper terrain blending.
if (_firstTileDrawCommandForTile)
{
_firstTileDrawCommandForTile->_order = 0;
}
}
}
}