forked from teamnwah/openmw-tes3coop
Add a flag to specify if an animation should be playing
This commit is contained in:
parent
fdabef65a1
commit
92d0c55f32
2 changed files with 11 additions and 3 deletions
|
@ -26,6 +26,7 @@ Animation::Animation(const MWWorld::Ptr &ptr)
|
||||||
, mLastPosition(0.0f)
|
, mLastPosition(0.0f)
|
||||||
, mCurrentKeys(NULL)
|
, mCurrentKeys(NULL)
|
||||||
, mAnimState(NULL)
|
, mAnimState(NULL)
|
||||||
|
, mPlaying(false)
|
||||||
, mLooping(false)
|
, mLooping(false)
|
||||||
, mAnimSpeedMult(1.0f)
|
, mAnimSpeedMult(1.0f)
|
||||||
{
|
{
|
||||||
|
@ -187,6 +188,7 @@ void Animation::play(const std::string &groupname, const std::string &start, boo
|
||||||
mCurrentKeys = &mTextKeys[groupname];
|
mCurrentKeys = &mTextKeys[groupname];
|
||||||
mLooping = loop;
|
mLooping = loop;
|
||||||
reset(start);
|
reset(start);
|
||||||
|
mPlaying = true;
|
||||||
}
|
}
|
||||||
catch(std::exception &e) {
|
catch(std::exception &e) {
|
||||||
std::cerr<< e.what() <<std::endl;
|
std::cerr<< e.what() <<std::endl;
|
||||||
|
@ -197,12 +199,13 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
||||||
timepassed *= mAnimSpeedMult;
|
timepassed *= mAnimSpeedMult;
|
||||||
while(mAnimState && timepassed > 0.0f)
|
while(mAnimState && mPlaying && timepassed > 0.0f)
|
||||||
{
|
{
|
||||||
float targetTime = mAnimState->getTimePosition() + timepassed;
|
float targetTime = mAnimState->getTimePosition() + timepassed;
|
||||||
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
||||||
{
|
{
|
||||||
movement += updatePosition(targetTime);
|
movement += updatePosition(targetTime);
|
||||||
|
mPlaying = (targetTime < mAnimState->getLength() || mLooping);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +239,12 @@ Ogre::Vector3 Animation::runAnimation(float timepassed)
|
||||||
if(mAnimState->getTimePosition() >= time)
|
if(mAnimState->getTimePosition() >= time)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(mController)
|
else
|
||||||
mController->markerEvent(time, evt);
|
{
|
||||||
|
mPlaying = false;
|
||||||
|
if(mController)
|
||||||
|
mController->markerEvent(time, evt);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(mController)
|
if(mController)
|
||||||
|
|
|
@ -31,6 +31,7 @@ protected:
|
||||||
NifOgre::TextKeyMap *mCurrentKeys;
|
NifOgre::TextKeyMap *mCurrentKeys;
|
||||||
NifOgre::TextKeyMap::const_iterator mNextKey;
|
NifOgre::TextKeyMap::const_iterator mNextKey;
|
||||||
Ogre::AnimationState *mAnimState;
|
Ogre::AnimationState *mAnimState;
|
||||||
|
bool mPlaying;
|
||||||
bool mLooping;
|
bool mLooping;
|
||||||
|
|
||||||
float mAnimSpeedMult;
|
float mAnimSpeedMult;
|
||||||
|
|
Loading…
Reference in a new issue