Kelsidavis-WoWee/tests/test_anim_capability.cpp

57 lines
1.7 KiB
C++
Raw Normal View History

feat(animation): decompose AnimationController into FSM-based architecture 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).
2026-04-05 12:27:35 +03:00
// AnimCapabilitySet unit tests
#include <catch_amalgamated.hpp>
#include "rendering/animation/anim_capability_set.hpp"
using namespace wowee::rendering;
TEST_CASE("AnimCapabilitySet: default-constructed has all zero IDs", "[capability]") {
AnimCapabilitySet caps;
CHECK(caps.resolvedStand == 0);
CHECK(caps.resolvedWalk == 0);
CHECK(caps.resolvedRun == 0);
CHECK(caps.resolvedSprint == 0);
CHECK(caps.resolvedJumpStart == 0);
CHECK(caps.resolvedJump == 0);
CHECK(caps.resolvedJumpEnd == 0);
CHECK(caps.resolvedSwimIdle == 0);
CHECK(caps.resolvedSwim == 0);
CHECK(caps.resolvedCombatIdle == 0);
CHECK(caps.resolvedMelee1H == 0);
CHECK(caps.resolvedMelee2H == 0);
CHECK(caps.resolvedStun == 0);
CHECK(caps.resolvedMount == 0);
CHECK(caps.resolvedStealthIdle == 0);
CHECK(caps.resolvedLoot == 0);
}
TEST_CASE("AnimCapabilitySet: default-constructed has all flags false", "[capability]") {
AnimCapabilitySet caps;
CHECK_FALSE(caps.hasStand);
CHECK_FALSE(caps.hasWalk);
CHECK_FALSE(caps.hasRun);
CHECK_FALSE(caps.hasSprint);
CHECK_FALSE(caps.hasWalkBackwards);
CHECK_FALSE(caps.hasJump);
CHECK_FALSE(caps.hasSwim);
CHECK_FALSE(caps.hasMelee);
CHECK_FALSE(caps.hasStealth);
CHECK_FALSE(caps.hasDeath);
CHECK_FALSE(caps.hasMount);
}
TEST_CASE("AnimOutput::ok creates valid output", "[capability]") {
auto out = AnimOutput::ok(42, true);
CHECK(out.valid);
CHECK(out.animId == 42);
CHECK(out.loop == true);
}
TEST_CASE("AnimOutput::stay creates invalid output", "[capability]") {
auto out = AnimOutput::stay();
CHECK_FALSE(out.valid);
CHECK(out.animId == 0);
CHECK(out.loop == false);
}