Added app callback to Drawable.
This commit is contained in:
@@ -161,6 +161,38 @@ class SG_EXPORT Drawable : public Object
|
||||
void compile(State& state);
|
||||
|
||||
|
||||
struct AppCallback : public osg::Referenced
|
||||
{
|
||||
/** do customized app code.*/
|
||||
virtual void app(osg::NodeVisitor *visitor, osg::Drawable* drawable) const = 0;
|
||||
};
|
||||
|
||||
/** Set the AppCallback which allows users to attach customize the undating of an object during the app traversal.*/
|
||||
void setAppCallback(AppCallback* ac);
|
||||
|
||||
/** Get the non const AppCallback.*/
|
||||
AppCallback* getAppCallback() { return _appCallback.get(); }
|
||||
|
||||
/** Get the const AppCallback.*/
|
||||
const AppCallback* getAppCallback() const { return _appCallback.get(); }
|
||||
|
||||
|
||||
struct CullCallback : public osg::Referenced
|
||||
{
|
||||
/** do customized cull code.*/
|
||||
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 culling of Drawable during the cull traversal.*/
|
||||
void setCullCallback(CullCallback* cc) { _cullCallback=cc; }
|
||||
|
||||
/** Get the non const CullCallback.*/
|
||||
CullCallback* getCullCallback() { return _cullCallback.get(); }
|
||||
|
||||
/** Get the const CullCallback.*/
|
||||
const CullCallback* getCullCallback() const { return _cullCallback.get(); }
|
||||
|
||||
|
||||
/** Callback attached to an Drawable which allows the users to customize the drawing of an exist Drawable object.
|
||||
* The draw callback is implement as a replacement to the Drawable's own drawImmediateMode() method, if the
|
||||
* the user intends to decorate the exist draw code then simple call the drawable->drawImmediateMode() from
|
||||
@@ -181,21 +213,6 @@ class SG_EXPORT Drawable : public Object
|
||||
/** Get the const DrawCallback.*/
|
||||
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, osg::State *state=NULL) const = 0;
|
||||
};
|
||||
|
||||
/** 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 CullCallback.*/
|
||||
CullCallback* getCullCallback() { return _cullCallback.get(); }
|
||||
|
||||
/** Get the const CullCallback.*/
|
||||
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,
|
||||
@@ -310,6 +327,7 @@ class SG_EXPORT Drawable : public Object
|
||||
mutable BoundingBox _bbox;
|
||||
mutable bool _bbox_computed;
|
||||
|
||||
ref_ptr<AppCallback> _appCallback;
|
||||
ref_ptr<DrawCallback> _drawCallback;
|
||||
ref_ptr<CullCallback> _cullCallback;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user