diff --git a/include/osgTerrain/TerrainNode b/include/osgTerrain/TerrainNode index ba59756c6..25f6b19eb 100644 --- a/include/osgTerrain/TerrainNode +++ b/include/osgTerrain/TerrainNode @@ -121,6 +121,23 @@ class OSGTERRAIN_EXPORT TerrainNode : public osg::Group bool getTreatBoundariesToValidDataAsDefaultValue() const { return _treatBoundariesToValidDataAsDefaultValue; } + /** Set an OperationsThread to do an data initialization and update work.*/ + void setOperationsThread(osg::OperationsThread* operationsThread) { _operationsThread = operationsThread; } + + /** Get the OperationsThread if one is attached, return NULL otherwise.*/ + osg::OperationsThread* getOperationsThread() { return _operationsThread.get(); } + + /** Get the const OperationsThread if one is attached, return NULL otherwise.*/ + const osg::OperationsThread* getOperationsThread() const { return _operationsThread.get(); } + + + /** Add a graphics context that should be used to compile/delete OpenGL objects.*/ + void addCompileGraphicsContext(osg::GraphicsContext* gc); + + /** Removed a graphics context that should be used to compile/delete OpenGL objects.*/ + void removeCompileGraphicsContext(osg::GraphicsContext* gc); + + /** Compute the bounding volume of the terrain by computing the union of the bounding volumes of all layers.*/ virtual osg::BoundingSphere computeBound() const; @@ -162,6 +179,11 @@ class OSGTERRAIN_EXPORT TerrainNode : public osg::Group bool _requiresNormals; bool _treatBoundariesToValidDataAsDefaultValue; + + osg::ref_ptr _operationsThread; + + typedef std::vector< osg::observer_ptr > CompileGraphicsContexts; + CompileGraphicsContexts _compileGraphicsContexts; }; } diff --git a/src/osgTerrain/GeometryTechnique.cpp b/src/osgTerrain/GeometryTechnique.cpp index f83a8a4f7..eab716378 100644 --- a/src/osgTerrain/GeometryTechnique.cpp +++ b/src/osgTerrain/GeometryTechnique.cpp @@ -531,18 +531,22 @@ void GeometryTechnique::init() } -void GeometryTechnique::update(osgUtil::UpdateVisitor* nv) +void GeometryTechnique::update(osgUtil::UpdateVisitor* uv) { - + if (_terrainNode) _terrainNode->osg::Group::traverse(*uv); } -void GeometryTechnique::cull(osgUtil::CullVisitor* nv) +void GeometryTechnique::cull(osgUtil::CullVisitor* cv) { +#if 0 + if (_terrainNode) _terrainNode->osg::Group::traverse(*cv); +#else if (_transform.valid()) { - _transform->accept(*nv); + _transform->accept(*cv); } +#endif } void GeometryTechnique::cleanSceneGraph() diff --git a/src/osgTerrain/TerrainNode.cpp b/src/osgTerrain/TerrainNode.cpp index 11f7d62ee..4ccecfbaa 100644 --- a/src/osgTerrain/TerrainNode.cpp +++ b/src/osgTerrain/TerrainNode.cpp @@ -99,6 +99,36 @@ void TerrainNode::setColorFilter(unsigned int i, Filter filter) _colorLayers[i].filter = filter; } +void TerrainNode::addCompileGraphicsContext(osg::GraphicsContext* gc) +{ + for(CompileGraphicsContexts::iterator itr = _compileGraphicsContexts.begin(); + itr != _compileGraphicsContexts.end(); + ++itr) + { + if (*itr == gc) + { + return; + } + } + + _compileGraphicsContexts.push_back(gc); +} + +void TerrainNode::removeCompileGraphicsContext(osg::GraphicsContext* gc) +{ + for(CompileGraphicsContexts::iterator itr = _compileGraphicsContexts.begin(); + itr != _compileGraphicsContexts.end(); + ++itr) + { + if (*itr == gc) + { + _compileGraphicsContexts.erase(itr); + return; + } + } +} + + osg::BoundingSphere TerrainNode::computeBound() const { osg::BoundingSphere bs; diff --git a/src/osgTerrain/TerrainTechnique.cpp b/src/osgTerrain/TerrainTechnique.cpp index bc3481540..8c0536222 100644 --- a/src/osgTerrain/TerrainTechnique.cpp +++ b/src/osgTerrain/TerrainTechnique.cpp @@ -40,14 +40,16 @@ void TerrainTechnique::init() _dirty = false; } -void TerrainTechnique::update(osgUtil::UpdateVisitor*) +void TerrainTechnique::update(osgUtil::UpdateVisitor* uv) { osg::notify(osg::NOTICE)<osg::Group::traverse(*uv); } -void TerrainTechnique::cull(osgUtil::CullVisitor*) +void TerrainTechnique::cull(osgUtil::CullVisitor* cv) { osg::notify(osg::NOTICE)<osg::Group::traverse(*cv); } void TerrainTechnique::cleanSceneGraph()