mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-29 11:06:50 +00:00
Make 'PlayGroup idle' to cancel scripted animations
This commit is contained in:
parent
0e441d48ac
commit
25bb7c1826
2 changed files with 14 additions and 9 deletions
|
@ -2182,23 +2182,28 @@ bool CharacterController::playGroup(const std::string &groupname, int mode, int
|
||||||
|
|
||||||
if(mode != 0 || mAnimQueue.empty() || !isAnimPlaying(mAnimQueue.front().mGroup))
|
if(mode != 0 || mAnimQueue.empty() || !isAnimPlaying(mAnimQueue.front().mGroup))
|
||||||
{
|
{
|
||||||
clearAnimQueue();
|
clearAnimQueue(persist);
|
||||||
mAnimQueue.push_back(entry);
|
|
||||||
|
|
||||||
mAnimation->disable(mCurrentIdle);
|
mAnimation->disable(mCurrentIdle);
|
||||||
mCurrentIdle.clear();
|
mCurrentIdle.clear();
|
||||||
|
|
||||||
mIdleState = CharState_SpecialIdle;
|
mIdleState = CharState_SpecialIdle;
|
||||||
bool loopfallback = (entry.mGroup.compare(0,4,"idle") == 0);
|
bool loopfallback = (entry.mGroup.compare(0,4,"idle") == 0);
|
||||||
mAnimation->play(groupname, persist ? Priority_Persistent : Priority_Default,
|
mAnimation->play(groupname, persist && groupname != "idle" ? Priority_Persistent : Priority_Default,
|
||||||
MWRender::Animation::BlendMask_All, false, 1.0f,
|
MWRender::Animation::BlendMask_All, false, 1.0f,
|
||||||
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1, loopfallback);
|
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1, loopfallback);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mAnimQueue.resize(1);
|
mAnimQueue.resize(1);
|
||||||
mAnimQueue.push_back(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "PlayGroup idle" is a special case, used to remove to stop scripted animations playing
|
||||||
|
if (groupname == "idle")
|
||||||
|
entry.mPersist = false;
|
||||||
|
|
||||||
|
mAnimQueue.push_back(entry);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2225,15 +2230,15 @@ bool CharacterController::isAnimPlaying(const std::string &groupName)
|
||||||
return mAnimation->isPlaying(groupName);
|
return mAnimation->isPlaying(groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterController::clearAnimQueue()
|
void CharacterController::clearAnimQueue(bool clearPersistAnims)
|
||||||
{
|
{
|
||||||
// Do not interrupt scripted animations
|
// Do not interrupt scripted animations, if we want to keep them
|
||||||
if (!isPersistentAnimPlaying() && !mAnimQueue.empty())
|
if ((!isPersistentAnimPlaying() || clearPersistAnims) && !mAnimQueue.empty())
|
||||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||||
|
|
||||||
for (AnimationQueue::iterator it = mAnimQueue.begin(); it != mAnimQueue.end();)
|
for (AnimationQueue::iterator it = mAnimQueue.begin(); it != mAnimQueue.end();)
|
||||||
{
|
{
|
||||||
if (!it->mPersist)
|
if (clearPersistAnims || !it->mPersist)
|
||||||
it = mAnimQueue.erase(it);
|
it = mAnimQueue.erase(it);
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
|
|
|
@ -215,7 +215,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
|
||||||
void refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, bool force=false);
|
void refreshMovementAnims(const WeaponInfo* weap, CharacterState movement, bool force=false);
|
||||||
void refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force=false);
|
void refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force=false);
|
||||||
|
|
||||||
void clearAnimQueue();
|
void clearAnimQueue(bool clearPersistAnims = false);
|
||||||
|
|
||||||
bool updateWeaponState();
|
bool updateWeaponState();
|
||||||
bool updateCreatureState();
|
bool updateCreatureState();
|
||||||
|
|
Loading…
Reference in a new issue