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:
parent
80791c6972
commit
e3f0876e87
@ -207,6 +207,26 @@ class OSG_EXPORT StateAttributeCallback : public virtual osg::Callback
|
|||||||
virtual void operator () (StateAttribute*, NodeVisitor*) {}
|
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
|
} // namespace
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ class StateSet;
|
|||||||
class StateAttribute;
|
class StateAttribute;
|
||||||
class StateAttributeCallback;
|
class StateAttributeCallback;
|
||||||
class Uniform;
|
class Uniform;
|
||||||
|
class UniformCallback;
|
||||||
class Node;
|
class Node;
|
||||||
class Drawable;
|
class Drawable;
|
||||||
class Array;
|
class Array;
|
||||||
@ -82,6 +83,7 @@ class OSG_EXPORT CopyOp
|
|||||||
virtual Uniform* operator() (const Uniform* shape) const;
|
virtual Uniform* operator() (const Uniform* shape) const;
|
||||||
virtual Callback* operator() (const Callback* nodecallback) const;
|
virtual Callback* operator() (const Callback* nodecallback) const;
|
||||||
virtual StateAttributeCallback* operator() (const StateAttributeCallback* stateattributecallback) const;
|
virtual StateAttributeCallback* operator() (const StateAttributeCallback* stateattributecallback) const;
|
||||||
|
virtual UniformCallback* operator() (const UniformCallback* uniformcallback) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <osg/Array>
|
#include <osg/Array>
|
||||||
|
#include <osg/Callback>
|
||||||
#include <osg/Vec2>
|
#include <osg/Vec2>
|
||||||
#include <osg/Vec3>
|
#include <osg/Vec3>
|
||||||
#include <osg/Vec4>
|
#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 ) const;
|
||||||
bool getElement( unsigned int index, bool& b0, bool& b1, bool& b2 ) 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;
|
bool getElement( unsigned int index, bool& b0, bool& b1, bool& b2, bool& b3 ) const;
|
||||||
|
|
||||||
|
|
||||||
struct Callback : public virtual osg::Object
|
typedef UniformCallback Callback;
|
||||||
{
|
|
||||||
Callback() {}
|
|
||||||
|
|
||||||
Callback(const Callback&,const CopyOp&) {}
|
|
||||||
|
|
||||||
META_Object(osg,Callback);
|
|
||||||
|
|
||||||
/** do customized update code.*/
|
|
||||||
virtual void operator () (Uniform*, NodeVisitor*) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Set the UpdateCallback which allows users to attach customize the updating of an object during the update traversal.*/
|
/** 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.*/
|
/** Get the non const UpdateCallback.*/
|
||||||
Callback* getUpdateCallback() { return _updateCallback.get(); }
|
UniformCallback* getUpdateCallback() { return _updateCallback.get(); }
|
||||||
|
|
||||||
/** Get the const UpdateCallback.*/
|
/** 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.*/
|
/** 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.*/
|
/** Get the non const EventCallback.*/
|
||||||
Callback* getEventCallback() { return _eventCallback.get(); }
|
UniformCallback* getEventCallback() { return _eventCallback.get(); }
|
||||||
|
|
||||||
/** Get the const EventCallback.*/
|
/** 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.
|
/** Increment the modified count on the Uniform so Programs watching it know it update themselves.
|
||||||
* NOTE: automatically called during osg::Uniform::set*();
|
* NOTE: automatically called during osg::Uniform::set*();
|
||||||
@ -923,8 +914,8 @@ class OSG_EXPORT Uniform : public Object
|
|||||||
ref_ptr<IntArray> _intArray;
|
ref_ptr<IntArray> _intArray;
|
||||||
ref_ptr<UIntArray> _uintArray;
|
ref_ptr<UIntArray> _uintArray;
|
||||||
|
|
||||||
ref_ptr<Callback> _updateCallback;
|
ref_ptr<UniformCallback> _updateCallback;
|
||||||
ref_ptr<Callback> _eventCallback;
|
ref_ptr<UniformCallback> _eventCallback;
|
||||||
|
|
||||||
unsigned int _modifiedCount;
|
unsigned int _modifiedCount;
|
||||||
};
|
};
|
||||||
|
@ -107,3 +107,22 @@ bool StateAttributeCallback::run(osg::Object* object, osg::Object* data)
|
|||||||
return traverse(object, data);
|
return traverse(object, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// UniformCallback
|
||||||
|
//
|
||||||
|
bool UniformCallback::run(osg::Object* object, osg::Object* data)
|
||||||
|
{
|
||||||
|
osg::Uniform* uniform = dynamic_cast<osg::Uniform*>(object);
|
||||||
|
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||||
|
if (uniform && nv)
|
||||||
|
{
|
||||||
|
operator()(uniform, nv);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return traverse(object, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -36,6 +36,7 @@ COPY_OP( Object, DEEP_COPY_OBJECTS )
|
|||||||
COPY_OP( StateSet, DEEP_COPY_STATESETS )
|
COPY_OP( StateSet, DEEP_COPY_STATESETS )
|
||||||
COPY_OP( Image, DEEP_COPY_IMAGES )
|
COPY_OP( Image, DEEP_COPY_IMAGES )
|
||||||
COPY_OP( Uniform, DEEP_COPY_UNIFORMS )
|
COPY_OP( Uniform, DEEP_COPY_UNIFORMS )
|
||||||
|
COPY_OP( UniformCallback, DEEP_COPY_CALLBACKS )
|
||||||
COPY_OP( StateAttributeCallback, DEEP_COPY_CALLBACKS )
|
COPY_OP( StateAttributeCallback, DEEP_COPY_CALLBACKS )
|
||||||
COPY_OP( Drawable, DEEP_COPY_DRAWABLES )
|
COPY_OP( Drawable, DEEP_COPY_DRAWABLES )
|
||||||
COPY_OP( Texture, DEEP_COPY_TEXTURES )
|
COPY_OP( Texture, DEEP_COPY_TEXTURES )
|
||||||
|
@ -1780,7 +1780,7 @@ void StateSet::runUpdateCallbacks(osg::NodeVisitor* nv)
|
|||||||
uitr != _uniformList.end();
|
uitr != _uniformList.end();
|
||||||
++uitr)
|
++uitr)
|
||||||
{
|
{
|
||||||
Uniform::Callback* callback = uitr->second.first->getUpdateCallback();
|
UniformCallback* callback = uitr->second.first->getUpdateCallback();
|
||||||
if (callback) (*callback)(uitr->second.first.get(),nv);
|
if (callback) (*callback)(uitr->second.first.get(),nv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1843,7 +1843,7 @@ void StateSet::runEventCallbacks(osg::NodeVisitor* nv)
|
|||||||
uitr != _uniformList.end();
|
uitr != _uniformList.end();
|
||||||
++uitr)
|
++uitr)
|
||||||
{
|
{
|
||||||
Uniform::Callback* callback = uitr->second.first->getEventCallback();
|
UniformCallback* callback = uitr->second.first->getEventCallback();
|
||||||
if (callback) (*callback)(uitr->second.first.get(),nv);
|
if (callback) (*callback)(uitr->second.first.get(),nv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,13 @@ Uniform::Uniform( Type type, const std::string& name, int numElements ) :
|
|||||||
allocateDataArray();
|
allocateDataArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
Uniform::Uniform( const Uniform& rhs, const CopyOp& copyop ) :
|
Uniform::Uniform(const Uniform& uniform, const CopyOp& copyop) :
|
||||||
Object(rhs,copyop), _type(rhs._type)
|
Object(uniform, copyop),
|
||||||
|
_type(uniform._type),
|
||||||
|
_updateCallback(copyop(uniform._updateCallback.get())),
|
||||||
|
_eventCallback(copyop(uniform._eventCallback.get()))
|
||||||
{
|
{
|
||||||
copyData( rhs );
|
copyData(uniform);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uniform::~Uniform()
|
Uniform::~Uniform()
|
||||||
@ -1298,7 +1301,7 @@ Uniform::Uniform( const char* name, bool b0, bool b1, bool b2, bool b3 ) :
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Value assignment for single-element (ie: non-array) uniforms.
|
// Value assignment for single-element (ie: non-array) uniforms.
|
||||||
// (For backwards compatibility, if not already configured, set the
|
// (For backwards compatability, if not already configured, set the
|
||||||
// Uniform's _numElements=1)
|
// Uniform's _numElements=1)
|
||||||
|
|
||||||
bool Uniform::set( float f )
|
bool Uniform::set( float f )
|
||||||
@ -2607,7 +2610,7 @@ void Uniform::apply(const GLExtensions* ext, GLint location) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uniform::setUpdateCallback(Callback* uc)
|
void Uniform::setUpdateCallback(UniformCallback* uc)
|
||||||
{
|
{
|
||||||
OSG_INFO<<"Uniform::Setting Update callbacks"<<std::endl;
|
OSG_INFO<<"Uniform::Setting Update callbacks"<<std::endl;
|
||||||
|
|
||||||
@ -2633,7 +2636,7 @@ void Uniform::setUpdateCallback(Callback* uc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uniform::setEventCallback(Callback* ec)
|
void Uniform::setEventCallback(UniformCallback* ec)
|
||||||
{
|
{
|
||||||
OSG_INFO<<"Uniform::Setting Event callbacks"<<std::endl;
|
OSG_INFO<<"Uniform::Setting Event callbacks"<<std::endl;
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ bool Uniform_readLocalData(Object& obj, Input& fr)
|
|||||||
{
|
{
|
||||||
//int entry = fr[0].getNoNestedBrackets();
|
//int entry = fr[0].getNoNestedBrackets();
|
||||||
fr += 2;
|
fr += 2;
|
||||||
Uniform::Callback* callback = fr.readObjectOfType<Uniform::Callback>();
|
UniformCallback* callback = fr.readObjectOfType<UniformCallback>();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
uniform.setUpdateCallback(callback);
|
uniform.setUpdateCallback(callback);
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ bool Uniform_readLocalData(Object& obj, Input& fr)
|
|||||||
{
|
{
|
||||||
//int entry = fr[0].getNoNestedBrackets();
|
//int entry = fr[0].getNoNestedBrackets();
|
||||||
fr += 2;
|
fr += 2;
|
||||||
Uniform::Callback* callback = fr.readObjectOfType<Uniform::Callback>();
|
UniformCallback* callback = fr.readObjectOfType<UniformCallback>();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
uniform.setEventCallback(callback);
|
uniform.setEventCallback(callback);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ USE_SERIALIZER_WRAPPER(TransferFunction1D)
|
|||||||
USE_SERIALIZER_WRAPPER(Transform)
|
USE_SERIALIZER_WRAPPER(Transform)
|
||||||
USE_SERIALIZER_WRAPPER(TriangleMesh)
|
USE_SERIALIZER_WRAPPER(TriangleMesh)
|
||||||
USE_SERIALIZER_WRAPPER(Uniform)
|
USE_SERIALIZER_WRAPPER(Uniform)
|
||||||
|
USE_SERIALIZER_WRAPPER(UniformCallback)
|
||||||
USE_SERIALIZER_WRAPPER(UpdateCallback)
|
USE_SERIALIZER_WRAPPER(UpdateCallback)
|
||||||
USE_SERIALIZER_WRAPPER(UserDataContainer)
|
USE_SERIALIZER_WRAPPER(UserDataContainer)
|
||||||
USE_SERIALIZER_WRAPPER(VertexProgram)
|
USE_SERIALIZER_WRAPPER(VertexProgram)
|
||||||
|
Loading…
Reference in New Issue
Block a user