1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGTERRAIN_TERRAINTECHNIQUE
15#define OSGTERRAIN_TERRAINTECHNIQUE 1
19#include <osgUtil/UpdateVisitor>
20#include <osgUtil/CullVisitor>
22#include <osgTerrain/Export>
28class OSGTERRAIN_EXPORT TerrainNeighbours
36 void addNeighbour(TerrainTile* tile);
37 void removeNeighbour(TerrainTile* tile);
38 bool containsNeighbour(TerrainTile* tile) const;
42 TerrainNeighbours(const TerrainNeighbours& /*tn*/) {}
43 TerrainNeighbours& operator = (const TerrainNeighbours& /*rhs*/) { return *this; }
45 typedef std::set<TerrainTile*> Neighbours;
47 mutable OpenThreads::Mutex _neighboursMutex;
48 Neighbours _neighbours;
52class OSGTERRAIN_EXPORT TerrainTechnique : public osg::Object, public osg::Observer
58 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
59 TerrainTechnique(const TerrainTechnique&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
61 META_Object(osgTerrain, TerrainTechnique);
63 virtual void setTerrainTile(TerrainTile* tile);
64 TerrainTile* getTerrainTile() { return _terrainTile; }
65 const TerrainTile* getTerrainTile() const { return _terrainTile; }
67 virtual void init(int dirtyMask, bool assumeMultiThreaded);
69 virtual void update(osgUtil::UpdateVisitor* nv);
71 virtual void cull(osgUtil::CullVisitor* nv);
73 /** Clean scene graph from any terrain technique specific nodes.*/
74 virtual void cleanSceneGraph();
76 /** Traverse the terrain subgraph.*/
77 virtual void traverse(osg::NodeVisitor& nv);
79 /** If State is non-zero, this function releases any associated OpenGL objects for
80 * the specified graphics context. Otherwise, releases OpenGL objects
81 * for all graphics contexts. */
82 virtual void releaseGLObjects(osg::State* = 0) const {}
84 virtual void addNeighbour(TerrainTile* tile) { _neighbours.addNeighbour(tile); }
85 virtual void removeNeighbour(TerrainTile* tile) { _neighbours.removeNeighbour(tile); }
86 virtual bool containsNeighbour(TerrainTile* tile) { return _neighbours.containsNeighbour(tile); }
91 virtual ~TerrainTechnique();
93 friend class osgTerrain::TerrainTile;
95 TerrainTile* _terrainTile;
98 TerrainNeighbours _neighbours;