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
This commit is contained in:
Don BURNS
2002-07-02 06:22:28 +00:00
parent 0443d4cffa
commit d2aa4270ce
4 changed files with 10 additions and 2 deletions

View File

@@ -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.*/

View File

@@ -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<osg::ImpostorSpriteManager> _impostorSpriteManager;
osg::ref_ptr<osg::State> _state;
};

View File

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

View File

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