Improved support for setting/getting properties via the osg::UserDataContainer.

This commit is contained in:
Robert Osfield
2014-02-11 18:07:37 +00:00
parent e3a003a08f
commit 2797e8cb7c
4 changed files with 60 additions and 8 deletions

View File

@@ -292,7 +292,18 @@ osgDB::BaseSerializer* PropertyInterface::getSerializer(const osg::Object* objec
osg::Object* PropertyInterface::createObject(const std::string& compoundClassName) const
{
osgDB::ObjectWrapper* ow = osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper(compoundClassName);
return (ow!=0) ? ow->createInstance() : 0;
if (ow)
{
osg::Object* object = ow->createInstance();
OSG_NOTICE<<"PropertyInterface::createObject("<<compoundClassName<<"), wrapper found, created object="<<object<<std::endl;
return object;
}
else
{
OSG_NOTICE<<"PropertyInterface::createObject("<<compoundClassName<<"), No object wrapper avaiable."<<std::endl;
return 0;
}
// return (ow!=0) ? ow->createInstance() : 0;
}
bool PropertyInterface::copyPropertyDataFromObject(const osg::Object* object, const std::string& propertyName, void* valuePtr, unsigned int valueSize, osgDB::BaseSerializer::Type valueType)
@@ -366,7 +377,7 @@ bool PropertyInterface::copyPropertyDataToObject(osg::Object* object, const std:
}
else
{
OSG_INFO<<"PropertyInterface::copyPropertyDataFromObject() no serializer available."<<std::endl;
OSG_NOTICE<<"PropertyInterface::copyPropertyDataFromObject() no serializer available."<<std::endl;
return false;
}
}
@@ -389,7 +400,7 @@ bool PropertyInterface::copyPropertyObjectFromObject(const osg::Object* object,
}
else
{
OSG_INFO<<"PropertyInterface::copyPropertyObjectFromObject() no serializer available."<<std::endl;
OSG_NOTICE<<"PropertyInterface::copyPropertyObjectFromObject() no serializer available."<<std::endl;
return false;
}
}

View File

@@ -537,6 +537,8 @@ public:
int LuaScriptEngine::pushPropertyToStack(osg::Object* object, const std::string& propertyName) const
{
OSG_NOTICE<<"LuaScriptEngine::pushPropertyToStack("<<object<<", "<<propertyName<<")"<<std::endl;
osgDB::BaseSerializer::Type type;
if (!_pi.getPropertyType(object, propertyName, type))
{
@@ -549,15 +551,20 @@ int LuaScriptEngine::pushPropertyToStack(osg::Object* object, const std::string&
return 1;
}
osg::CallbackObject* co = osg::getCallbackObject(object, propertyName);
LuaCallbackObject* lco = dynamic_cast<LuaCallbackObject*>(co);
osg::Object* uo = osg::getUserObject(object, propertyName);
LuaCallbackObject* lco = dynamic_cast<LuaCallbackObject*>(uo);
if (lco)
{
lua_rawgeti(_lua, LUA_REGISTRYINDEX, lco->getRef());
return 1;
}
else if (uo)
{
pushObject(uo);
return 1;
}
OSG_INFO<<"LuaScriptEngine::pushPropertyToStack("<<object<<", "<<propertyName<<") no property found."<<std::endl;
OSG_NOTICE<<"LuaScriptEngine::pushPropertyToStack("<<object<<", "<<propertyName<<") no property found."<<std::endl;
return 0;
}