Fixed handling of assignment of User Object's that replace existing Object with the specified propertyName.
This commit is contained in:
parent
2797e8cb7c
commit
8bbbea1274
@ -272,11 +272,24 @@ inline bool PropertyInterface::setProperty(osg::Object* object, const std::strin
|
||||
if (copyPropertyObjectToObject(object, propertyName, &value, sizeof(ObjectPtr), getTypeEnum<ObjectPtr>())) return true;
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"PropertyInterface::setProperty("<<propertyName<<", "<<value->className()<<") Adding object to UserDataContainer"<<std::endl;
|
||||
// fallback to using user data to store property data
|
||||
osg::UserDataContainer* udc = object->getOrCreateUserDataContainer();
|
||||
value->setName(propertyName);
|
||||
udc->addUserObject(value);
|
||||
unsigned int objectIndex = udc->getUserObjectIndex(propertyName);
|
||||
if (objectIndex < udc->getNumUserObjects())
|
||||
{
|
||||
const osg::Object* outgoingObject = udc->getUserObject(objectIndex);
|
||||
if (outgoingObject==value) return true;
|
||||
|
||||
OSG_NOTICE<<"PropertyInterface::setProperty("<<propertyName<<", "<<value->className()<<") replace object on UserDataContainer"<<std::endl;
|
||||
value->setName(propertyName);
|
||||
udc->setUserObject(objectIndex, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"PropertyInterface::setProperty("<<propertyName<<", "<<value->className()<<") Adding object to UserDataContainer"<<std::endl;
|
||||
value->setName(propertyName);
|
||||
udc->addUserObject(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user