mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Cache the Animation's Skeleton
This commit is contained in:
parent
eb458bf9c8
commit
795f6d77f2
2 changed files with 9 additions and 5 deletions
|
@ -311,6 +311,7 @@ namespace MWRender
|
|||
|
||||
Animation::Animation(const MWWorld::Ptr &ptr, osg::ref_ptr<osg::Group> parentNode, Resource::ResourceSystem* resourceSystem)
|
||||
: mInsert(parentNode)
|
||||
, mSkeleton(NULL)
|
||||
, mPtr(ptr)
|
||||
, mResourceSystem(resourceSystem)
|
||||
, mAccumulate(1.f, 1.f, 0.f)
|
||||
|
@ -338,10 +339,8 @@ namespace MWRender
|
|||
|
||||
void Animation::setActive(bool active)
|
||||
{
|
||||
if (SceneUtil::Skeleton* skel = dynamic_cast<SceneUtil::Skeleton*>(mObjectRoot.get()))
|
||||
{
|
||||
skel->setActive(active);
|
||||
}
|
||||
if (mSkeleton)
|
||||
mSkeleton->setActive(active);
|
||||
}
|
||||
|
||||
void Animation::updatePtr(const MWWorld::Ptr &ptr)
|
||||
|
@ -965,6 +964,7 @@ namespace MWRender
|
|||
mObjectRoot->getParent(0)->removeChild(mObjectRoot);
|
||||
}
|
||||
mObjectRoot = NULL;
|
||||
mSkeleton = NULL;
|
||||
|
||||
mNodeMap.clear();
|
||||
mActiveControllers.clear();
|
||||
|
@ -976,9 +976,11 @@ namespace MWRender
|
|||
else
|
||||
{
|
||||
osg::ref_ptr<osg::Node> newObjectRoot = mResourceSystem->getSceneManager()->createInstance(model);
|
||||
if (!dynamic_cast<SceneUtil::Skeleton*>(newObjectRoot.get()))
|
||||
mSkeleton = dynamic_cast<SceneUtil::Skeleton*>(newObjectRoot.get());
|
||||
if (!mSkeleton)
|
||||
{
|
||||
osg::ref_ptr<SceneUtil::Skeleton> skel = new SceneUtil::Skeleton;
|
||||
mSkeleton = skel.get();
|
||||
skel->addChild(newObjectRoot);
|
||||
newObjectRoot = skel;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace NifOsg
|
|||
namespace SceneUtil
|
||||
{
|
||||
class LightSource;
|
||||
class Skeleton;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
|
@ -208,6 +209,7 @@ protected:
|
|||
osg::ref_ptr<osg::Group> mInsert;
|
||||
|
||||
osg::ref_ptr<osg::Node> mObjectRoot;
|
||||
SceneUtil::Skeleton* mSkeleton;
|
||||
|
||||
// The node expected to accumulate movement during movement animations.
|
||||
osg::ref_ptr<osg::Node> mAccumRoot;
|
||||
|
|
Loading…
Reference in a new issue