mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Fix commit 8f71b65d38f (don't overwrite the previous user data)
This resulted in a crash/corruption because the KeyframeController, for performance reasons, does not check that the expected user data is there and of correct type. (Fixes #3829)
This commit is contained in:
parent
a2e863e7dd
commit
8d84869432
@ -81,14 +81,23 @@ namespace SceneUtil
|
|||||||
std::string mFilter2;
|
std::string mFilter2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void mergeUserData(osg::UserDataContainer* source, osg::Object* target)
|
||||||
|
{
|
||||||
|
if (!target->getUserDataContainer())
|
||||||
|
target->setUserDataContainer(source);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (unsigned int i=0; i<source->getNumUserObjects(); ++i)
|
||||||
|
target->getUserDataContainer()->addUserObject(source->getUserObject(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> attach(osg::ref_ptr<osg::Node> toAttach, osg::Node *master, const std::string &filter, osg::Group* attachNode)
|
osg::ref_ptr<osg::Node> attach(osg::ref_ptr<osg::Node> toAttach, osg::Node *master, const std::string &filter, osg::Group* attachNode)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<SceneUtil::Skeleton*>(toAttach.get()))
|
if (dynamic_cast<SceneUtil::Skeleton*>(toAttach.get()))
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Group> handle = new osg::Group;
|
osg::ref_ptr<osg::Group> handle = new osg::Group;
|
||||||
|
|
||||||
osg::UserDataContainer* udc = toAttach->getUserDataContainer();
|
|
||||||
|
|
||||||
CopyRigVisitor copyVisitor(handle, filter);
|
CopyRigVisitor copyVisitor(handle, filter);
|
||||||
toAttach->accept(copyVisitor);
|
toAttach->accept(copyVisitor);
|
||||||
copyVisitor.doCopy();
|
copyVisitor.doCopy();
|
||||||
@ -98,13 +107,13 @@ namespace SceneUtil
|
|||||||
osg::ref_ptr<osg::Node> newHandle = handle->getChild(0);
|
osg::ref_ptr<osg::Node> newHandle = handle->getChild(0);
|
||||||
handle->removeChild(newHandle);
|
handle->removeChild(newHandle);
|
||||||
master->asGroup()->addChild(newHandle);
|
master->asGroup()->addChild(newHandle);
|
||||||
newHandle->setUserDataContainer(udc);
|
mergeUserData(toAttach->getUserDataContainer(), newHandle);
|
||||||
return newHandle;
|
return newHandle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
master->asGroup()->addChild(handle);
|
master->asGroup()->addChild(handle);
|
||||||
handle->setUserDataContainer(udc);
|
handle->setUserDataContainer(toAttach->getUserDataContainer());
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user