From Brad Christiansen and Robert Osfield, "I have added the new function as suggested. The change was made against trunk from an hour or so ago. I haven't tested the performance yet (and probably won't get a chance till next week) but I have checked my terrains still work. I defaulted the equalization to off as I thought this was best until we can look into why there is the performance hit.

", note from Robert, tweaked the names and enabled the code path.
This commit is contained in:
Robert Osfield 2010-11-02 12:15:18 +00:00
parent 5da431a9a6
commit 526b39060c
3 changed files with 20 additions and 6 deletions

View File

@ -49,6 +49,14 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
/** Get the vertical scale hint.*/ /** Get the vertical scale hint.*/
float getVerticalScale() const { return _verticalScale; } 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 advatange 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. /** 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 * Note, the Terrain::BlendingPolicy value only sets the value for the TerrainTiles it encloses for the
@ -95,6 +103,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
float _sampleRatio; float _sampleRatio;
float _verticalScale; float _verticalScale;
TerrainTile::BlendingPolicy _blendingPolicy; TerrainTile::BlendingPolicy _blendingPolicy;
bool _equalizeBoundaries;
mutable OpenThreads::Mutex _mutex; mutable OpenThreads::Mutex _mutex;
TerrainTileSet _terrainTileSet; TerrainTileSet _terrainTileSet;

View File

@ -29,8 +29,6 @@
using namespace osgTerrain; using namespace osgTerrain;
#define NEW_COORD_CODE
GeometryTechnique::GeometryTechnique() GeometryTechnique::GeometryTechnique()
{ {
setFilterBias(0); setFilterBias(0);
@ -880,8 +878,7 @@ void GeometryTechnique::generateGeometry(BufferData& buffer, Locator* masterLoca
// //
VNG.populateCenter(elevationLayer, layerToTexCoordMap); VNG.populateCenter(elevationLayer, layerToTexCoordMap);
#if 1 if (terrain && terrain->getEqualizeBoundaries())
if (terrain)
{ {
TileID tileID = _terrainTile->getTileID(); TileID tileID = _terrainTile->getTileID();
@ -997,7 +994,6 @@ void GeometryTechnique::generateGeometry(BufferData& buffer, Locator* masterLoca
} }
#endif #endif
} }
#endif
osg::ref_ptr<osg::Vec3Array> skirtVectors = new osg::Vec3Array((*VNG._normals)); osg::ref_ptr<osg::Vec3Array> skirtVectors = new osg::Vec3Array((*VNG._normals));

View File

@ -25,7 +25,8 @@ using namespace osgTerrain;
Terrain::Terrain(): Terrain::Terrain():
_sampleRatio(1.0), _sampleRatio(1.0),
_verticalScale(1.0), _verticalScale(1.0),
_blendingPolicy(TerrainTile::INHERIT) _blendingPolicy(TerrainTile::INHERIT),
_equalizeBoundaries(false)
{ {
setNumChildrenRequiringUpdateTraversal(1); setNumChildrenRequiringUpdateTraversal(1);
_terrainTechnique = new GeometryTechnique; _terrainTechnique = new GeometryTechnique;
@ -36,6 +37,7 @@ Terrain::Terrain(const Terrain& ts, const osg::CopyOp& copyop):
_sampleRatio(ts._sampleRatio), _sampleRatio(ts._sampleRatio),
_verticalScale(ts._verticalScale), _verticalScale(ts._verticalScale),
_blendingPolicy(ts._blendingPolicy), _blendingPolicy(ts._blendingPolicy),
_equalizeBoundaries(ts._equalizeBoundaries),
_terrainTechnique(ts._terrainTechnique) _terrainTechnique(ts._terrainTechnique)
{ {
setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1); setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
@ -71,6 +73,13 @@ void Terrain::setVerticalScale(float scale)
dirtyRegisteredTiles(); dirtyRegisteredTiles();
} }
void Terrain::setEqualizeBoundaries(bool equalizeBoundaries)
{
if(_equalizeBoundaries == equalizeBoundaries) return;
_equalizeBoundaries = equalizeBoundaries;
dirtyRegisteredTiles();
}
void Terrain::setBlendingPolicy(TerrainTile::BlendingPolicy policy) void Terrain::setBlendingPolicy(TerrainTile::BlendingPolicy policy)
{ {
if (_blendingPolicy == policy) return; if (_blendingPolicy == policy) return;