Improved the mapping of update and cull traversal

This commit is contained in:
Robert Osfield
2007-07-05 18:30:20 +00:00
parent 0434d29ad4
commit 601217025f
4 changed files with 64 additions and 6 deletions

View File

@@ -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<osg::OperationsThread> _operationsThread;
typedef std::vector< osg::observer_ptr<osg::GraphicsContext> > CompileGraphicsContexts;
CompileGraphicsContexts _compileGraphicsContexts;
};
}

View File

@@ -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()

View File

@@ -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;

View File

@@ -40,14 +40,16 @@ void TerrainTechnique::init()
_dirty = false;
}
void TerrainTechnique::update(osgUtil::UpdateVisitor*)
void TerrainTechnique::update(osgUtil::UpdateVisitor* uv)
{
osg::notify(osg::NOTICE)<<className()<<"::update(..) not implementated yet"<<std::endl;
if (_terrainNode) _terrainNode->osg::Group::traverse(*uv);
}
void TerrainTechnique::cull(osgUtil::CullVisitor*)
void TerrainTechnique::cull(osgUtil::CullVisitor* cv)
{
osg::notify(osg::NOTICE)<<className()<<"::cull(..) not implementated yet"<<std::endl;
if (_terrainNode) _terrainNode->osg::Group::traverse(*cv);
}
void TerrainTechnique::cleanSceneGraph()