Added support for reading and writing UserData from objects.
This commit is contained in:
@@ -59,22 +59,6 @@ bool Node_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
}
|
||||
|
||||
// if (fr.matchSequence("user_data {"))
|
||||
// {
|
||||
// notify(DEBUG) << "Matched user_data {"<< std::endl;
|
||||
// int entry = fr[0].getNoNestedBrackets();
|
||||
// fr += 2;
|
||||
//
|
||||
// while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
// {
|
||||
// Object* object = fr.readObject();
|
||||
// if (object) setUserData(object);
|
||||
// notify(DEBUG) << "read "<<object<< std::endl;
|
||||
// ++fr;
|
||||
// }
|
||||
// iteratorAdvanced = true;
|
||||
// }
|
||||
|
||||
while (fr.matchSequence("description {"))
|
||||
{
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
@@ -163,18 +147,6 @@ bool Node_writeLocalData(const Object& obj, Output& fw)
|
||||
if (node.getCullingActive()) fw << "TRUE"<< std::endl;
|
||||
else fw << "FALSE"<< std::endl;
|
||||
|
||||
// if (_userData)
|
||||
// {
|
||||
// Object* object = dynamic_cast<Object*>(_userData);
|
||||
// if (object)
|
||||
// {
|
||||
// fw.indent() << "user_data {"<< std::endl;
|
||||
// fw.moveIn();
|
||||
// object->write(fw);
|
||||
// fw.moveOut();
|
||||
// fw.indent() << "}"<< std::endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!node.getDescriptions().empty())
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "osg/Object"
|
||||
#include "osg/Notify"
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
@@ -42,6 +43,22 @@ bool Object_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr.matchSequence("UserData {"))
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO) << "Matched UserData {"<< std::endl;
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
fr += 2;
|
||||
|
||||
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
Object* object = fr.readObject();
|
||||
if (object) obj.setUserData(object);
|
||||
osg::notify(osg::DEBUG_INFO) << "read "<<object<< std::endl;
|
||||
++fr;
|
||||
}
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
return iteratorAdvanced;
|
||||
}
|
||||
|
||||
@@ -54,5 +71,18 @@ bool Object_writeLocalData(const Object& obj, Output& fw)
|
||||
default: fw.indent() << "DataVariance DYNAMIC" << std::endl;break;
|
||||
}
|
||||
|
||||
if (obj.getUserData())
|
||||
{
|
||||
const Object* object = dynamic_cast<const Object*>(obj.getUserData());
|
||||
if (object)
|
||||
{
|
||||
fw.indent() << "UserData {"<< std::endl;
|
||||
fw.moveIn();
|
||||
fw.writeObject(*object);
|
||||
fw.moveOut();
|
||||
fw.indent() << "}"<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user