mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-05 09:41:38 +00:00
Rewrite CharacterController::updateAnimQueue() to properly maintain the animation queue and clean up finished animations.
This commit is contained in:
parent
50f3b81096
commit
cdb325f19a
1 changed files with 26 additions and 4 deletions
|
@ -1852,17 +1852,39 @@ namespace MWMechanics
|
|||
|
||||
void CharacterController::updateAnimQueue()
|
||||
{
|
||||
if (mAnimQueue.size() > 1)
|
||||
{
|
||||
if (mAnimQueue.empty())
|
||||
return;
|
||||
|
||||
if (mAnimation->isPlaying(mAnimQueue.front().mGroup) == false)
|
||||
{
|
||||
if (mAnimQueue.size() > 1)
|
||||
{
|
||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||
mAnimQueue.pop_front();
|
||||
|
||||
bool loopfallback = mAnimQueue.front().mGroup.starts_with("idle");
|
||||
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default, MWRender::Animation::BlendMask_All, false,
|
||||
1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount, loopfallback);
|
||||
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default, MWRender::Animation::BlendMask_All,
|
||||
false, 1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount, loopfallback);
|
||||
}
|
||||
else if (mAnimQueue.front().mLoopCount > 1 && mAnimQueue.front().mPersist)
|
||||
{
|
||||
// The last animation stopped playing when it shouldn't have.
|
||||
// This is caused by a rebuild of the animation object, so we should restart the animation here
|
||||
// Subtract 1 from mLoopCount to consider the current loop done.
|
||||
bool loopfallback = mAnimQueue.front().mGroup.starts_with("idle");
|
||||
mAnimation->play(mAnimQueue.front().mGroup, Priority_Persistent, MWRender::Animation::BlendMask_All,
|
||||
false, 1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount - 1, loopfallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Animation is done, remove it from the queue.
|
||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||
mAnimQueue.pop_front();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mAnimQueue.front().mLoopCount = mAnimation->getCurrentLoopCount(mAnimQueue.front().mGroup);
|
||||
}
|
||||
|
||||
if (!mAnimQueue.empty())
|
||||
|
|
Loading…
Reference in a new issue