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

@@ -107,3 +107,22 @@ bool StateAttributeCallback::run(osg::Object* object, osg::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);
}
}

View File

@@ -36,6 +36,7 @@ COPY_OP( Object, DEEP_COPY_OBJECTS )
COPY_OP( StateSet, DEEP_COPY_STATESETS )
COPY_OP( Image, DEEP_COPY_IMAGES )
COPY_OP( Uniform, DEEP_COPY_UNIFORMS )
COPY_OP( UniformCallback, DEEP_COPY_CALLBACKS )
COPY_OP( StateAttributeCallback, DEEP_COPY_CALLBACKS )
COPY_OP( Drawable, DEEP_COPY_DRAWABLES )
COPY_OP( Texture, DEEP_COPY_TEXTURES )

View File

@@ -1780,7 +1780,7 @@ void StateSet::runUpdateCallbacks(osg::NodeVisitor* nv)
uitr != _uniformList.end();
++uitr)
{
Uniform::Callback* callback = uitr->second.first->getUpdateCallback();
UniformCallback* callback = uitr->second.first->getUpdateCallback();
if (callback) (*callback)(uitr->second.first.get(),nv);
}
}
@@ -1843,7 +1843,7 @@ void StateSet::runEventCallbacks(osg::NodeVisitor* nv)
uitr != _uniformList.end();
++uitr)
{
Uniform::Callback* callback = uitr->second.first->getEventCallback();
UniformCallback* callback = uitr->second.first->getEventCallback();
if (callback) (*callback)(uitr->second.first.get(),nv);
}
}

View File

@@ -45,10 +45,13 @@ Uniform::Uniform( Type type, const std::string& name, int numElements ) :
allocateDataArray();
}
Uniform::Uniform( const Uniform& rhs, const CopyOp& copyop ) :
Object(rhs,copyop), _type(rhs._type)
Uniform::Uniform(const Uniform& uniform, const CopyOp& copyop) :
Object(uniform, copyop),
_type(uniform._type),
_updateCallback(copyop(uniform._updateCallback.get())),
_eventCallback(copyop(uniform._eventCallback.get()))
{
copyData( rhs );
copyData(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.
// (For backwards compatibility, if not already configured, set the
// (For backwards compatability, if not already configured, set the
// Uniform's _numElements=1)
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;
@@ -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;

View File

@@ -214,7 +214,7 @@ bool Uniform_readLocalData(Object& obj, Input& fr)
{
//int entry = fr[0].getNoNestedBrackets();
fr += 2;
Uniform::Callback* callback = fr.readObjectOfType<Uniform::Callback>();
UniformCallback* callback = fr.readObjectOfType<UniformCallback>();
if (callback) {
uniform.setUpdateCallback(callback);
}
@@ -225,7 +225,7 @@ bool Uniform_readLocalData(Object& obj, Input& fr)
{
//int entry = fr[0].getNoNestedBrackets();
fr += 2;
Uniform::Callback* callback = fr.readObjectOfType<Uniform::Callback>();
UniformCallback* callback = fr.readObjectOfType<UniformCallback>();
if (callback) {
uniform.setEventCallback(callback);
}

View File

@@ -108,6 +108,7 @@ USE_SERIALIZER_WRAPPER(TransferFunction1D)
USE_SERIALIZER_WRAPPER(Transform)
USE_SERIALIZER_WRAPPER(TriangleMesh)
USE_SERIALIZER_WRAPPER(Uniform)
USE_SERIALIZER_WRAPPER(UniformCallback)
USE_SERIALIZER_WRAPPER(UpdateCallback)
USE_SERIALIZER_WRAPPER(UserDataContainer)
USE_SERIALIZER_WRAPPER(VertexProgram)