From 137b25f3188a45113ff4b1bfe058a7bb70dc3223 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 10 Mar 2026 10:19:13 -0700 Subject: [PATCH] rendering: fix NPC movement animation IDs and remove redundant player anim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The renderer's CharAnimState machine already drives player character animations (Run=5, Walk=4, Jump, Swim, etc.) — remove the conflicting camera controller code added in the previous commit. Fix creature movement animations to use the correct WoW M2 IDs: 4=Walk, 5=Run. Both the per-frame sync loop and the SMSG_MONSTER_MOVE spline callback now use Run (5) for NPC movement. --- include/rendering/camera_controller.hpp | 3 --- src/core/application.cpp | 10 ++++++---- src/rendering/camera_controller.cpp | 25 ++----------------------- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/include/rendering/camera_controller.hpp b/include/rendering/camera_controller.hpp index fc513117..79a7d622 100644 --- a/include/rendering/camera_controller.hpp +++ b/include/rendering/camera_controller.hpp @@ -226,9 +226,6 @@ private: bool autoRunning = false; bool tildeWasDown = false; - // Movement animation state tracking - bool prevPlayerMoving_ = false; - // Movement state tracking (for sending opcodes on state change) bool wasMovingForward = false; bool wasMovingBackward = false; diff --git a/src/core/application.cpp b/src/core/application.cpp index adb454a0..00d4ef81 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -1476,7 +1476,8 @@ void Application::update(float deltaTime) { } posIt->second = renderPos; - // Drive movement animation: Run (4) when moving, Stand (0) when idle. + // Drive movement animation: Run (anim 5) when moving, Stand (0) when idle. + // WoW M2 animation IDs: 4=Walk, 5=Run. Use Run for all server-driven NPC movement. // Only switch on transitions to avoid resetting animation time. // Don't override Death (1) animation. bool prevMoving = creatureWasMoving_[guid]; @@ -1486,7 +1487,7 @@ void Application::update(float deltaTime) { bool gotState = charRenderer->getAnimationState(instanceId, curAnimId, curT, curDur); if (!gotState || curAnimId != 1 /*Death*/) { charRenderer->playAnimation(instanceId, - isMovingNow ? 4u : 0u, /*loop=*/true); + isMovingNow ? 5u : 0u, /*loop=*/true); } } } @@ -2453,7 +2454,8 @@ void Application::setupUICallbacks() { glm::vec3 renderPos = core::coords::canonicalToRender(glm::vec3(x, y, z)); float durationSec = static_cast(durationMs) / 1000.0f; renderer->getCharacterRenderer()->moveInstanceTo(instanceId, renderPos, durationSec); - // Play Run animation for the duration of the spline move (anim 4). + // Play Run animation (anim 5) for the duration of the spline move. + // WoW M2 animation IDs: 4=Walk, 5=Run. // Don't override Death animation (1). The per-frame sync loop will return to // Stand when movement stops. if (durationMs > 0) { @@ -2461,7 +2463,7 @@ void Application::setupUICallbacks() { auto* cr = renderer->getCharacterRenderer(); bool gotState = cr->getAnimationState(instanceId, curAnimId, curT, curDur); if (!gotState || curAnimId != 1 /*Death*/) { - cr->playAnimation(instanceId, 4u, /*loop=*/true); + cr->playAnimation(instanceId, 5u, /*loop=*/true); } if (!isPlayer) creatureWasMoving_[guid] = true; } diff --git a/src/rendering/camera_controller.cpp b/src/rendering/camera_controller.cpp index 0eeb7c50..cd6f7c27 100644 --- a/src/rendering/camera_controller.cpp +++ b/src/rendering/camera_controller.cpp @@ -1446,29 +1446,8 @@ void CameraController::update(float deltaTime) { bool shouldHidePlayer = isFirstPersonView() || (actualDist < MIN_DISTANCE + 0.1f); characterRenderer->setInstanceVisible(playerInstanceId, !shouldHidePlayer); - // Drive movement animation: Run (4) / Walk (5) when moving, Stand (0) when idle. - // Only transition on state changes to avoid resetting animation time every frame. - // Skip if current animation is Death (1) — death pose must persist. - bool nowMoving = isMoving(); - // Use Run (4) when running forward; Walk (5) for backpedal or slow pace. - uint32_t movingAnim = runPace ? 4u : 5u; - if (nowMoving != prevPlayerMoving_) { - prevPlayerMoving_ = nowMoving; - uint32_t curAnimId = 0; float curT = 0.0f, curDur = 0.0f; - bool gotState = characterRenderer->getAnimationState( - playerInstanceId, curAnimId, curT, curDur); - if (!gotState || curAnimId != 1 /*Death*/) { - characterRenderer->playAnimation(playerInstanceId, - nowMoving ? movingAnim : 0u, /*loop=*/true); - } - } else if (nowMoving) { - // Also switch between Run and Walk if pace changes while moving. - uint32_t curAnimId = 0; float curT = 0.0f, curDur = 0.0f; - characterRenderer->getAnimationState(playerInstanceId, curAnimId, curT, curDur); - if (curAnimId != movingAnim && curAnimId != 1 /*Death*/) { - characterRenderer->playAnimation(playerInstanceId, movingAnim, /*loop=*/true); - } - } + // Note: the Renderer's CharAnimState machine drives player character animations + // (Run, Walk, Jump, Swim, etc.) — no additional animation driving needed here. } } else { // Free-fly camera mode (original behavior)