Refactored Callback system in osg::Node, osg::Drawable, osg::StateSet and osg::StateAttribute to use a new osg::Callback base class.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14244 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-06-05 16:26:13 +00:00
parent 35d6cb812f
commit 977ec20751
64 changed files with 590 additions and 471 deletions

View File

@@ -268,7 +268,7 @@ class OSG_EXPORT Drawable : public Node
* for all graphics contexts. */
virtual void releaseGLObjects(State* state=0) const;
struct UpdateCallback : public virtual osg::Object
struct OSG_EXPORT UpdateCallback : public virtual Callback
{
UpdateCallback() {}
@@ -276,24 +276,15 @@ class OSG_EXPORT Drawable : public Node
META_Object(osg,UpdateCallback);
/** override Callback::run() entry point to adapt to StateAttributeCallback::run(..) method.*/
virtual bool run(osg::Object* object, osg::Object* data);
/** do customized update code.*/
virtual void update(osg::NodeVisitor*, osg::Drawable*) {}
};
/** Set the UpdateCallback which allows users to attach customize the updating of an object during the update traversal. */
virtual void setUpdateCallback(UpdateCallback* ac);
/** Get the non const UpdateCallback.*/
UpdateCallback* getUpdateCallback() { return _drawableUpdateCallback.get(); }
/** Get the const UpdateCallback.*/
const UpdateCallback* getUpdateCallback() const { return _drawableUpdateCallback.get(); }
/** Return whether this Drawable has update callbacks associated with it, and therefore must be traversed.*/
bool requiresUpdateTraversal() const { return _drawableUpdateCallback.valid() || (_stateset.valid() && _stateset->requiresUpdateTraversal()); }
struct EventCallback : public virtual osg::Object
struct OSG_EXPORT EventCallback : public virtual Callback
{
EventCallback() {}
@@ -301,24 +292,14 @@ class OSG_EXPORT Drawable : public Node
META_Object(osg,EventCallback);
/** override Callback::run() entry point to adapt to StateAttributeCallback::run(..) method.*/
virtual bool run(osg::Object* object, osg::Object* data);
/** do customized Event code. */
virtual void event(osg::NodeVisitor*, osg::Drawable*) {}
};
/** Set the EventCallback which allows users to attach customize the updating of an object during the Event traversal.*/
virtual void setEventCallback(EventCallback* ac);
/** Get the non const EventCallback.*/
EventCallback* getEventCallback() { return _drawableEventCallback.get(); }
/** Get the const EventCallback.*/
const EventCallback* getEventCallback() const { return _drawableEventCallback.get(); }
/** Return whether this Drawable has event callbacks associated with it, and therefore must be traversed.*/
bool requiresEventTraversal() const { return _drawableEventCallback.valid() || (_stateset.valid() && _stateset->requiresEventTraversal()); }
struct CullCallback : public virtual osg::Object
struct CullCallback : public virtual Callback
{
CullCallback() {}
@@ -333,17 +314,6 @@ class OSG_EXPORT Drawable : public Node
virtual bool cull(osg::NodeVisitor* nv, osg::Drawable* drawable, osg::RenderInfo* renderInfo) const { return cull(nv, drawable, renderInfo? renderInfo->getState():0); }
};
/** Set the CullCallback which allows users to customize the culling of Drawable during the cull traversal.*/
virtual void setCullCallback(CullCallback* cc) { _drawableCullCallback=cc; }
/** Get the non const CullCallback.*/
CullCallback* getCullCallback() { return _drawableCullCallback.get(); }
/** Get the const CullCallback.*/
const CullCallback* getCullCallback() const { return _drawableCullCallback.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 drawImplementation() method, if the