From d2aa4270ceffbe26224b82baed26bad52f8c96fe Mon Sep 17 00:00:00 2001 From: Don BURNS Date: Tue, 2 Jul 2002 06:22:28 +0000 Subject: [PATCH] Added support for CullVisitor to contain a osg::State. This used when cull Callbacks require the contextID for doing operations on texture objects, for example. Modified CullVisitor SceneView and Drawable --- include/osg/Drawable | 2 +- include/osgUtil/CullVisitor | 6 ++++++ src/osgUtil/CullVisitor.cpp | 2 +- src/osgUtil/SceneView.cpp | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/osg/Drawable b/include/osg/Drawable index f01ee00c2..4b1a0ce9d 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -185,7 +185,7 @@ class SG_EXPORT Drawable : public Object struct CullCallback : public osg::Referenced { /** do customized cull code.*/ - virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable) const = 0; + virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable, osg::State *state=NULL) const = 0; }; /** Set the CullCallback which allows users to attach customize the drawing of existing Drawable object.*/ diff --git a/include/osgUtil/CullVisitor b/include/osgUtil/CullVisitor index 9b1eb7454..038b661b2 100644 --- a/include/osgUtil/CullVisitor +++ b/include/osgUtil/CullVisitor @@ -196,6 +196,10 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac /** reimplement CullStack's popProjectionMatrix() adding clamping of the projection matrix to the computed near and far.*/ void popProjectionMatrix(); + void setState(osg::State* state) { _state = state; } + osg::State* getState() { return _state.get(); } + const osg::State* getState() const { return _state.get(); } + protected: /** prevent unwanted copy construction.*/ @@ -251,6 +255,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac inline RenderLeaf* createOrReuseRenderLeaf(osg::Drawable* drawable,osg::Matrix* projection,osg::Matrix* matrix, float depth=0.0f); osg::ref_ptr _impostorSpriteManager; + + osg::ref_ptr _state; }; diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index e2f23eb71..98a7794e3 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -257,7 +257,7 @@ void CullVisitor::apply(Geode& node) if( drawable->getCullCallback() ) { - if( drawable->getCullCallback()->cull( this, drawable ) == true ) + if( drawable->getCullCallback()->cull( this, drawable, _state.valid()?_state.get():NULL ) == true ) continue; } else diff --git a/src/osgUtil/SceneView.cpp b/src/osgUtil/SceneView.cpp index 63016b25d..b5e00a2c8 100644 --- a/src/osgUtil/SceneView.cpp +++ b/src/osgUtil/SceneView.cpp @@ -369,6 +369,8 @@ void SceneView::cullStage(osg::Matrix* projection,osg::Matrix* modelview,osgUtil cullVisitor->setRenderGraph(rendergraph); cullVisitor->setRenderStage(renderStage); + cullVisitor->setState( _state.get() ); + renderStage->reset(); // comment out reset of rendergraph since clean is more efficient.