Relaxed the handling of Image objects

This commit is contained in:
Robert Osfield 2014-03-04 13:35:27 +00:00
parent c6e72ee00b
commit 218e36b12b
2 changed files with 6 additions and 2 deletions

View File

@ -268,7 +268,9 @@ inline bool PropertyInterface::getProperty(const osg::Object* object, const std:
template<> template<>
inline bool PropertyInterface::setProperty(osg::Object* object, const std::string& propertyName, const ObjectPtr& value) inline bool PropertyInterface::setProperty(osg::Object* object, const std::string& propertyName, const ObjectPtr& value)
{ {
if (copyPropertyObjectToObject(object, propertyName, &value, sizeof(ObjectPtr), getTypeEnum<ObjectPtr>())) return true; osgDB::BaseSerializer::Type type = dynamic_cast<osg::Image*>(value) ? osgDB::BaseSerializer::RW_IMAGE : getTypeEnum<ObjectPtr>();
// osgDB::BaseSerializer::Type type = getTypeEnum<ObjectPtr>();
if (copyPropertyObjectToObject(object, propertyName, &value, sizeof(ObjectPtr), type)) return true;
else else
{ {
// fallback to using user data to store property data // fallback to using user data to store property data

View File

@ -264,6 +264,8 @@ bool PropertyInterface::areTypesCompatible(osgDB::BaseSerializer::Type lhs, osgD
if (lhs==osgDB::BaseSerializer::RW_ENUM) lhs = osgDB::BaseSerializer::RW_INT; if (lhs==osgDB::BaseSerializer::RW_ENUM) lhs = osgDB::BaseSerializer::RW_INT;
if (rhs==osgDB::BaseSerializer::RW_ENUM) rhs = osgDB::BaseSerializer::RW_INT; if (rhs==osgDB::BaseSerializer::RW_ENUM) rhs = osgDB::BaseSerializer::RW_INT;
if (lhs==osgDB::BaseSerializer::RW_IMAGE) lhs = osgDB::BaseSerializer::RW_OBJECT;
return lhs==rhs; return lhs==rhs;
} }
@ -392,7 +394,7 @@ bool PropertyInterface::copyPropertyObjectFromObject(const osg::Object* object,
osgDB::BaseSerializer* serializer = getSerializer(object, propertyName, sourceType); osgDB::BaseSerializer* serializer = getSerializer(object, propertyName, sourceType);
if (serializer) if (serializer)
{ {
if (areTypesCompatible(valueType, sourceType)) if (areTypesCompatible(sourceType, valueType))
{ {
return serializer->get(*object, valuePtr); return serializer->get(*object, valuePtr);
} }