Added support for a Terrain::s/getTerrainTechniquePrototype()
This commit is contained in:
parent
8e49efd496
commit
3ce53b56c7
@ -63,6 +63,15 @@ class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
||||
|
||||
/** Get the const TerrainTile for a given TileID.*/
|
||||
const TerrainTile* getTile(const TileID& tileID) const;
|
||||
|
||||
/** Set the TerrainTechnique cprototype from which TerrainTiles can clone the techniques from..*/
|
||||
void setTerrainTechniquePrototype(TerrainTechnique* technique);
|
||||
|
||||
/** Get the TerrainTechnique prototype */
|
||||
TerrainTechnique* getTerrainTechniquePrototype() { return _terrainTechnique.get(); }
|
||||
|
||||
/** Get the const TerrainTechnique protype*/
|
||||
const TerrainTechnique* getTerrainTechniquePrototype() const { return _terrainTechnique.get(); }
|
||||
|
||||
protected:
|
||||
|
||||
@ -85,7 +94,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
||||
TerrainTileSet _terrainTileSet;
|
||||
TerrainTileMap _terrainTileMap;
|
||||
|
||||
|
||||
osg::ref_ptr<TerrainTechnique> _terrainTechnique;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class OSGTERRAIN_EXPORT TerrainTile : public osg::Group
|
||||
|
||||
|
||||
/** Set the TerrainTechnique*/
|
||||
void setTerrainTechnique(TerrainTechnique* TerrainTechnique);
|
||||
void setTerrainTechnique(TerrainTechnique* terrainTechnique);
|
||||
|
||||
/** Get the TerrainTechnique*/
|
||||
TerrainTechnique* getTerrainTechnique() { return _terrainTechnique.get(); }
|
||||
|
@ -43,8 +43,13 @@ GeometryTechnique::GeometryTechnique():
|
||||
}
|
||||
|
||||
GeometryTechnique::GeometryTechnique(const GeometryTechnique& gt,const osg::CopyOp& copyop):
|
||||
TerrainTechnique(gt,copyop)
|
||||
TerrainTechnique(gt,copyop),
|
||||
_currentReadOnlyBuffer(1),
|
||||
_currentWriteBuffer(0)
|
||||
{
|
||||
setFilterBias(gt._filterBias);
|
||||
setFilterWidth(gt._filterWidth);
|
||||
setFilterMatrix(gt._filterMatrix);
|
||||
}
|
||||
|
||||
GeometryTechnique::~GeometryTechnique()
|
||||
|
@ -12,6 +12,8 @@
|
||||
*/
|
||||
|
||||
#include <osgTerrain/Terrain>
|
||||
#include <osgTerrain/GeometryTechnique>
|
||||
|
||||
#include <OpenThreads/ScopedLock>
|
||||
|
||||
using namespace osg;
|
||||
@ -21,12 +23,14 @@ Terrain::Terrain():
|
||||
_sampleRatio(1.0),
|
||||
_verticalScale(1.0)
|
||||
{
|
||||
_terrainTechnique = new GeometryTechnique;
|
||||
}
|
||||
|
||||
Terrain::Terrain(const Terrain& ts, const osg::CopyOp& copyop):
|
||||
osg::Group(ts,copyop),
|
||||
_sampleRatio(ts._sampleRatio),
|
||||
_verticalScale(ts._verticalScale)
|
||||
_verticalScale(ts._verticalScale),
|
||||
_terrainTechnique(ts._terrainTechnique)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <osgTerrain/TerrainTile>
|
||||
#include <osgTerrain/Terrain>
|
||||
#include <osgTerrain/GeometryTechnique>
|
||||
|
||||
#include <osg/ClusterCullingCallback>
|
||||
|
||||
@ -113,7 +114,9 @@ void TerrainTile::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
|
||||
_hasBeenTraversal = true;
|
||||
}
|
||||
|
||||
@ -138,6 +141,19 @@ void TerrainTile::traverse(osg::NodeVisitor& nv)
|
||||
|
||||
void TerrainTile::init()
|
||||
{
|
||||
if (!_terrainTechnique)
|
||||
{
|
||||
if (_terrain && _terrain->getTerrainTechniquePrototype())
|
||||
{
|
||||
osg::ref_ptr<osg::Object> object = _terrain->getTerrainTechniquePrototype()->clone(osg::CopyOp::DEEP_COPY_ALL);
|
||||
setTerrainTechnique(dynamic_cast<TerrainTechnique*>(object.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
setTerrainTechnique(new GeometryTechnique);
|
||||
}
|
||||
}
|
||||
|
||||
if (_terrainTechnique.valid() && getDirty())
|
||||
{
|
||||
_terrainTechnique->init();
|
||||
|
Loading…
Reference in New Issue
Block a user