Hold on to the AnimationState being used for animating

This commit is contained in:
Chris Robinson 2013-01-05 00:03:14 -08:00
parent 6e84d4bcdd
commit 818a24cdd6
2 changed files with 6 additions and 10 deletions

View File

@ -14,6 +14,7 @@ Animation::Animation()
: mInsert(NULL) : mInsert(NULL)
, mTime(0.0f) , mTime(0.0f)
, mSkipFrame(false) , mSkipFrame(false)
, mAnimState(NULL)
{ {
} }
@ -45,6 +46,8 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
Ogre::AnimationState *state = as.getNext(); Ogre::AnimationState *state = as.getNext();
state->setEnabled(true); state->setEnabled(true);
state->setLoop(false); state->setLoop(false);
if(!mAnimState)
mAnimState = state;
} }
} }
} }
@ -155,16 +158,8 @@ void Animation::runAnimation(float timepassed)
} }
} }
if(mEntityList.mSkelBase) if(mAnimState)
{ mAnimState->setTimePosition(mTime);
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements())
{
Ogre::AnimationState *state = as.getNext();
state->setTimePosition(mTime);
}
}
} }
mSkipFrame = false; mSkipFrame = false;
} }

View File

@ -40,6 +40,7 @@ protected:
NifOgre::EntityList mEntityList; NifOgre::EntityList mEntityList;
NifOgre::TextKeyMap mTextKeys; NifOgre::TextKeyMap mTextKeys;
Ogre::AnimationState *mAnimState;
bool findGroupTimes(const std::string &groupname, GroupTimes *times); bool findGroupTimes(const std::string &groupname, GroupTimes *times);