1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 21:49:55 +00:00

Merge pull request #211 from OpenMW/master

Add OpenMW commits up to 5 May 2017
This commit is contained in:
David Cernat 2017-05-05 18:50:46 +03:00 committed by GitHub
commit a7b06b342f

View file

@ -81,14 +81,23 @@ namespace SceneUtil
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)
{
if (dynamic_cast<SceneUtil::Skeleton*>(toAttach.get()))
{
osg::ref_ptr<osg::Group> handle = new osg::Group;
osg::UserDataContainer* udc = toAttach->getUserDataContainer();
CopyRigVisitor copyVisitor(handle, filter);
toAttach->accept(copyVisitor);
copyVisitor.doCopy();
@ -98,13 +107,13 @@ namespace SceneUtil
osg::ref_ptr<osg::Node> newHandle = handle->getChild(0);
handle->removeChild(newHandle);
master->asGroup()->addChild(newHandle);
newHandle->setUserDataContainer(udc);
mergeUserData(toAttach->getUserDataContainer(), newHandle);
return newHandle;
}
else
{
master->asGroup()->addChild(handle);
handle->setUserDataContainer(udc);
handle->setUserDataContainer(toAttach->getUserDataContainer());
return handle;
}
}