Moved across to using more flexible dirtyMark when dirtying tiles

This commit is contained in:
Robert Osfield 2010-05-27 13:58:46 +00:00
parent 2c77b3d637
commit 72663ec3df
2 changed files with 28 additions and 22 deletions

View File

@ -37,24 +37,14 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
/** Set the sample ratio hint that TerrainTile should use when building geometry. /** Set the sample ratio hint that TerrainTile should use when building geometry.
* Defaults to 1.0, which means use all original sample points.*/ * Defaults to 1.0, which means use all original sample points.*/
void setSampleRatio(float ratio) void setSampleRatio(float ratio);
{
if (_sampleRatio == ratio) return;
_sampleRatio = ratio;
dirtyRegisteredTiles();
}
/** Get the sample ratio hint.*/ /** Get the sample ratio hint.*/
float getSampleRatio() const { return _sampleRatio; } float getSampleRatio() const { return _sampleRatio; }
/** Set the vertical scale hint.*/ /** Set the vertical scale hint.*/
void setVerticalScale(float scale) void setVerticalScale(float scale);
{
if (_verticalScale == scale) return;
_verticalScale = scale;
dirtyRegisteredTiles();
}
/** Get the vertical scale hint.*/ /** Get the vertical scale hint.*/
float getVerticalScale() const { return _verticalScale; } float getVerticalScale() const { return _verticalScale; }
@ -64,12 +54,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
* 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
* TerrainTile's that have their policy set to INHERIT. INHERIT is the default BlendingPolicy for both * TerrainTile's that have their policy set to INHERIT. INHERIT is the default BlendingPolicy for both
* Terrain and TerrainTile, and if both are left to INERHIT then the policy used is ENABLE_BLENDING_WHEN_ALPHA_PRESENT. */ * Terrain and TerrainTile, and if both are left to INERHIT then the policy used is ENABLE_BLENDING_WHEN_ALPHA_PRESENT. */
void setBlendingPolicy(TerrainTile::BlendingPolicy policy) void setBlendingPolicy(TerrainTile::BlendingPolicy policy);
{
if (_blendingPolicy == policy) return;
_blendingPolicy = policy;
dirtyRegisteredTiles();
}
/** Get the default policy to use when deciding whether to enable/disable blending and use of transparent bin.*/ /** Get the default policy to use when deciding whether to enable/disable blending and use of transparent bin.*/
TerrainTile::BlendingPolicy getBlendingPolicy() const { return _blendingPolicy; } TerrainTile::BlendingPolicy getBlendingPolicy() const { return _blendingPolicy; }
@ -99,7 +84,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
friend class TerrainTile; friend class TerrainTile;
void dirtyRegisteredTiles(); void dirtyRegisteredTiles(int dirtyMask = TerrainTile::ALL_DIRTY);
void registerTerrainTile(TerrainTile* tile); void registerTerrainTile(TerrainTile* tile);
void unregisterTerrainTile(TerrainTile* tile); void unregisterTerrainTile(TerrainTile* tile);

View File

@ -55,6 +55,27 @@ Terrain::~Terrain()
_terrainTileMap.clear(); _terrainTileMap.clear();
} }
void Terrain::setSampleRatio(float ratio)
{
if (_sampleRatio == ratio) return;
_sampleRatio = ratio;
dirtyRegisteredTiles();
}
void Terrain::setVerticalScale(float scale)
{
if (_verticalScale == scale) return;
_verticalScale = scale;
dirtyRegisteredTiles();
}
void Terrain::setBlendingPolicy(TerrainTile::BlendingPolicy policy)
{
if (_blendingPolicy == policy) return;
_blendingPolicy = policy;
dirtyRegisteredTiles();
}
void Terrain::traverse(osg::NodeVisitor& nv) void Terrain::traverse(osg::NodeVisitor& nv)
{ {
if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR) if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR)
@ -107,7 +128,7 @@ const TerrainTile* Terrain::getTile(const TileID& tileID) const
return itr->second; return itr->second;
} }
void Terrain::dirtyRegisteredTiles() void Terrain::dirtyRegisteredTiles(int dirtyMask)
{ {
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
@ -115,7 +136,7 @@ void Terrain::dirtyRegisteredTiles()
itr != _terrainTileSet.end(); itr != _terrainTileSet.end();
++itr) ++itr)
{ {
(const_cast<TerrainTile*>(*itr))->setDirty(true); (const_cast<TerrainTile*>(*itr))->setDirtyMask(dirtyMask);
} }
} }