Removed hardware down sampling hack from GeoemtryTechnique and replaced with Terrain::g/setSampleRatio()
usage.
This commit is contained in:
parent
37bea2727b
commit
234bfeb648
@ -259,6 +259,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
terrain = new osgTerrain::Terrain;
|
||||
terrain->addChild(rootnode);
|
||||
terrain->setSampleRatio(0.25f);
|
||||
|
||||
rootnode = terrain;
|
||||
}
|
||||
|
@ -36,6 +36,14 @@ class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
||||
|
||||
virtual void traverse(osg::NodeVisitor& nv);
|
||||
|
||||
/** Set the sample ratio hint that TerrainTile should use when building geometry.
|
||||
* Defaults to 1.0, which means use all original sample points.*/
|
||||
void setSampleRatio(float ratio) { _sampleRatio = ratio; }
|
||||
|
||||
/** Get the sample ratio hint.*/
|
||||
float getSampleRatio() const { return _sampleRatio; }
|
||||
|
||||
|
||||
/** Get the TerrainTile for a given TileID.*/
|
||||
TerrainTile* getTile(const TileID& tileID);
|
||||
|
||||
@ -54,12 +62,13 @@ class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
||||
typedef std::map< TileID, TerrainTile* > TerrainTileMap;
|
||||
typedef std::set< TerrainTile* > TerrainTileSet;
|
||||
|
||||
float _sampleRatio;
|
||||
|
||||
mutable OpenThreads::Mutex _mutex;
|
||||
TerrainTileSet _terrainTileSet;
|
||||
TerrainTileMap _terrainTileMap;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <osgTerrain/GeometryTechnique>
|
||||
#include <osgTerrain/TerrainTile>
|
||||
#include <osgTerrain/Terrain>
|
||||
|
||||
#include <osgUtil/SmoothingVisitor>
|
||||
|
||||
@ -228,24 +229,26 @@ void GeometryTechnique::generateGeometry(Locator* masterLocator, const osg::Vec3
|
||||
numRows = elevationLayer->getNumRows();
|
||||
}
|
||||
|
||||
float sampleRatio = _terrainTile->getTerrain() ? _terrainTile->getTerrain()->getSampleRatio() : 1.0f;
|
||||
|
||||
double i_sampleFactor = 1.0;
|
||||
double j_sampleFactor = 1.0;
|
||||
|
||||
unsigned int targetSize = 32;
|
||||
if (numColumns==64 && numColumns>targetSize)
|
||||
if (sampleRatio!=1.0f)
|
||||
{
|
||||
|
||||
unsigned int originalNumColumns = numColumns;
|
||||
unsigned int originalNumRows = numRows;
|
||||
|
||||
numColumns = targetSize;
|
||||
numRows = targetSize;
|
||||
numColumns = std::max((unsigned int) (float(originalNumColumns)*sqrtf(sampleRatio)), 4u);
|
||||
numRows = std::max((unsigned int) (float(originalNumRows)*sqrtf(sampleRatio)),4u);
|
||||
|
||||
i_sampleFactor = double(originalNumColumns-1)/double(numColumns-1);
|
||||
j_sampleFactor = double(originalNumRows-1)/double(numRows-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool treatBoundariesToValidDataAsDefaultValue = _terrainTile->getTreatBoundariesToValidDataAsDefaultValue();
|
||||
osg::notify(osg::INFO)<<"TreatBoundariesToValidDataAsDefaultValue="<<treatBoundariesToValidDataAsDefaultValue<<std::endl;
|
||||
|
||||
|
@ -17,12 +17,14 @@
|
||||
using namespace osg;
|
||||
using namespace osgTerrain;
|
||||
|
||||
Terrain::Terrain()
|
||||
Terrain::Terrain():
|
||||
_sampleRatio(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
Terrain::Terrain(const Terrain& ts, const osg::CopyOp& copyop):
|
||||
osg::Group(ts,copyop)
|
||||
osg::Group(ts,copyop),
|
||||
_sampleRatio(ts._sampleRatio)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user