Re-organized the access of the mutex in Terrain to avoid deadlocks, and temporarily switched off the update of the neightbouring tile boundaries within the GeometryTechnique::generateGeometry method, again to avoid deadlocks.

This commit is contained in:
Robert Osfield 2010-06-16 12:46:16 +00:00
parent d3527f3830
commit 80389a4a13
2 changed files with 11 additions and 5 deletions

View File

@ -903,7 +903,7 @@ void GeometryTechnique::generateGeometry(BufferData& buffer, Locator* masterLoca
_neighbours.clear(); _neighbours.clear();
bool updateNeighboursImmediately = true; bool updateNeighboursImmediately = false;
if (left_tile.valid()) addNeighbour(left_tile.get()); if (left_tile.valid()) addNeighbour(left_tile.get());
if (right_tile.valid()) addNeighbour(right_tile.get()); if (right_tile.valid()) addNeighbour(right_tile.get());

View File

@ -84,15 +84,21 @@ void Terrain::traverse(osg::NodeVisitor& nv)
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv); osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
if (uv) if (uv)
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); typedef std::list< osg::ref_ptr<TerrainTile> > TerrainTileList;
for(TerrainTileSet::iterator itr = _updateTerrainTileSet.begin(); TerrainTileList tiles;
itr != _updateTerrainTileSet.end(); {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
std::copy(_updateTerrainTileSet.begin(), _updateTerrainTileSet.end(), std::back_inserter(tiles));
_updateTerrainTileSet.clear();
}
for(TerrainTileList::iterator itr = tiles.begin();
itr != tiles.end();
++itr) ++itr)
{ {
TerrainTile* tile = *itr; TerrainTile* tile = *itr;
tile->traverse(nv); tile->traverse(nv);
} }
_updateTerrainTileSet.clear();
} }
} }