From John Ivar Haugland, "I have added the serializer for UserData in osg::Object. See the attached modified file:
src\osgWrappers\serializers\osg\Object.cpp"
This commit is contained in:
@@ -3,6 +3,29 @@
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
static bool checkUserData( const osg::Object& obj )
|
||||
{
|
||||
return (obj.getUserData() && dynamic_cast<const osg::Object*>(obj.getUserData()));
|
||||
}
|
||||
|
||||
static bool readUserData( osgDB::InputStream& is, osg::Object& obj )
|
||||
{
|
||||
is >> osgDB::BEGIN_BRACKET;
|
||||
osg::Object* object = is.readObject();
|
||||
if(object) obj.setUserData(object);
|
||||
is >> osgDB::END_BRACKET;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool writeUserData( osgDB::OutputStream& os, const osg::Object& obj )
|
||||
{
|
||||
os << osgDB::BEGIN_BRACKET << std::endl;
|
||||
os.writeObject(dynamic_cast<const osg::Object*>(obj.getUserData()));
|
||||
os << osgDB::END_BRACKET << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( Object,
|
||||
/*new osg::Object*/NULL,
|
||||
osg::Object,
|
||||
@@ -15,4 +38,6 @@ REGISTER_OBJECT_WRAPPER( Object,
|
||||
ADD_ENUM_VALUE( DYNAMIC );
|
||||
ADD_ENUM_VALUE( UNSPECIFIED );
|
||||
END_ENUM_SERIALIZER(); // _dataVariance
|
||||
|
||||
ADD_USER_SERIALIZER( UserData ); // _userData
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user