From Konstantin Matveyev, "I've changed osg::Uniform::Callback to osg::UniformCallback.

osg::UniformCallback inherits osg::Callback now.

I don't really now if this class should be inside osgWrappers/serializers
because StateAttributeCallback is not presented there, but i've included it in the patch.


Please see archive in the attachment.


PS
DEEP_COPY_UNIFORMS works for me.
"
Note from Robert Osfield, added typedef UniformCallback Callback for backwards compatibility.



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14885 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2015-06-02 09:33:22 +00:00
parent 80791c6972
commit e3f0876e87
9 changed files with 69 additions and 32 deletions

View File

@@ -207,6 +207,26 @@ class OSG_EXPORT StateAttributeCallback : public virtual osg::Callback
virtual void operator () (StateAttribute*, NodeVisitor*) {}
};
// forward declare
class Uniform;
/** Deprecated. */
class OSG_EXPORT UniformCallback : public virtual osg::Callback
{
public:
UniformCallback() {}
UniformCallback(const UniformCallback&, const CopyOp&) {}
META_Object(osg, UniformCallback);
/** override Callback::run() entry point to adapt to UniformCallback::run(..) method.*/
virtual bool run(osg::Object* object, osg::Object* data);
/** do customized update code.*/
virtual void operator () (Uniform*, NodeVisitor*) {}
};
} // namespace

View File

@@ -26,6 +26,7 @@ class StateSet;
class StateAttribute;
class StateAttributeCallback;
class Uniform;
class UniformCallback;
class Node;
class Drawable;
class Array;
@@ -82,6 +83,7 @@ class OSG_EXPORT CopyOp
virtual Uniform* operator() (const Uniform* shape) const;
virtual Callback* operator() (const Callback* nodecallback) const;
virtual StateAttributeCallback* operator() (const StateAttributeCallback* stateattributecallback) const;
virtual UniformCallback* operator() (const UniformCallback* uniformcallback) const;
protected:

View File

@@ -21,6 +21,7 @@
#include <osg/ref_ptr>
#include <osg/Array>
#include <osg/Callback>
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
@@ -823,38 +824,28 @@ class OSG_EXPORT Uniform : public Object
bool getElement( unsigned int index, bool& b0, bool& b1 ) const;
bool getElement( unsigned int index, bool& b0, bool& b1, bool& b2 ) const;
bool getElement( unsigned int index, bool& b0, bool& b1, bool& b2, bool& b3 ) const;
struct Callback : public virtual osg::Object
{
Callback() {}
Callback(const Callback&,const CopyOp&) {}
META_Object(osg,Callback);
/** do customized update code.*/
virtual void operator () (Uniform*, NodeVisitor*) {}
};
typedef UniformCallback Callback;
/** Set the UpdateCallback which allows users to attach customize the updating of an object during the update traversal.*/
void setUpdateCallback(Callback* uc);
void setUpdateCallback(UniformCallback* uc);
/** Get the non const UpdateCallback.*/
Callback* getUpdateCallback() { return _updateCallback.get(); }
UniformCallback* getUpdateCallback() { return _updateCallback.get(); }
/** Get the const UpdateCallback.*/
const Callback* getUpdateCallback() const { return _updateCallback.get(); }
const UniformCallback* getUpdateCallback() const { return _updateCallback.get(); }
/** Set the EventCallback which allows users to attach customize the updating of an object during the Event traversal.*/
void setEventCallback(Callback* ec);
void setEventCallback(UniformCallback* ec);
/** Get the non const EventCallback.*/
Callback* getEventCallback() { return _eventCallback.get(); }
UniformCallback* getEventCallback() { return _eventCallback.get(); }
/** Get the const EventCallback.*/
const Callback* getEventCallback() const { return _eventCallback.get(); }
const UniformCallback* getEventCallback() const { return _eventCallback.get(); }
/** Increment the modified count on the Uniform so Programs watching it know it update themselves.
* NOTE: automatically called during osg::Uniform::set*();
@@ -923,8 +914,8 @@ class OSG_EXPORT Uniform : public Object
ref_ptr<IntArray> _intArray;
ref_ptr<UIntArray> _uintArray;
ref_ptr<Callback> _updateCallback;
ref_ptr<Callback> _eventCallback;
ref_ptr<UniformCallback> _updateCallback;
ref_ptr<UniformCallback> _eventCallback;
unsigned int _modifiedCount;
};