1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 10:06:42 +00:00

Fix queued animations

This commit is contained in:
Chris Robinson 2013-05-12 05:08:01 -07:00
parent 3988866ecd
commit bbb38c61cc
3 changed files with 24 additions and 9 deletions

View file

@ -338,18 +338,20 @@ void CharacterController::update(float duration, Movement &movement)
else if(rot.z < 0.0f) else if(rot.z < 0.0f)
setState(CharState_TurnLeft, true); setState(CharState_TurnLeft, true);
} }
else if(getState() != CharState_SpecialIdle) else if(mAnimQueue.size() > 0)
{ {
if(mAnimQueue.size() == 0) if(mAnimation->isPlaying(mAnimQueue.front().first) == false)
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
else
{ {
mAnimation->play(mAnimQueue.front().first, MWRender::Animation::Priority_Default,
MWRender::Animation::Group_All, false,
"start", "stop", 0.0f, mAnimQueue.front().second);
mAnimQueue.pop_front(); mAnimQueue.pop_front();
if(mAnimQueue.size() > 0)
mAnimation->play(mAnimQueue.front().first,
MWRender::Animation::Priority_Default,
MWRender::Animation::Group_All, false,
"start", "stop", 0.0f, mAnimQueue.front().second);
} }
} }
else if(getState() != CharState_SpecialIdle)
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
movement.mRotation[0] += rot.x * duration; movement.mRotation[0] += rot.x * duration;
movement.mRotation[1] += rot.y * duration; movement.mRotation[1] += rot.y * duration;
@ -387,9 +389,11 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
else else
{ {
count = std::max(count, 1); count = std::max(count, 1);
if(mode != 0 || getState() != CharState_SpecialIdle) if(mode != 0 || mAnimQueue.size() == 0)
{ {
mAnimQueue.clear(); mAnimQueue.clear();
mAnimQueue.push_back(std::make_pair(groupname, count-1));
mCharState = CharState_SpecialIdle; mCharState = CharState_SpecialIdle;
mLooping = false; mLooping = false;
mAnimation->play(groupname, MWRender::Animation::Priority_Default, mAnimation->play(groupname, MWRender::Animation::Priority_Default,
@ -398,7 +402,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
} }
else if(mode == 0) else if(mode == 0)
{ {
mAnimQueue.clear(); mAnimQueue.resize(1);
mAnimQueue.push_back(std::make_pair(groupname, count-1)); mAnimQueue.push_back(std::make_pair(groupname, count-1));
} }
} }

View file

@ -531,6 +531,14 @@ void Animation::play(const std::string &groupname, Priority priority, int groups
resetActiveGroups(); resetActiveGroups();
} }
bool Animation::isPlaying(const std::string &groupname) const
{
AnimStateMap::const_iterator state(mStates.find(groupname));
if(state != mStates.end())
return state->second.mPlaying;
return false;
}
void Animation::resetActiveGroups() void Animation::resetActiveGroups()
{ {
for(size_t grp = 0;grp < sNumGroups;grp++) for(size_t grp = 0;grp < sNumGroups;grp++)

View file

@ -177,6 +177,9 @@ public:
const std::string &start, const std::string &stop, const std::string &start, const std::string &stop,
float startpoint, size_t loops); float startpoint, size_t loops);
/** Returns true if the named animation group is playing. */
bool isPlaying(const std::string &groupname) const;
/** Gets info about the given animation group. /** Gets info about the given animation group.
* \param groupname Animation group to check. * \param groupname Animation group to check.
* \param complete Stores completion amount (0 = at start key, 0.5 = half way between start and stop keys), etc. * \param complete Stores completion amount (0 = at start key, 0.5 = half way between start and stop keys), etc.