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

Animation: do not assume the object root is a Group

This commit is contained in:
scrawl 2015-12-17 03:48:11 +01:00
parent 0731595c2b
commit 0a723ab075
2 changed files with 21 additions and 14 deletions

View file

@ -975,20 +975,27 @@ namespace MWRender
mAccumCtrl = NULL;
if (!forceskeleton)
mObjectRoot = mResourceSystem->getSceneManager()->createInstance(model, mInsert);
{
osg::ref_ptr<osg::Node> created = mResourceSystem->getSceneManager()->createInstance(model, mInsert);
mObjectRoot = created->asGroup();
if (!mObjectRoot)
{
mObjectRoot = new osg::Group;
mObjectRoot->addChild(created);
}
}
else
{
osg::ref_ptr<osg::Node> newObjectRoot = mResourceSystem->getSceneManager()->createInstance(model);
mSkeleton = dynamic_cast<SceneUtil::Skeleton*>(newObjectRoot.get());
if (!mSkeleton)
osg::ref_ptr<osg::Node> created = mResourceSystem->getSceneManager()->createInstance(model);
osg::ref_ptr<SceneUtil::Skeleton> skel = dynamic_cast<SceneUtil::Skeleton*>(created.get());
if (!skel)
{
osg::ref_ptr<SceneUtil::Skeleton> skel = new SceneUtil::Skeleton;
mSkeleton = skel.get();
skel->addChild(newObjectRoot);
newObjectRoot = skel;
skel = new SceneUtil::Skeleton;
skel->addChild(created);
}
mInsert->addChild(newObjectRoot);
mObjectRoot = newObjectRoot;
mSkeleton = skel.get();
mObjectRoot = skel;
mInsert->addChild(mObjectRoot);
}
if (previousStateset)
@ -1017,17 +1024,17 @@ namespace MWRender
osg::Group* Animation::getObjectRoot()
{
return static_cast<osg::Group*>(mObjectRoot.get());
return mObjectRoot.get();
}
osg::Group* Animation::getOrCreateObjectRoot()
{
if (mObjectRoot)
return static_cast<osg::Group*>(mObjectRoot.get());
return mObjectRoot.get();
mObjectRoot = new osg::Group;
mInsert->addChild(mObjectRoot);
return static_cast<osg::Group*>(mObjectRoot.get());
return mObjectRoot.get();
}
void Animation::addGlow(osg::ref_ptr<osg::Node> node, osg::Vec4f glowColor)

View file

@ -208,7 +208,7 @@ protected:
osg::ref_ptr<osg::Group> mInsert;
osg::ref_ptr<osg::Node> mObjectRoot;
osg::ref_ptr<osg::Group> mObjectRoot;
SceneUtil::Skeleton* mSkeleton;
// The node expected to accumulate movement during movement animations.