mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 01:23:51 +00:00
anim: also trigger animation update on walk/run transitions for creatures
Extend the locomotion state-change detection to include the WALKING movement flag. Previously a creature that switched from walking to running (or vice versa) while staying in the moving state would keep playing the wrong animation because only the moving/idle transition was tracked. Add creatureWasWalking_ alongside creatureWasSwimming_ and creatureWasFlying_; guard the walking check with isMovingNow to avoid spurious triggers when the flag flips while the creature is idle. Clear and erase the new map at world reset and creature/player despawn.
This commit is contained in:
parent
2717018631
commit
acbfe99401
2 changed files with 12 additions and 3 deletions
|
|
@ -190,6 +190,7 @@ private:
|
|||
std::unordered_map<uint64_t, bool> creatureWasMoving_; // guid -> previous-frame movement state
|
||||
std::unordered_map<uint64_t, bool> creatureWasSwimming_; // guid -> previous-frame swim state (for anim transition detection)
|
||||
std::unordered_map<uint64_t, bool> creatureWasFlying_; // guid -> previous-frame flying state (for anim transition detection)
|
||||
std::unordered_map<uint64_t, bool> creatureWasWalking_; // guid -> previous-frame walking state (walk vs run transition detection)
|
||||
std::unordered_map<uint64_t, bool> creatureSwimmingState_; // guid -> currently in swim mode (SWIMMING flag)
|
||||
std::unordered_map<uint64_t, bool> creatureWalkingState_; // guid -> walking (WALKING flag, selects Walk(4) vs Run(5))
|
||||
std::unordered_map<uint64_t, bool> creatureFlyingState_; // guid -> currently flying (FLYING flag)
|
||||
|
|
|
|||
|
|
@ -752,6 +752,7 @@ void Application::logoutToLogin() {
|
|||
creatureWasMoving_.clear();
|
||||
creatureWasSwimming_.clear();
|
||||
creatureWasFlying_.clear();
|
||||
creatureWasWalking_.clear();
|
||||
creatureSwimmingState_.clear();
|
||||
creatureWalkingState_.clear();
|
||||
creatureFlyingState_.clear();
|
||||
|
|
@ -1492,15 +1493,19 @@ void Application::update(float deltaTime) {
|
|||
bool prevMoving = creatureWasMoving_[guid];
|
||||
bool prevSwimming = creatureWasSwimming_[guid];
|
||||
bool prevFlying = creatureWasFlying_[guid];
|
||||
bool prevWalking = creatureWasWalking_[guid];
|
||||
// Trigger animation update on any locomotion-state transition, not just
|
||||
// moving/idle — e.g. creature lands while still moving → FlyForward→Run.
|
||||
const bool stateChanged = (isMovingNow != prevMoving) ||
|
||||
// moving/idle — e.g. creature lands while still moving → FlyForward→Run,
|
||||
// or server changes WALKING flag while creature is already running → Walk.
|
||||
const bool stateChanged = (isMovingNow != prevMoving) ||
|
||||
(isSwimmingNow != prevSwimming) ||
|
||||
(isFlyingNow != prevFlying);
|
||||
(isFlyingNow != prevFlying) ||
|
||||
(isWalkingNow != prevWalking && isMovingNow);
|
||||
if (stateChanged) {
|
||||
creatureWasMoving_[guid] = isMovingNow;
|
||||
creatureWasSwimming_[guid] = isSwimmingNow;
|
||||
creatureWasFlying_[guid] = isFlyingNow;
|
||||
creatureWasWalking_[guid] = isWalkingNow;
|
||||
uint32_t curAnimId = 0; float curT = 0.0f, curDur = 0.0f;
|
||||
bool gotState = charRenderer->getAnimationState(instanceId, curAnimId, curT, curDur);
|
||||
if (!gotState || curAnimId != 1 /*Death*/) {
|
||||
|
|
@ -6957,8 +6962,10 @@ void Application::despawnOnlinePlayer(uint64_t guid) {
|
|||
creatureSwimmingState_.erase(guid);
|
||||
creatureWalkingState_.erase(guid);
|
||||
creatureFlyingState_.erase(guid);
|
||||
creatureWasMoving_.erase(guid);
|
||||
creatureWasSwimming_.erase(guid);
|
||||
creatureWasFlying_.erase(guid);
|
||||
creatureWasWalking_.erase(guid);
|
||||
}
|
||||
|
||||
void Application::spawnOnlineGameObject(uint64_t guid, uint32_t entry, uint32_t displayId, float x, float y, float z, float orientation) {
|
||||
|
|
@ -8554,6 +8561,7 @@ void Application::despawnOnlineCreature(uint64_t guid) {
|
|||
creatureWasMoving_.erase(guid);
|
||||
creatureWasSwimming_.erase(guid);
|
||||
creatureWasFlying_.erase(guid);
|
||||
creatureWasWalking_.erase(guid);
|
||||
creatureSwimmingState_.erase(guid);
|
||||
creatureWalkingState_.erase(guid);
|
||||
creatureFlyingState_.erase(guid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue