Added support for boundary equalization to GeometryTechnique
This commit is contained in:
@@ -38,16 +38,7 @@ class OSGTERRAIN_EXPORT GeometryTechnique : public TerrainTechnique
|
||||
|
||||
virtual Locator* computeMasterLocator();
|
||||
|
||||
virtual osg::Vec3d computeCenterModel(Locator* masterLocator);
|
||||
|
||||
virtual void generateGeometry(Locator* masterLocator, const osg::Vec3d& centerModel);
|
||||
|
||||
virtual void applyColorLayers();
|
||||
|
||||
virtual void applyTransparency();
|
||||
|
||||
virtual void smoothGeometry();
|
||||
|
||||
virtual void update(osgUtil::UpdateVisitor* nv);
|
||||
|
||||
virtual void cull(osgUtil::CullVisitor* nv);
|
||||
@@ -86,24 +77,32 @@ class OSGTERRAIN_EXPORT GeometryTechnique : public TerrainTechnique
|
||||
|
||||
virtual ~GeometryTechnique();
|
||||
|
||||
struct BufferData
|
||||
class BufferData : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
BufferData() {}
|
||||
|
||||
osg::ref_ptr<osg::MatrixTransform> _transform;
|
||||
osg::ref_ptr<osg::Geode> _geode;
|
||||
osg::ref_ptr<osg::Geometry> _geometry;
|
||||
};
|
||||
|
||||
unsigned int _currentReadOnlyBuffer;
|
||||
unsigned int _currentWriteBuffer;
|
||||
|
||||
BufferData _bufferData[2];
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
inline BufferData& getReadOnlyBuffer() { return _bufferData[_currentReadOnlyBuffer]; }
|
||||
inline BufferData& getWriteBuffer() { return _bufferData[_currentWriteBuffer]; }
|
||||
|
||||
|
||||
protected:
|
||||
~BufferData() {}
|
||||
};
|
||||
|
||||
virtual osg::Vec3d computeCenterModel(BufferData& buffer, Locator* masterLocator);
|
||||
|
||||
virtual void generateGeometry(BufferData& buffer, Locator* masterLocator, const osg::Vec3d& centerModel);
|
||||
|
||||
virtual void applyColorLayers(BufferData& buffer);
|
||||
|
||||
virtual void applyTransparency(BufferData& buffer);
|
||||
|
||||
|
||||
OpenThreads::Mutex _writeBufferMutex;
|
||||
osg::ref_ptr<BufferData> _currentBufferData;
|
||||
osg::ref_ptr<BufferData> _newBufferData;
|
||||
|
||||
float _filterBias;
|
||||
osg::ref_ptr<osg::Uniform> _filterBiasUniform;
|
||||
float _filterWidth;
|
||||
|
||||
@@ -91,6 +91,9 @@ class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
||||
/** Get the const TerrainTechnique protype*/
|
||||
const TerrainTechnique* getTerrainTechniquePrototype() const { return _terrainTechnique.get(); }
|
||||
|
||||
/** Tell the Terrain node to call the terrainTile's TerrainTechnique on the next update traversal.*/
|
||||
void updateTerrainTileOnNextFrame(TerrainTile* terrainTile);
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Terrain();
|
||||
@@ -112,6 +115,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::Group
|
||||
mutable OpenThreads::Mutex _mutex;
|
||||
TerrainTileSet _terrainTileSet;
|
||||
TerrainTileMap _terrainTileMap;
|
||||
TerrainTileSet _updateTerrainTileSet;
|
||||
|
||||
osg::ref_ptr<TerrainTechnique> _terrainTechnique;
|
||||
};
|
||||
|
||||
@@ -25,7 +25,31 @@ namespace osgTerrain {
|
||||
|
||||
class TerrainTile;
|
||||
|
||||
class OSGTERRAIN_EXPORT TerrainTechnique : public osg::Object
|
||||
class OSGTERRAIN_EXPORT TerrainNeighbours
|
||||
{
|
||||
public:
|
||||
|
||||
TerrainNeighbours();
|
||||
~TerrainNeighbours();
|
||||
|
||||
void clear();
|
||||
void addNeighbour(TerrainTile* tile);
|
||||
void removeNeighbour(TerrainTile* tile);
|
||||
bool containsNeighbour(TerrainTile* tile) const;
|
||||
|
||||
protected:
|
||||
|
||||
TerrainNeighbours(const TerrainNeighbours& tn) {}
|
||||
TerrainNeighbours& operator = (const TerrainNeighbours& rhs) { return *this; }
|
||||
|
||||
typedef std::set<TerrainTile*> Neighbours;
|
||||
|
||||
mutable OpenThreads::Mutex _neighboursMutex;
|
||||
Neighbours _neighbours;
|
||||
};
|
||||
|
||||
|
||||
class OSGTERRAIN_EXPORT TerrainTechnique : public osg::Object, public osg::Observer
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -33,7 +57,7 @@ class OSGTERRAIN_EXPORT TerrainTechnique : public osg::Object
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
TerrainTechnique(const TerrainTechnique&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
|
||||
META_Object(osgTerrain, TerrainTechnique);
|
||||
|
||||
TerrainTile* getTerrainTile() { return _terrainTile; }
|
||||
@@ -56,15 +80,26 @@ class OSGTERRAIN_EXPORT TerrainTechnique : public osg::Object
|
||||
* for all graphics contexts. */
|
||||
virtual void releaseGLObjects(osg::State* = 0) const {}
|
||||
|
||||
void addNeighbour(TerrainTile* tile) { _neighbours.addNeighbour(tile); }
|
||||
void removeNeighbour(TerrainTile* tile) { _neighbours.removeNeighbour(tile); }
|
||||
|
||||
bool containsNeighbour(TerrainTile* tile) { return _neighbours.containsNeighbour(tile); }
|
||||
TerrainNeighbours& getNeighbours() { return _neighbours; }
|
||||
const TerrainNeighbours& getNeighbours() const { return _neighbours; }
|
||||
|
||||
protected:
|
||||
|
||||
void setDirty(bool dirty);
|
||||
|
||||
virtual ~TerrainTechnique();
|
||||
|
||||
|
||||
void setTerrainTile(TerrainTile* tile);
|
||||
void setDirty(bool dirty);
|
||||
|
||||
friend class osgTerrain::TerrainTile;
|
||||
|
||||
TerrainTile* _terrainTile;
|
||||
TerrainTile* _terrainTile;
|
||||
|
||||
|
||||
TerrainNeighbours _neighbours;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class OSGTERRAIN_EXPORT TerrainTile : public osg::Group
|
||||
public:
|
||||
|
||||
TerrainTile();
|
||||
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
TerrainTile(const TerrainTile&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
@@ -172,11 +172,32 @@ class OSGTERRAIN_EXPORT TerrainTile : public osg::Group
|
||||
BlendingPolicy getBlendingPolicy() const { return _blendingPolicy; }
|
||||
|
||||
|
||||
enum DirtyMask
|
||||
{
|
||||
NOT_DIRTY = 0,
|
||||
IMAGERY_DIRTY = 1<<0,
|
||||
ELEVATION_DIRTY = 1<<1,
|
||||
LEFT_EDGE_DIRTY = 1<<2,
|
||||
RIGHT_EDGE_DIRTY = 1<<3,
|
||||
TOP_EDGE_DIRTY = 1<<4,
|
||||
BOTTOM_EDGE_DIRTY = 1<<5,
|
||||
EDGES_DIRTY = LEFT_EDGE_DIRTY | RIGHT_EDGE_DIRTY | TOP_EDGE_DIRTY | BOTTOM_EDGE_DIRTY,
|
||||
ALL_DIRTY = IMAGERY_DIRTY | ELEVATION_DIRTY | EDGES_DIRTY
|
||||
};
|
||||
|
||||
/** Set the dirty flag on/off.*/
|
||||
void setDirty(bool dirty);
|
||||
void setDirty(bool dirty) { setDirtyMask(dirty ? ALL_DIRTY : NOT_DIRTY); }
|
||||
|
||||
/** return true if the any of the DirtyMask are set.*/
|
||||
int getDirty() const { return _dirtyMask!=NOT_DIRTY; }
|
||||
|
||||
|
||||
/** Set the dirty flag on/off.*/
|
||||
void setDirtyMask(int dirtyMask);
|
||||
|
||||
/** return true if the tile is dirty and needs to be updated,*/
|
||||
bool getDirty() const { return _dirty; }
|
||||
int getDirtyMask() const { return _dirtyMask; }
|
||||
|
||||
|
||||
/** Compute the bounding volume of the terrain by computing the union of the bounding volumes of all layers.*/
|
||||
virtual osg::BoundingSphere computeBound() const;
|
||||
@@ -207,7 +228,7 @@ class OSGTERRAIN_EXPORT TerrainTile : public osg::Group
|
||||
|
||||
Terrain* _terrain;
|
||||
|
||||
bool _dirty;
|
||||
int _dirtyMask;
|
||||
bool _hasBeenTraversal;
|
||||
|
||||
TileID _tileID;
|
||||
|
||||
Reference in New Issue
Block a user