From 80389a4a134f68bd0e977dd81af2b89e42cc99f9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 16 Jun 2010 12:46:16 +0000 Subject: [PATCH] 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. --- src/osgTerrain/GeometryTechnique.cpp | 2 +- src/osgTerrain/Terrain.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/osgTerrain/GeometryTechnique.cpp b/src/osgTerrain/GeometryTechnique.cpp index d386e1aa5..0b326b865 100644 --- a/src/osgTerrain/GeometryTechnique.cpp +++ b/src/osgTerrain/GeometryTechnique.cpp @@ -903,7 +903,7 @@ void GeometryTechnique::generateGeometry(BufferData& buffer, Locator* masterLoca _neighbours.clear(); - bool updateNeighboursImmediately = true; + bool updateNeighboursImmediately = false; if (left_tile.valid()) addNeighbour(left_tile.get()); if (right_tile.valid()) addNeighbour(right_tile.get()); diff --git a/src/osgTerrain/Terrain.cpp b/src/osgTerrain/Terrain.cpp index f5ae4257b..a0f0d0919 100644 --- a/src/osgTerrain/Terrain.cpp +++ b/src/osgTerrain/Terrain.cpp @@ -84,15 +84,21 @@ void Terrain::traverse(osg::NodeVisitor& nv) osgUtil::UpdateVisitor* uv = dynamic_cast(&nv); if (uv) { - OpenThreads::ScopedLock lock(_mutex); - for(TerrainTileSet::iterator itr = _updateTerrainTileSet.begin(); - itr != _updateTerrainTileSet.end(); + typedef std::list< osg::ref_ptr > TerrainTileList; + TerrainTileList tiles; + { + OpenThreads::ScopedLock lock(_mutex); + std::copy(_updateTerrainTileSet.begin(), _updateTerrainTileSet.end(), std::back_inserter(tiles)); + _updateTerrainTileSet.clear(); + } + + for(TerrainTileList::iterator itr = tiles.begin(); + itr != tiles.end(); ++itr) { TerrainTile* tile = *itr; tile->traverse(nv); } - _updateTerrainTileSet.clear(); } }