mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-24 13:43:43 +00:00
Merge branch 'we-all-know-actors-cant-read' into 'master'
Some cleanup of scripted animation handling. Closes #4742, #7637, and #7636 See merge request OpenMW/openmw!3522
This commit is contained in:
commit
629fe8ce81
@ -10,6 +10,7 @@
|
||||
Bug #4382: Sound output device does not change when it should
|
||||
Bug #4508: Can't stack enchantment buffs from different instances of the same self-cast generic magic apparel
|
||||
Bug #4610: Casting a Bound Weapon spell cancels the casting animation by equipping the weapon prematurely
|
||||
Bug #4742: Actors with wander never stop walking after Loopgroup Walkforward
|
||||
Bug #4754: Stack of ammunition cannot be equipped partially
|
||||
Bug #4816: GetWeaponDrawn returns 1 before weapon is attached
|
||||
Bug #5057: Weapon swing sound plays at same pitch whether it hits or misses
|
||||
@ -84,6 +85,8 @@
|
||||
Bug #7611: Beast races' idle animations slide after turning or jumping in place
|
||||
Bug #7630: Charm can be cast on creatures
|
||||
Bug #7631: Cannot trade with/talk to Creeper or Mudcrab Merchant when they're fleeing
|
||||
Bug #7636: Animations bug out when switching between 1st and 3rd person, while playing a scripted animation
|
||||
Bug #7637: Actors can sometimes move while playing scripted animations
|
||||
Bug #7639: NPCs don't use hand-to-hand if their other melee skills were damaged during combat
|
||||
Bug #7642: Items in repair and recharge menus aren't sorted alphabetically
|
||||
Bug #7647: NPC walk cycle bugs after greeting player
|
||||
|
@ -1998,12 +1998,12 @@ namespace MWMechanics
|
||||
}
|
||||
|
||||
bool Actors::playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool persist) const
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted) const
|
||||
{
|
||||
const auto iter = mIndex.find(ptr.mRef);
|
||||
if (iter != mIndex.end())
|
||||
{
|
||||
return iter->second->getCharacterController().playGroup(groupName, mode, number, persist);
|
||||
return iter->second->getCharacterController().playGroup(groupName, mode, number, scripted);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace MWMechanics
|
||||
void forceStateUpdate(const MWWorld::Ptr& ptr) const;
|
||||
|
||||
bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool persist = false) const;
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted = false) const;
|
||||
void skipAnimation(const MWWorld::Ptr& ptr) const;
|
||||
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) const;
|
||||
void persistAnimationStates() const;
|
||||
|
@ -538,7 +538,7 @@ namespace MWMechanics
|
||||
if (mAnimation->isPlaying("containerclose"))
|
||||
return false;
|
||||
|
||||
mAnimation->play("containeropen", Priority_Persistent, MWRender::Animation::BlendMask_All, false, 1.0f,
|
||||
mAnimation->play("containeropen", Priority_Scripted, MWRender::Animation::BlendMask_All, false, 1.0f,
|
||||
"start", "stop", 0.f, 0);
|
||||
if (mAnimation->isPlaying("containeropen"))
|
||||
return false;
|
||||
@ -559,7 +559,7 @@ namespace MWMechanics
|
||||
if (animPlaying)
|
||||
startPoint = 1.f - complete;
|
||||
|
||||
mAnimation->play("containerclose", Priority_Persistent, MWRender::Animation::BlendMask_All, false, 1.0f,
|
||||
mAnimation->play("containerclose", Priority_Scripted, MWRender::Animation::BlendMask_All, false, 1.0f,
|
||||
"start", "stop", startPoint, 0);
|
||||
}
|
||||
}
|
||||
@ -827,8 +827,8 @@ namespace MWMechanics
|
||||
void CharacterController::refreshCurrentAnims(
|
||||
CharacterState idle, CharacterState movement, JumpingState jump, bool force)
|
||||
{
|
||||
// If the current animation is persistent, do not touch it
|
||||
if (isPersistentAnimPlaying())
|
||||
// If the current animation is scripted, do not touch it
|
||||
if (isScriptedAnimPlaying())
|
||||
return;
|
||||
|
||||
refreshHitRecoilAnims();
|
||||
@ -882,7 +882,7 @@ namespace MWMechanics
|
||||
mDeathState = chooseRandomDeathState();
|
||||
|
||||
// Do not interrupt scripted animation by death
|
||||
if (isPersistentAnimPlaying())
|
||||
if (isScriptedAnimPlaying())
|
||||
return;
|
||||
|
||||
playDeath(startpoint, mDeathState);
|
||||
@ -1481,8 +1481,8 @@ namespace MWMechanics
|
||||
sndMgr->stopSound3D(mPtr, wolfRun);
|
||||
}
|
||||
|
||||
// Combat for actors with persistent animations obviously will be buggy
|
||||
if (isPersistentAnimPlaying())
|
||||
// Combat for actors with scripted animations obviously will be buggy
|
||||
if (isScriptedAnimPlaying())
|
||||
return forcestateupdate;
|
||||
|
||||
float complete = 0.f;
|
||||
@ -1852,17 +1852,32 @@ namespace MWMechanics
|
||||
|
||||
void CharacterController::updateAnimQueue()
|
||||
{
|
||||
if (mAnimQueue.size() > 1)
|
||||
if (mAnimQueue.empty())
|
||||
return;
|
||||
|
||||
if (!mAnimation->isPlaying(mAnimQueue.front().mGroup))
|
||||
{
|
||||
if (mAnimation->isPlaying(mAnimQueue.front().mGroup) == false)
|
||||
// Remove the finished animation, unless it's a scripted animation that was interrupted by e.g. a rebuild of
|
||||
// the animation object.
|
||||
if (mAnimQueue.size() > 1 || !mAnimQueue.front().mScripted || mAnimQueue.front().mLoopCount == 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (!mAnimQueue.empty())
|
||||
{
|
||||
// Move on to the remaining items of the queue
|
||||
bool loopfallback = mAnimQueue.front().mGroup.starts_with("idle");
|
||||
mAnimation->play(mAnimQueue.front().mGroup,
|
||||
mAnimQueue.front().mScripted ? Priority_Scripted : Priority_Default,
|
||||
MWRender::Animation::BlendMask_All, false, 1.0f, "start", "stop", 0.0f,
|
||||
mAnimQueue.front().mLoopCount, loopfallback);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mAnimQueue.front().mLoopCount = mAnimation->getCurrentLoopCount(mAnimQueue.front().mGroup);
|
||||
}
|
||||
|
||||
if (!mAnimQueue.empty())
|
||||
@ -2344,7 +2359,7 @@ namespace MWMechanics
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMovementAnimationControlled())
|
||||
if (!isMovementAnimationControlled() && !isScriptedAnimPlaying())
|
||||
world->queueMovement(mPtr, vec);
|
||||
}
|
||||
|
||||
@ -2371,8 +2386,7 @@ namespace MWMechanics
|
||||
}
|
||||
}
|
||||
|
||||
bool isPersist = isPersistentAnimPlaying();
|
||||
osg::Vec3f moved = mAnimation->runAnimation(mSkipAnim && !isPersist ? 0.f : duration);
|
||||
osg::Vec3f moved = mAnimation->runAnimation(mSkipAnim && !isScriptedAnimPlaying() ? 0.f : duration);
|
||||
if (duration > 0.0f)
|
||||
moved /= duration;
|
||||
else
|
||||
@ -2413,7 +2427,7 @@ namespace MWMechanics
|
||||
}
|
||||
|
||||
// Update movement
|
||||
if (isMovementAnimationControlled() && mPtr.getClass().isActor())
|
||||
if (isMovementAnimationControlled() && mPtr.getClass().isActor() && !isScriptedAnimPlaying())
|
||||
world->queueMovement(mPtr, moved);
|
||||
|
||||
mSkipAnim = false;
|
||||
@ -2428,7 +2442,7 @@ namespace MWMechanics
|
||||
state.mScriptedAnims.clear();
|
||||
for (AnimationQueue::const_iterator iter = mAnimQueue.begin(); iter != mAnimQueue.end(); ++iter)
|
||||
{
|
||||
if (!iter->mPersist)
|
||||
if (!iter->mScripted)
|
||||
continue;
|
||||
|
||||
ESM::AnimationState::ScriptedAnimation anim;
|
||||
@ -2464,7 +2478,7 @@ namespace MWMechanics
|
||||
AnimationQueueEntry entry;
|
||||
entry.mGroup = iter->mGroup;
|
||||
entry.mLoopCount = iter->mLoopCount;
|
||||
entry.mPersist = true;
|
||||
entry.mScripted = true;
|
||||
|
||||
mAnimQueue.push_back(entry);
|
||||
}
|
||||
@ -2483,18 +2497,18 @@ namespace MWMechanics
|
||||
mIdleState = CharState_SpecialIdle;
|
||||
|
||||
bool loopfallback = mAnimQueue.front().mGroup.starts_with("idle");
|
||||
mAnimation->play(anim.mGroup, Priority_Persistent, MWRender::Animation::BlendMask_All, false, 1.0f, "start",
|
||||
mAnimation->play(anim.mGroup, Priority_Scripted, MWRender::Animation::BlendMask_All, false, 1.0f, "start",
|
||||
"stop", complete, anim.mLoopCount, loopfallback);
|
||||
}
|
||||
}
|
||||
|
||||
bool CharacterController::playGroup(std::string_view groupname, int mode, int count, bool persist)
|
||||
bool CharacterController::playGroup(std::string_view groupname, int mode, int count, bool scripted)
|
||||
{
|
||||
if (!mAnimation || !mAnimation->hasAnimation(groupname))
|
||||
return false;
|
||||
|
||||
// We should not interrupt persistent animations by non-persistent ones
|
||||
if (isPersistentAnimPlaying() && !persist)
|
||||
// We should not interrupt scripted animations with non-scripted ones
|
||||
if (isScriptedAnimPlaying() && !scripted)
|
||||
return true;
|
||||
|
||||
// If this animation is a looped animation (has a "loop start" key) that is already playing
|
||||
@ -2523,17 +2537,17 @@ namespace MWMechanics
|
||||
AnimationQueueEntry entry;
|
||||
entry.mGroup = groupname;
|
||||
entry.mLoopCount = count - 1;
|
||||
entry.mPersist = persist;
|
||||
entry.mScripted = scripted;
|
||||
|
||||
if (mode != 0 || mAnimQueue.empty() || !isAnimPlaying(mAnimQueue.front().mGroup))
|
||||
{
|
||||
clearAnimQueue(persist);
|
||||
clearAnimQueue(scripted);
|
||||
|
||||
clearStateAnimation(mCurrentIdle);
|
||||
|
||||
mIdleState = CharState_SpecialIdle;
|
||||
bool loopfallback = entry.mGroup.starts_with("idle");
|
||||
mAnimation->play(groupname, persist && groupname != "idle" ? Priority_Persistent : Priority_Default,
|
||||
mAnimation->play(groupname, scripted && groupname != "idle" ? Priority_Scripted : Priority_Default,
|
||||
MWRender::Animation::BlendMask_All, false, 1.0f, ((mode == 2) ? "loop start" : "start"), "stop", 0.0f,
|
||||
count - 1, loopfallback);
|
||||
}
|
||||
@ -2544,7 +2558,7 @@ namespace MWMechanics
|
||||
|
||||
// "PlayGroup idle" is a special case, used to remove to stop scripted animations playing
|
||||
if (groupname == "idle")
|
||||
entry.mPersist = false;
|
||||
entry.mScripted = false;
|
||||
|
||||
mAnimQueue.push_back(entry);
|
||||
|
||||
@ -2556,12 +2570,12 @@ namespace MWMechanics
|
||||
mSkipAnim = true;
|
||||
}
|
||||
|
||||
bool CharacterController::isPersistentAnimPlaying() const
|
||||
bool CharacterController::isScriptedAnimPlaying() const
|
||||
{
|
||||
if (!mAnimQueue.empty())
|
||||
{
|
||||
const AnimationQueueEntry& first = mAnimQueue.front();
|
||||
return first.mPersist && isAnimPlaying(first.mGroup);
|
||||
return first.mScripted && isAnimPlaying(first.mGroup);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -2584,13 +2598,13 @@ namespace MWMechanics
|
||||
return movementAnimationControlled;
|
||||
}
|
||||
|
||||
void CharacterController::clearAnimQueue(bool clearPersistAnims)
|
||||
void CharacterController::clearAnimQueue(bool clearScriptedAnims)
|
||||
{
|
||||
// Do not interrupt scripted animations, if we want to keep them
|
||||
if ((!isPersistentAnimPlaying() || clearPersistAnims) && !mAnimQueue.empty())
|
||||
if ((!isScriptedAnimPlaying() || clearScriptedAnims) && !mAnimQueue.empty())
|
||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||
|
||||
if (clearPersistAnims)
|
||||
if (clearScriptedAnims)
|
||||
{
|
||||
mAnimQueue.clear();
|
||||
return;
|
||||
@ -2598,7 +2612,7 @@ namespace MWMechanics
|
||||
|
||||
for (AnimationQueue::iterator it = mAnimQueue.begin(); it != mAnimQueue.end();)
|
||||
{
|
||||
if (!it->mPersist)
|
||||
if (!it->mScripted)
|
||||
it = mAnimQueue.erase(it);
|
||||
else
|
||||
++it;
|
||||
|
@ -40,7 +40,7 @@ namespace MWMechanics
|
||||
Priority_Torch,
|
||||
Priority_Storm,
|
||||
Priority_Death,
|
||||
Priority_Persistent,
|
||||
Priority_Scripted,
|
||||
|
||||
Num_Priorities
|
||||
};
|
||||
@ -135,7 +135,7 @@ namespace MWMechanics
|
||||
{
|
||||
std::string mGroup;
|
||||
size_t mLoopCount;
|
||||
bool mPersist;
|
||||
bool mScripted;
|
||||
};
|
||||
typedef std::deque<AnimationQueueEntry> AnimationQueue;
|
||||
AnimationQueue mAnimQueue;
|
||||
@ -207,7 +207,7 @@ namespace MWMechanics
|
||||
void refreshMovementAnims(CharacterState movement, bool force = false);
|
||||
void refreshIdleAnims(CharacterState idle, bool force = false);
|
||||
|
||||
void clearAnimQueue(bool clearPersistAnims = false);
|
||||
void clearAnimQueue(bool clearScriptedAnims = false);
|
||||
|
||||
bool updateWeaponState();
|
||||
void updateIdleStormState(bool inwater) const;
|
||||
@ -215,7 +215,7 @@ namespace MWMechanics
|
||||
std::string chooseRandomAttackAnimation() const;
|
||||
static bool isRandomAttackAnimation(std::string_view group);
|
||||
|
||||
bool isPersistentAnimPlaying() const;
|
||||
bool isScriptedAnimPlaying() const;
|
||||
bool isMovementAnimationControlled() const;
|
||||
|
||||
void updateAnimQueue();
|
||||
@ -270,7 +270,7 @@ namespace MWMechanics
|
||||
void persistAnimationState() const;
|
||||
void unpersistAnimationState();
|
||||
|
||||
bool playGroup(std::string_view groupname, int mode, int count, bool persist = false);
|
||||
bool playGroup(std::string_view groupname, int mode, int count, bool scripted = false);
|
||||
void skipAnim();
|
||||
bool isAnimPlaying(std::string_view groupName) const;
|
||||
|
||||
|
@ -760,12 +760,12 @@ namespace MWMechanics
|
||||
}
|
||||
|
||||
bool MechanicsManager::playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool persist)
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted)
|
||||
{
|
||||
if (ptr.getClass().isActor())
|
||||
return mActors.playAnimationGroup(ptr, groupName, mode, number, persist);
|
||||
return mActors.playAnimationGroup(ptr, groupName, mode, number, scripted);
|
||||
else
|
||||
return mObjects.playAnimationGroup(ptr, groupName, mode, number, persist);
|
||||
return mObjects.playAnimationGroup(ptr, groupName, mode, number, scripted);
|
||||
}
|
||||
void MechanicsManager::skipAnimation(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ namespace MWMechanics
|
||||
/// Attempt to play an animation group
|
||||
/// @return Success or error
|
||||
bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool persist = false) override;
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted = false) override;
|
||||
void skipAnimation(const MWWorld::Ptr& ptr) override;
|
||||
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) override;
|
||||
void persistAnimationStates() override;
|
||||
|
@ -99,12 +99,12 @@ namespace MWMechanics
|
||||
}
|
||||
|
||||
bool Objects::playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool persist)
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted)
|
||||
{
|
||||
const auto iter = mIndex.find(ptr.mRef);
|
||||
if (iter != mIndex.end())
|
||||
{
|
||||
return iter->second->playGroup(groupName, mode, number, persist);
|
||||
return iter->second->playGroup(groupName, mode, number, scripted);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace MWMechanics
|
||||
void onClose(const MWWorld::Ptr& ptr);
|
||||
|
||||
bool playAnimationGroup(
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool persist = false);
|
||||
const MWWorld::Ptr& ptr, std::string_view groupName, int mode, int number, bool scripted = false);
|
||||
void skipAnimation(const MWWorld::Ptr& ptr);
|
||||
void persistAnimationStates();
|
||||
|
||||
|
@ -1145,8 +1145,7 @@ namespace MWRender
|
||||
bool hasScriptedAnims = false;
|
||||
for (AnimStateMap::iterator stateiter = mStates.begin(); stateiter != mStates.end(); stateiter++)
|
||||
{
|
||||
if (stateiter->second.mPriority.contains(int(MWMechanics::Priority_Persistent))
|
||||
&& stateiter->second.mPlaying)
|
||||
if (stateiter->second.mPriority.contains(int(MWMechanics::Priority_Scripted)) && stateiter->second.mPlaying)
|
||||
{
|
||||
hasScriptedAnims = true;
|
||||
break;
|
||||
@ -1158,7 +1157,7 @@ namespace MWRender
|
||||
while (stateiter != mStates.end())
|
||||
{
|
||||
AnimState& state = stateiter->second;
|
||||
if (hasScriptedAnims && !state.mPriority.contains(int(MWMechanics::Priority_Persistent)))
|
||||
if (hasScriptedAnims && !state.mPriority.contains(int(MWMechanics::Priority_Scripted)))
|
||||
{
|
||||
++stateiter;
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user