From Cedric Pinson, "Here a patch to be able to clone stateattribute, in order to do that i
moved the StateAttribute::Callback structure to a file StateAttributeCallback with the same behavior as NodeCallback. "
This commit is contained in:
@@ -24,6 +24,7 @@ class Image;
|
||||
class Texture;
|
||||
class StateSet;
|
||||
class StateAttribute;
|
||||
class StateAttributeCallback;
|
||||
class Uniform;
|
||||
class Node;
|
||||
class Drawable;
|
||||
@@ -32,6 +33,7 @@ class PrimitiveSet;
|
||||
class Shape;
|
||||
class NodeCallback;
|
||||
|
||||
|
||||
/** Copy Op(erator) used to control whether shallow or deep copy is used
|
||||
* during copy construction and clone operation.*/
|
||||
class OSG_EXPORT CopyOp
|
||||
@@ -53,7 +55,7 @@ class OSG_EXPORT CopyOp
|
||||
DEEP_COPY_PRIMITIVES = 1<<8,
|
||||
DEEP_COPY_SHAPES = 1<<9,
|
||||
DEEP_COPY_UNIFORMS = 1<<10,
|
||||
DEEP_COPY_NODECALLBACKS = 1<<11,
|
||||
DEEP_COPY_CALLBACKS = 1<<11,
|
||||
DEEP_COPY_ALL = 0x7FFFFFFF
|
||||
};
|
||||
|
||||
@@ -75,6 +77,7 @@ class OSG_EXPORT CopyOp
|
||||
virtual Shape* operator() (const Shape* shape) const;
|
||||
virtual Uniform* operator() (const Uniform* shape) const;
|
||||
virtual NodeCallback* operator() (const NodeCallback* nodecallback) const;
|
||||
virtual StateAttributeCallback* operator() (const StateAttributeCallback* stateattributecallback) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class OSG_EXPORT ImageSequence : public ImageStream
|
||||
|
||||
virtual void update(NodeVisitor* nv);
|
||||
|
||||
struct OSG_EXPORT UpdateCallback : public osg::StateAttribute::Callback
|
||||
struct OSG_EXPORT UpdateCallback : public osg::StateAttributeCallback
|
||||
{
|
||||
virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <osg/Export>
|
||||
#include <osg/Object>
|
||||
#include <osg/StateAttributeCallback>
|
||||
#include <osg/GL>
|
||||
|
||||
#include <typeinfo>
|
||||
@@ -190,7 +191,9 @@ class OSG_EXPORT StateAttribute : public Object
|
||||
StateAttribute();
|
||||
|
||||
StateAttribute(const StateAttribute& sa,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Object(sa,copyop) {}
|
||||
Object(sa,copyop),
|
||||
_updateCallback(copyop(sa._updateCallback.get()))
|
||||
{}
|
||||
|
||||
|
||||
/** Clone the type of an attribute, with Object* return type.
|
||||
@@ -281,37 +284,28 @@ class OSG_EXPORT StateAttribute : public Object
|
||||
// default to no black listed GLMode's associated with use of the StateAttribute.
|
||||
return true;
|
||||
}
|
||||
|
||||
struct Callback : public virtual osg::Object
|
||||
{
|
||||
Callback() {}
|
||||
|
||||
Callback(const Callback&,const CopyOp&) {}
|
||||
|
||||
META_Object(osg,Callback);
|
||||
|
||||
/** do customized update code.*/
|
||||
virtual void operator () (StateAttribute*, NodeVisitor*) {}
|
||||
};
|
||||
// provide callback for backwards compatibility.
|
||||
typedef osg::StateAttributeCallback 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(StateAttributeCallback* uc);
|
||||
|
||||
/** Get the non const UpdateCallback.*/
|
||||
Callback* getUpdateCallback() { return _updateCallback.get(); }
|
||||
StateAttributeCallback* getUpdateCallback() { return _updateCallback.get(); }
|
||||
|
||||
/** Get the const UpdateCallback.*/
|
||||
const Callback* getUpdateCallback() const { return _updateCallback.get(); }
|
||||
const StateAttributeCallback* 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(StateAttributeCallback* ec);
|
||||
|
||||
/** Get the non const EventCallback.*/
|
||||
Callback* getEventCallback() { return _eventCallback.get(); }
|
||||
StateAttributeCallback* getEventCallback() { return _eventCallback.get(); }
|
||||
|
||||
/** Get the const EventCallback.*/
|
||||
const Callback* getEventCallback() const { return _eventCallback.get(); }
|
||||
const StateAttributeCallback* getEventCallback() const { return _eventCallback.get(); }
|
||||
|
||||
|
||||
/** apply the OpenGL state attributes.
|
||||
@@ -343,8 +337,8 @@ class OSG_EXPORT StateAttribute : public Object
|
||||
ParentList _parents;
|
||||
friend class osg::StateSet;
|
||||
|
||||
ref_ptr<Callback> _updateCallback;
|
||||
ref_ptr<Callback> _eventCallback;
|
||||
ref_ptr<StateAttributeCallback> _updateCallback;
|
||||
ref_ptr<StateAttributeCallback> _eventCallback;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@ namespace osgAnimation
|
||||
virtual int link(osgAnimation::Animation* animation) = 0;
|
||||
virtual void updateLink() = 0;
|
||||
virtual const std::string& getName() const = 0;
|
||||
|
||||
virtual ~AnimationUpdateCallbackBase() {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@@ -130,7 +128,7 @@ namespace osgAnimation
|
||||
|
||||
|
||||
|
||||
class OSGANIMATION_EXPORT UpdateMaterial : public AnimationUpdateCallback<osg::StateAttribute::Callback>
|
||||
class OSGANIMATION_EXPORT UpdateMaterial : public AnimationUpdateCallback<osg::StateAttributeCallback>
|
||||
{
|
||||
protected:
|
||||
osg::ref_ptr<osgAnimation::Vec4Target> _diffuse;
|
||||
@@ -147,6 +145,7 @@ namespace osgAnimation
|
||||
void update(osg::Material& material);
|
||||
bool needLink() const;
|
||||
bool link(osgAnimation::Channel* channel);
|
||||
osgAnimation::Vec4Target* getDiffuse();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user