Fixed DrawCallback in Drawable and added CullCallback to Drawable

Cull Visitor now checks for a Drawable's CullCallback and calls it
if it exists.  It then prunes based on the return value (bool) of the
cull callback.
This commit is contained in:
Don BURNS
2002-03-13 22:44:22 +00:00
parent bc30edb9e6
commit d0ee300405
4 changed files with 32 additions and 4 deletions

View File

@@ -10,6 +10,7 @@
#include <osg/State>
#include <osg/Types>
#include <osg/Vec2>
#include <osg/NodeVisitor>
#include <vector>
#include <map>
@@ -168,7 +169,7 @@ class SG_EXPORT Drawable : public Object
struct DrawCallback : public osg::Referenced
{
/** do customized draw code.*/
virtual void drawImmediateMode(State& state,osg::Drawable* drawable) const;
virtual void drawImmediateMode(State& state,osg::Drawable* drawable) const = 0;
};
friend struct osg::Drawable::DrawCallback;
@@ -182,6 +183,23 @@ class SG_EXPORT Drawable : public Object
/** Get the const ComputerTransfromCallback.*/
const DrawCallback* getDrawCallback() const { return _drawCallback.get(); }
struct CullCallback : public osg::Referenced
{
/** do customized cull code.*/
virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable) = 0;
};
friend struct osg::Drawable::CullCallback;
/** Set the CullCallback which allows users to attach customize the drawing of existing Drawable object.*/
void setCullCallback(CullCallback* cc) { _cullCallback=cc; }
/** Get the non const ComputerTransfromCallback.*/
CullCallback* getCullCallback() { return _cullCallback.get(); }
/** Get the const ComputerTransfromCallback.*/
const CullCallback* getCullCallback() const { return _cullCallback.get(); }
/** draw directly ignoring an OpenGL display list which could be attached.
* This is the internal draw method which does the drawing itself,
@@ -277,6 +295,7 @@ class SG_EXPORT Drawable : public Object
mutable bool _bbox_computed;
ref_ptr<DrawCallback> _drawCallback;
ref_ptr<CullCallback> _cullCallback;
// static cache of deleted display lists which can only
// by completely deleted once the appropriate OpenGL context