Moved osgTerrain::GeometryPool from osgTerrain::DisplacementMappingTechnique to the osgTerrain::Terrain

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14703 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2015-02-18 10:52:52 +00:00
parent e5d51da1b3
commit 5c023d1f76
4 changed files with 29 additions and 18 deletions

View File

@ -18,7 +18,6 @@
#include <osg/MatrixTransform>
#include <osg/Program>
#include <osgTerrain/GeometryTechnique>
#include <osgTerrain/GeometryPool>
namespace osgTerrain
{
@ -44,8 +43,6 @@ class OSGTERRAIN_EXPORT DisplacementMappingTechnique : public osgTerrain::Terrai
virtual ~DisplacementMappingTechnique();
osg::ref_ptr<GeometryPool> _geometryPool;
mutable OpenThreads::Mutex _traversalMutex;
mutable OpenThreads::Mutex _transformMutex;

View File

@ -18,6 +18,7 @@
#include <OpenThreads/ReentrantMutex>
#include <osgTerrain/TerrainTile>
#include <osgTerrain/GeometryPool>
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> _geometryPool;
mutable OpenThreads::ReentrantMutex _mutex;
TerrainTileSet _terrainTileSet;

View File

@ -11,8 +11,7 @@
* OpenSceneGraph Public License for more details.
*/
#include <osgTerrain/Layer>
#include <osgTerrain/TerrainTile>
#include <osgTerrain/Terrain>
#include <osgTerrain/DisplacementMappingTechnique>
@ -25,14 +24,11 @@ using namespace osgTerrain;
DisplacementMappingTechnique::DisplacementMappingTechnique()
{
// OSG_NOTICE<<"DisplacementMappingTechnique::DisplacementMappingTechnique()"<<std::endl;
_geometryPool = new GeometryPool;
}
DisplacementMappingTechnique::DisplacementMappingTechnique(const DisplacementMappingTechnique& st,const osg::CopyOp& copyop):
osgTerrain::TerrainTechnique(st, copyop),
_geometryPool(st._geometryPool)
osgTerrain::TerrainTechnique(st, copyop)
{
// OSG_NOTICE<<"DisplacementMappingTechnique::DisplacementMappingTechnique(DisplacementMappingTechnique&, CopyOp&) "<<_geometryPool.get()<<std::endl;
}
DisplacementMappingTechnique::~DisplacementMappingTechnique()
@ -42,10 +38,12 @@ DisplacementMappingTechnique::~DisplacementMappingTechnique()
void DisplacementMappingTechnique::init(int dirtyMask, bool assumeMultiThreaded)
{
if (!_terrainTile) return;
if (!_terrainTile->getTerrain()) return;
//OSG_NOTICE<<"DisplacementMappingTechnique::init("<<dirtyMask<<", "<<assumeMultiThreaded<<")"<<std::endl;
_transform = _geometryPool->getTileSubgraph(_terrainTile);
GeometryPool* geometryPool = _terrainTile->getTerrain()->getGeometryPool();
_transform = geometryPool->getTileSubgraph(_terrainTile);
// set tile as no longer dirty.
_terrainTile->setDirtyMask(0);

View File

@ -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);