diff --git a/include/osgTerrain/DisplacementMappingTechnique b/include/osgTerrain/DisplacementMappingTechnique index 826fd0e5e..21a5e2b17 100644 --- a/include/osgTerrain/DisplacementMappingTechnique +++ b/include/osgTerrain/DisplacementMappingTechnique @@ -18,7 +18,6 @@ #include #include #include -#include namespace osgTerrain { @@ -44,8 +43,6 @@ class OSGTERRAIN_EXPORT DisplacementMappingTechnique : public osgTerrain::Terrai virtual ~DisplacementMappingTechnique(); - osg::ref_ptr _geometryPool; - mutable OpenThreads::Mutex _traversalMutex; mutable OpenThreads::Mutex _transformMutex; diff --git a/include/osgTerrain/Terrain b/include/osgTerrain/Terrain index 230cf9b2c..dce659d0a 100644 --- a/include/osgTerrain/Terrain +++ b/include/osgTerrain/Terrain @@ -18,6 +18,7 @@ #include #include +#include namespace osgTerrain { @@ -54,14 +55,6 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode /** Get the vertical scale hint.*/ float getVerticalScale() const { return _verticalScale; } - /** If set to true the boundaries between adjacent tiles should be equalized. - * Note, it is only possible to equalizae boundaries when the TerrainTile's contain properly assigned TileID's, - * databases built with VirtualPlanetBuilder-0.9.11 and older do not set the TileID, so databases must be - * built with later versions of VirtualPlanetBuilder to take advantage of boundary equalization. */ - void setEqualizeBoundaries(bool equalizeBoundaries); - - /** If true the boundaries between adjacent tiles will be equalized. */ - bool getEqualizeBoundaries() const { return _equalizeBoundaries; } /** Set the default policy to use when deciding whether to enable/disable blending and use of transparent bin. * Note, the Terrain::BlendingPolicy value only sets the value for the TerrainTiles it encloses for the @@ -72,6 +65,26 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode /** Get the default policy to use when deciding whether to enable/disable blending and use of transparent bin.*/ TerrainTile::BlendingPolicy getBlendingPolicy() const { return _blendingPolicy; } + /** If set to true the boundaries between adjacent tiles should be equalized. + * Note, it is only possible to equalizae boundaries when the TerrainTile's contain properly assigned TileID's, + * databases built with VirtualPlanetBuilder-0.9.11 and older do not set the TileID, so databases must be + * built with later versions of VirtualPlanetBuilder to take advantage of boundary equalization. */ + void setEqualizeBoundaries(bool equalizeBoundaries); + + /** If true the boundaries between adjacent tiles will be equalized. */ + bool getEqualizeBoundaries() const { return _equalizeBoundaries; } + + + /** Set a custom GeometryPool to be used by TerrainTechniques that share geometry.*/ + void setGeometryPool(GeometryPool* gp) { _geometryPool = gp; } + + /** Get the GeometryPool.*/ + GeometryPool* getGeometryPool() { return _geometryPool.get(); } + + /** Get the const GeometryPool.*/ + const GeometryPool* getGeometryPool() const { return _geometryPool.get(); } + + /** Get the TerrainTile for a given TileID.*/ TerrainTile* getTile(const TileID& tileID); @@ -109,6 +122,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode float _verticalScale; TerrainTile::BlendingPolicy _blendingPolicy; bool _equalizeBoundaries; + osg::ref_ptr _geometryPool; mutable OpenThreads::ReentrantMutex _mutex; TerrainTileSet _terrainTileSet; diff --git a/src/osgTerrain/DisplacementMappingTechnique.cpp b/src/osgTerrain/DisplacementMappingTechnique.cpp index 5ee0bd871..0e434c853 100644 --- a/src/osgTerrain/DisplacementMappingTechnique.cpp +++ b/src/osgTerrain/DisplacementMappingTechnique.cpp @@ -11,8 +11,7 @@ * OpenSceneGraph Public License for more details. */ -#include -#include +#include #include @@ -25,14 +24,11 @@ using namespace osgTerrain; DisplacementMappingTechnique::DisplacementMappingTechnique() { // OSG_NOTICE<<"DisplacementMappingTechnique::DisplacementMappingTechnique()"<getTerrain()) return; //OSG_NOTICE<<"DisplacementMappingTechnique::init("<getTileSubgraph(_terrainTile); + GeometryPool* geometryPool = _terrainTile->getTerrain()->getGeometryPool(); + _transform = geometryPool->getTileSubgraph(_terrainTile); // set tile as no longer dirty. _terrainTile->setDirtyMask(0); diff --git a/src/osgTerrain/Terrain.cpp b/src/osgTerrain/Terrain.cpp index ea40ef6e9..1ae4a7e16 100644 --- a/src/osgTerrain/Terrain.cpp +++ b/src/osgTerrain/Terrain.cpp @@ -28,6 +28,7 @@ Terrain::Terrain(): _equalizeBoundaries(false) { setNumChildrenRequiringUpdateTraversal(1); + _geometryPool = new GeometryPool; } Terrain::Terrain(const Terrain& ts, const osg::CopyOp& copyop): @@ -36,6 +37,7 @@ Terrain::Terrain(const Terrain& ts, const osg::CopyOp& copyop): _verticalScale(ts._verticalScale), _blendingPolicy(ts._blendingPolicy), _equalizeBoundaries(ts._equalizeBoundaries), + _geometryPool(ts._geometryPool), _terrainTechnique(ts._terrainTechnique) { setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);