mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-06 05:03:52 +00:00
Replace the 2,200-line monolithic AnimationController (goto-driven, single class, untestable) with a composed FSM architecture per refactor.md. New subsystem (src/rendering/animation/ — 16 headers, 10 sources): - CharacterAnimator: FSM composer implementing ICharacterAnimator - LocomotionFSM: idle/walk/run/sprint/jump/swim/strafe - CombatFSM: melee/ranged/spell cast/stun/hit reaction/charge - ActivityFSM: emote/loot/sit-down/sitting/sit-up - MountFSM: idle/run/flight/taxi/fidget/rear-up (per-instance RNG) - AnimCapabilitySet + AnimCapabilityProbe: probe once at model load, eliminate per-frame hasAnimation() linear search - AnimationManager: registry of CharacterAnimator by GUID - EmoteRegistry: DBC-backed emote command → animId singleton - FootstepDriver, SfxStateDriver: extracted from AnimationController animation_ids.hpp/.cpp moved to animation/ subdirectory (452 named constants); all include paths updated. AnimationController retained as thin adapter (~400 LOC): collects FrameInput, delegates to CharacterAnimator, applies AnimOutput. Priority order: Mount > Stun > HitReaction > Spell > Charge > Melee/Ranged > CombatIdle > Emote > Loot > Sit > Locomotion. STAY_IN_STATE policy when all FSMs return valid=false. Bugs fixed: - Remove static mt19937 in mount fidget (shared state across all mounted units) — replaced with per-instance seeded RNG - Remove goto from mounted animation branch (skipped init) - Remove per-frame hasAnimation() calls (now one probe at load) - Fix VK_INDEX_TYPE_UINT16 → UINT32 in shadow pass Tests (4 new suites, all ASAN+UBSan clean): - test_locomotion_fsm: 167 assertions - test_combat_fsm: 125 cases - test_activity_fsm: 112 cases - test_anim_capability: 56 cases docs/ANIMATION_SYSTEM.md added (architecture reference).
112 lines
3.1 KiB
C++
112 lines
3.1 KiB
C++
// ActivityFSM unit tests
|
|
#include <catch_amalgamated.hpp>
|
|
#include "rendering/animation/activity_fsm.hpp"
|
|
#include "rendering/animation/animation_ids.hpp"
|
|
|
|
using namespace wowee::rendering;
|
|
namespace anim = wowee::rendering::anim;
|
|
|
|
static AnimCapabilitySet makeActivityCaps() {
|
|
AnimCapabilitySet caps;
|
|
caps.resolvedStand = anim::STAND;
|
|
caps.resolvedSitDown = anim::SIT_GROUND_DOWN;
|
|
caps.resolvedSitLoop = anim::SITTING;
|
|
caps.resolvedSitUp = anim::SIT_GROUND_UP;
|
|
caps.resolvedKneel = anim::KNEEL_LOOP;
|
|
caps.resolvedLoot = anim::LOOT;
|
|
return caps;
|
|
}
|
|
|
|
static ActivityFSM::Input idleInput() {
|
|
ActivityFSM::Input in;
|
|
in.grounded = true;
|
|
return in;
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: NONE by default", "[activity]") {
|
|
ActivityFSM fsm;
|
|
CHECK(fsm.getState() == ActivityFSM::State::NONE);
|
|
CHECK_FALSE(fsm.isActive());
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: emote starts and returns valid output", "[activity]") {
|
|
ActivityFSM fsm;
|
|
auto caps = makeActivityCaps();
|
|
|
|
fsm.startEmote(anim::EMOTE_WAVE, false);
|
|
CHECK(fsm.getState() == ActivityFSM::State::EMOTE);
|
|
CHECK(fsm.isEmoteActive());
|
|
|
|
auto in = idleInput();
|
|
auto out = fsm.resolve(in, caps);
|
|
REQUIRE(out.valid);
|
|
CHECK(out.animId == anim::EMOTE_WAVE);
|
|
CHECK(out.loop == false);
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: emote cancelled by movement", "[activity]") {
|
|
ActivityFSM fsm;
|
|
auto caps = makeActivityCaps();
|
|
|
|
fsm.startEmote(anim::EMOTE_WAVE, false);
|
|
|
|
auto in = idleInput();
|
|
in.moving = true;
|
|
auto out = fsm.resolve(in, caps);
|
|
|
|
// After movement, emote should be cancelled
|
|
CHECK_FALSE(fsm.isEmoteActive());
|
|
CHECK(fsm.getState() == ActivityFSM::State::NONE);
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: looting starts and stops", "[activity]") {
|
|
ActivityFSM fsm;
|
|
auto caps = makeActivityCaps();
|
|
|
|
fsm.startLooting();
|
|
CHECK(fsm.getState() == ActivityFSM::State::LOOTING);
|
|
|
|
auto in = idleInput();
|
|
auto out = fsm.resolve(in, caps);
|
|
REQUIRE(out.valid);
|
|
|
|
// stopLooting transitions through LOOT_END (KNEEL_END one-shot) before NONE
|
|
fsm.stopLooting();
|
|
CHECK(fsm.getState() == ActivityFSM::State::LOOT_END);
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: sit stand state triggers sit down", "[activity]") {
|
|
ActivityFSM fsm;
|
|
auto caps = makeActivityCaps();
|
|
|
|
fsm.setStandState(ActivityFSM::STAND_STATE_SIT);
|
|
CHECK(fsm.getState() == ActivityFSM::State::SIT_DOWN);
|
|
|
|
auto in = idleInput();
|
|
in.sitting = true;
|
|
auto out = fsm.resolve(in, caps);
|
|
REQUIRE(out.valid);
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: cancel emote explicitly", "[activity]") {
|
|
ActivityFSM fsm;
|
|
auto caps = makeActivityCaps();
|
|
|
|
fsm.startEmote(anim::EMOTE_DANCE, true);
|
|
CHECK(fsm.isEmoteActive());
|
|
CHECK(fsm.getEmoteAnimId() == anim::EMOTE_DANCE);
|
|
|
|
fsm.cancelEmote();
|
|
CHECK_FALSE(fsm.isEmoteActive());
|
|
CHECK(fsm.getState() == ActivityFSM::State::NONE);
|
|
}
|
|
|
|
TEST_CASE("ActivityFSM: reset clears all state", "[activity]") {
|
|
ActivityFSM fsm;
|
|
fsm.startEmote(anim::EMOTE_WAVE, false);
|
|
CHECK(fsm.isActive());
|
|
|
|
fsm.reset();
|
|
CHECK(fsm.getState() == ActivityFSM::State::NONE);
|
|
CHECK_FALSE(fsm.isActive());
|
|
}
|