Commit graph

3174 commits

Author SHA1 Message Date
Kelsi
19bfaaef97 fix(movement): stop spoofing player position for area triggers
The area trigger system was temporarily moving the player to the trigger
center and sending a heartbeat before firing CMSG_AREATRIGGER. This told
the server the player was at a different location, causing unexpected
teleports (e.g. Stormwind to Hillsbrad). Just send the area trigger
packet directly — the player is already inside the trigger radius.
2026-04-05 04:40:46 -07:00
Kelsi
09c1469956 fix(ui): show only zone name on character select, drop map/continent 2026-04-05 04:34:39 -07:00
Kelsi
e4c4b6f429 fix(ui): use display name from Map.dbc field 4 instead of internal name
Was reading field 2 (InstanceType) which fell back to field 1 (internal
name like "Azeroth"). Field 4 has the localized display name ("Eastern
Kingdoms").
2026-04-05 04:32:10 -07:00
Kelsi
535ae8aa89 fix(ui): resolve map 0 name and allow guild queries at character screen
getMapName() returned empty for mapId 0 (Eastern Kingdoms) due to an
early return guard. Remove it since 0 is a valid map ID.

queryGuildInfo() required IN_WORLD state but the character screen is at
CHAR_LIST_RECEIVED. The server accepts CMSG_GUILD_QUERY before login,
so just check for a connected socket.
2026-04-05 04:30:32 -07:00
Kelsi
2e30490fc5 fix(ui): show guild name and zone name on character select screen
Load area names from AreaTable.dbc (canonical zone names) in addition
to WorldMapArea.dbc so zone IDs from SMSG_CHAR_ENUM resolve to names.
Use lookupGuildName() to query and display guild names instead of raw
guild IDs.
2026-04-05 04:28:36 -07:00
Kelsi
35be19e74c fix(mail): route GO mailbox open through InventoryHandler
The decomposition PRs moved mail state to InventoryHandler but the GO
interaction code still set stale GameHandler fields. Add openMailbox()
on InventoryHandler and forward from GameHandler so the correct
mailboxGuid_/mailboxOpen_ are set and refreshMailList() works.
2026-04-05 04:22:48 -07:00
Kelsi
62f3f515e2 fix(mail): let SMSG_SHOW_MAILBOX open mailbox instead of stale GameHandler fields
GO interaction was setting the old GameHandler mailbox state instead of
InventoryHandler's, so refreshMailList saw mailboxGuid_=0 and bailed.
2026-04-05 04:17:55 -07:00
Kelsi
53244d025c feat(repair): DBC-based repair cost estimation and UI display
Calculate repair costs client-side using DurabilityCosts.dbc and
DurabilityQuality.dbc. Block repair when player can't afford it and
only apply optimistic durability/gold updates when cost is verified.
Show repair cost next to the Repair All button in the vendor window.
2026-04-05 04:15:48 -07:00
Kelsi Davis
3dec33ecf1 perf(rendering): reduce GPU cull buffer to 24k instances 2026-04-05 03:39:10 -07:00
Kelsi Davis
8bb3702af4 perf(rendering): reduce GPU cull buffer and add CPU fallback for overflow
Halve MAX_CULL_INSTANCES to 32768 and iterate all instances in render,
falling back to CPU frustum culling for any beyond the GPU buffer.
2026-04-05 03:25:27 -07:00
Kelsi Davis
b62df70d09 fix(rendering): game objects invisible due to GPU cull instance limit
MAX_CULL_INSTANCES was 16384 but game object instances were allocated
at indices 20000+, beyond the cull buffer. Increased to 65536.
Also compute fallback boundRadius from vertex extents when M2 header
reports 0, and seed bones for global-sequence-only animated models.
2026-04-05 03:18:52 -07:00
Kelsi
1dd1a431f4 fix(repair): process item durability updates even when entity missing from manager
handleValuesUpdate silently dropped VALUES updates for item GUIDs not in
entityManager, causing repair-all durability changes to be lost. Fall
through to updateItemOnValuesUpdate for items tracked in onlineItems_.
2026-04-05 03:15:03 -07:00
Kelsi
0e308cf5a1 chore: remove HelloWorld test addon 2026-04-05 02:39:10 -07:00
Kelsi Rae Davis
8c587ab13d
Merge pull request #48 from ldmonster/feat/animation-handling
[feat] animation: FSM-Based Animation System — Full Refactor
2026-04-05 02:38:02 -07:00
Kelsi
a86c94c55a chore: add shallow=true to FidelityFX-FSR2 submodule 2026-04-05 02:37:46 -07:00
Pavel Okhlopkov
e386fbb069
Merge branch 'master' into feat/animation-handling 2026-04-05 12:37:08 +03:00
Kelsi
0d188edd75 fix(areatrigger): use actual DBC dimensions instead of inflated minimums
The minimum floor (3.0 for sphere radius, 4.0 for box dimensions) was
inflating narrow triggers like AT 5711 (boxWidth 1.06 → 4.0), causing
false area trigger fires near the Stormwind AH and unexpected teleports.
2026-04-05 02:35:47 -07:00
Paul
292e28b948 fix(ci): skip FidelityFX submodule checkout during actions/checkout
Add update=none and shallow=true to extern/FidelityFX-FSR2 and
extern/FidelityFX-SDK in .gitmodules.

The 'Checkout' step runs git submodule update --init --force --depth=1
on all submodules, including the Kelsidavis FSR2/SDK forks, which fails
because it tries to resolve a specific commit SHA via shallow fetch.
The 'Fetch AMD FSR2 SDK' step already rm -rf's and re-clones both
directories from the correct upstream repos, so the submodule checkout
step is redundant and harmful.

update=none causes git submodule update (and actions/checkout submodules:true)
to skip these two entries.  Local developers who want the FSR2/SDK must
run the manual fetch step or use 'git submodule update --init <path>'
explicitly.
2026-04-05 12:35:34 +03:00
Paul
0da2365154 Merge commit 'bcf1015149' into feat/animation-handling 2026-04-05 12:35:17 +03:00
Kelsi
e0ef682b1e fix(ci): revert FSR2 submodule to remote HEAD, ignore dirty state
The .gitignore commit was never pushed to the FSR2 fork, breaking CI
shallow clones. Revert to 3d22aef and add ignore=dirty to .gitmodules
to suppress generated shader header noise.
2026-04-05 02:35:14 -07:00
Paul
a9a4f606f9 gitignore 2026-04-05 12:35:12 +03:00
Paul
b4989dc11f 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
Kelsi
aee5750759 chore: update FidelityFX-FSR2 submodule (ignore generated shaders) 2026-04-05 02:18:22 -07:00
Kelsi Davis
bcf1015149 fix(rendering): check sampler validity in VkTexture::isValid(), fix Windows build
- VkTexture::isValid() now checks both image AND sampler handles. Previously
  it only checked the image, so a texture with a valid image but NULL sampler
  would pass validation and get bound to a descriptor set. On MoltenVK (macOS)
  this renders as pink/magenta boxes; the fallback white texture is now
  correctly used instead.

- Fix fs::path to std::string implicit conversion in asset extractor that
  broke the Windows (MSYS2/clang) CI build.
2026-04-05 01:34:49 -07:00
Kelsi Rae Davis
50fdfd2e22
Merge pull request #47 from sschepens/patch-2
refactor asset extractor
2026-04-05 01:10:28 -07:00
Kelsi Rae Davis
f9d6ae5ef1
Merge pull request #46 from ldmonster/feat/animation-handling
[feat] animation: Comprehensive Animation System Overhaul — 452 Constants, 30-Phase State Machine
2026-04-05 01:09:51 -07:00
Kelsi Rae Davis
6d60717545
Merge pull request #45 from ldmonster/feat/rendering-performance-architecture
[feat] Rendering Architecture & GPU Performance + Bug Fixes
2026-04-05 01:09:03 -07:00
Paul
e58f9b4b40 feat(animation): 452 named constants, 30-phase character animation state machine
Add animation_ids.hpp/cpp with all 452 WoW animation ID constants (anim::STAND,
anim::RUN, anim::FIRE_BOW, ... anim::FLY_BACKWARDS, etc.), nameFromId() O(1)
lookup, and flyVariant() compact 218-element ground→FLY_* resolver.

Expand AnimationController into a full state machine with 20+ named states:
spell cast (directed→omni→cast fallback chain, instant one-shot release),
hit reactions (WOUND/CRIT/DODGE/BLOCK/SHIELD_BLOCK), stun, wounded idle,
stealth animation substitution, loot, fishing channel, sit/sleep/kneel
down→loop→up transitions, sheathe/unsheathe combat enter/exit, ranged weapons
(BOW/GUN/CROSSBOW/THROWN with reload states), game object OPEN/CLOSE/DESTROY,
vehicle enter/exit, mount flight directionals (FLY_LEFT/RIGHT/UP/DOWN/BACKWARDS),
emote state variants, off-hand/pierce/dual-wield alternation, NPC
birth/spawn/drown/rise, sprint aura override, totem idle, NPC greeting/farewell.

Add spell_defines.hpp with SpellEffect (~45 constants) and SpellMissInfo
(12 constants) namespaces; replace all magic numbers in spell_handler.cpp.

Add GAMEOBJECT_BYTES_1 to update field table (all 4 expansion JSONs) and wire
GameObjectStateCallback. Add DBC cross-validation on world entry.

Expand tools/_ANIM_NAMES from ~35 to 452 entries in m2_viewer.py and
asset_pipeline_gui.py. Add tests/test_animation_ids.cpp.

Bug fixes included:
- Stand state 1 was animating READY_2H(27) — fixed to SITTING(97)
- Spell casts ended freeze-frame — add one-shot release animation
- NPC 2H swing probe chain missing ATTACK_2H_LOOSE (polearm/staff)
- Chair sits (states 2/4/5/6) incorrectly played floor-sit transition
- STOP(3) used for all spell casts — replaced with model-aware chain
2026-04-04 23:02:53 +03:00
sschepens
a381598bf8
fix gitignore 2026-04-04 15:29:50 -03:00
sschepens
1e464dd513
refactor path mapper 2026-04-04 14:34:23 -03:00
sschepens
5542cbaa02
refactor asset extractor
- mpq and locale finding is now case insensitive
- improve extraction order and support more patches
- unified much of the mpq logic for all expansions
- return a list of ordered paths for loading
2026-04-04 14:00:55 -03:00
Paul
d54e262048 feat(rendering): GPU architecture + visual quality fixes
M2 GPU instancing
- M2InstanceGPU SSBO (96 B/entry, double-buffered, 16384 max)
- Group opaque instances by (modelId, LOD); single vkCmdDrawIndexed per group
- boneBase field indexes into mega bone SSBO via gl_InstanceIndex

Indirect terrain drawing
- 24 MB mega index buffer (6M uint32) + 64 MB mega vertex buffer
- CPU builds VkDrawIndexedIndirectCommand per visible chunk
- Single VB/IB bind per frame; shadow pass reuses mega buffers
- Replaced vkCmdDrawIndexedIndirect with direct vkCmdDrawIndexed to fix
  host-mapped buffer race condition that caused terrain flickering

GPU frustum culling (compute shader)
- m2_cull.comp.glsl: 64-thread workgroups, sphere-vs-6-planes + distance cull
- CullInstanceGPU SSBO input, uint visibility[] output, double-buffered
- dispatchCullCompute() runs before main pass via render graph node

Consolidated bone matrix SSBOs
- 16 MB double-buffered mega bone SSBO (2048 instances × 128 bones)
- Eliminated per-instance descriptor sets; one megaBoneSet_ per frame
- prepareRender() packs bone matrices consecutively into current frame slot

Render graph / frame graph
- RenderGraph: RGResource handles, RGPass nodes, Kahn topological sort
- Automatic VkImageMemoryBarrier/VkBufferMemoryBarrier between passes
- Passes: minimap_composite, worldmap_composite, preview_composite,
  shadow_pass, reflection_pass, compute_cull
- beginFrame() uses buildFrameGraph() + renderGraph_->execute(cmd)

Pipeline derivatives
- PipelineBuilder::setFlags/setBasePipeline for VK_PIPELINE_CREATE_DERIVATIVE_BIT
- M2 opaque = base; alphaTest/alpha/additive are derivatives
- Applied to terrain (wireframe) and WMO (alpha-test) renderers

Rendering bug fixes:
- fix(shadow): compute lightSpaceMatrix before updatePerFrameUBO to eliminate
  one-frame lag that caused shadow trails and flicker on moving objects
- fix(shadow): scale depth bias with shadowDistance_ instead of hardcoded 0.8f
  to prevent acne at close range and gaps at far range
- fix(visibility): WMO group distance threshold 500u → 1200u to match terrain
  view distance; buildings were disappearing on the horizon
- fix(precision): camera near plane 0.05 → 0.5 (ratio 600K:1 → 60K:1),
  eliminating Z-fighting and improving frustum plane extraction stability
- fix(streaming): terrain load radius 4 → 6 tiles (~2133u → ~3200u) to exceed
  M2 render distance (2800u) and eliminate pop-in when camera turns;
  unload radius 7 → 9; spawn radius 3 → 4
- fix(visibility): ground-detail M2 distance multiplier 0.75 → 0.9 to reduce
  early pop of grass and debris
2026-04-04 13:43:16 +03:00
Pavel Okhlopkov
ca3cea078b
Merge branch 'Kelsidavis:master' into master 2026-04-04 13:42:02 +03:00
Kelsi Davis
2343b768ce fix: warden mmap on macOS, add external listfile support to asset extractor
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
Drop PROT_EXEC from warden module mmap when using Unicorn emulation
(not needed — module image is copied into emulator address space). Use
MAP_JIT on macOS for the native fallback path.

Add --listfile option to asset_extract and SFileAddListFileEntries
support for resolving unnamed MPQ hash table entries from external
listfiles.
2026-04-04 01:16:28 -07:00
Kelsi Davis
2fd9473f3b fix(rendering): alpha-to-coverage for hair, skip eye glow geosets, add missing include
- Enable alpha-to-coverage on alphaTestPipeline for smooth hair edges
  when MSAA is active (both init and recreatePipelines paths)
- Shader uses fwidth()-based alpha rescaling for clean coverage
- Skip group 17/18 geosets (DK/NE eye glow) when no geoset filter is
  set — prevents blue eye glow on all NPCs
- Add missing <libgen.h> include for dirname() on Linux
2026-04-04 01:16:28 -07:00
Kelsi Davis
f577411a15 fix(chat): resolve /r reply target when name arrives after whisper
Whisper sender name may not be in the player name cache when the packet
arrives. Store the sender GUID and lazily resolve the name from the
cache in getLastWhisperSender(). Also backfill lastWhisperSender_ when
the SMSG_NAME_QUERY_RESPONSE arrives.
2026-04-04 01:16:28 -07:00
Kelsi Davis
3f408341e1 fix(rendering): correct alpha test on opaque batches and hair transparency
- alphaTestPipeline_ uses blendDisabled() so surviving pixels are fully
  opaque (was blendAlpha, causing hair to blend with background)
- Remove alphaCutout from alphaTest condition — opaque materials like
  capes no longer alpha-test just because their texture has an alpha
  channel
- Two-pass batch rendering: opaque (blendMode 0) draws first to
  establish depth, then alpha-key/blend draws on top
2026-04-04 01:16:28 -07:00
Kelsi Davis
c95147390b fix(rendering,game): init bone SSBO to identity; stop movement before cast
Bone SSBO buffers were allocated for MAX_BONES (240) entries but only
the first numBones were written. Uninitialized GPU memory in the
remaining slots caused vertex spikes when any bone index exceeded the
model's actual bone count.

Also send MSG_MOVE_STOP before spell casts so the server doesn't reject
cast-time spells (e.g. hearthstone) with "can't do that while moving".
2026-04-04 01:16:28 -07:00
Kelsi Davis
bde9bd20d8 fix(rendering): use separate timer for global sequence bones
Global sequence bones (hair, cape, physics) need time values spanning
their full duration (up to ~968733ms), but animationTime wraps at the
current animation's sequence duration (~2000ms for walk). This caused
vertex spikes projecting from fingers/neck/ponytail as bones got stuck
in the first ~2s of their loop. Add a separate globalSequenceTime
accumulator that is not wrapped at the animation duration.
2026-04-04 01:16:28 -07:00
Kelsi Davis
f520511139 fix: chdir to executable directory at startup for relative asset paths
The binary assumed it was always launched from its own directory, causing
shader/asset loads to fail when run from any other working directory.
2026-04-04 01:16:28 -07:00
k
b3fa8cf5f3 fix: warden mmap on macOS, add external listfile support to asset extractor
Drop PROT_EXEC from warden module mmap when using Unicorn emulation
(not needed — module image is copied into emulator address space). Use
MAP_JIT on macOS for the native fallback path.

Add --listfile option to asset_extract and SFileAddListFileEntries
support for resolving unnamed MPQ hash table entries from external
listfiles.
2026-04-04 00:22:07 -07:00
Kelsi
84108c44f5 fix(rendering): alpha-to-coverage for hair, skip eye glow geosets, add missing include
- Enable alpha-to-coverage on alphaTestPipeline for smooth hair edges
  when MSAA is active (both init and recreatePipelines paths)
- Shader uses fwidth()-based alpha rescaling for clean coverage
- Skip group 17/18 geosets (DK/NE eye glow) when no geoset filter is
  set — prevents blue eye glow on all NPCs
- Add missing <libgen.h> include for dirname() on Linux
2026-04-04 00:21:15 -07:00
Kelsi
5538655383 fix(chat): resolve /r reply target when name arrives after whisper
Whisper sender name may not be in the player name cache when the packet
arrives. Store the sender GUID and lazily resolve the name from the
cache in getLastWhisperSender(). Also backfill lastWhisperSender_ when
the SMSG_NAME_QUERY_RESPONSE arrives.
2026-04-04 00:03:19 -07:00
Kelsi
c85d023329 fix(rendering): correct alpha test on opaque batches and hair transparency
- alphaTestPipeline_ uses blendDisabled() so surviving pixels are fully
  opaque (was blendAlpha, causing hair to blend with background)
- Remove alphaCutout from alphaTest condition — opaque materials like
  capes no longer alpha-test just because their texture has an alpha
  channel
- Two-pass batch rendering: opaque (blendMode 0) draws first to
  establish depth, then alpha-key/blend draws on top
2026-04-04 00:03:19 -07:00
Kelsi
100394a743 fix(rendering,game): init bone SSBO to identity; stop movement before cast
Bone SSBO buffers were allocated for MAX_BONES (240) entries but only
the first numBones were written. Uninitialized GPU memory in the
remaining slots caused vertex spikes when any bone index exceeded the
model's actual bone count.

Also send MSG_MOVE_STOP before spell casts so the server doesn't reject
cast-time spells (e.g. hearthstone) with "can't do that while moving".
2026-04-04 00:03:19 -07:00
Kelsi
aeb295e0bb fix(rendering): use separate timer for global sequence bones
Global sequence bones (hair, cape, physics) need time values spanning
their full duration (up to ~968733ms), but animationTime wraps at the
current animation's sequence duration (~2000ms for walk). This caused
vertex spikes projecting from fingers/neck/ponytail as bones got stuck
in the first ~2s of their loop. Add a separate globalSequenceTime
accumulator that is not wrapped at the animation duration.
2026-04-04 00:03:19 -07:00
k
b54458fe6c fix: chdir to executable directory at startup for relative asset paths
The binary assumed it was always launched from its own directory, causing
shader/asset loads to fail when run from any other working directory.
2026-04-03 23:27:13 -07:00
Kelsi
f79395788a fix(rendering): filter player hair geosets via CharHairGeosets.dbc
buildDefaultPlayerGeosets() was inserting all submeshIds 0-99 into
activeGeosets, showing every hair variation simultaneously. Now uses
the hairGeosetMap_ (from CharHairGeosets.dbc) to select only the
correct hair scalp geoset for the player's race/sex/style, matching
the existing NPC geoset filtering logic in EntitySpawner.
2026-04-03 22:43:37 -07:00
Kelsi
5468a93f2e fix(rendering): handle global sequences in character bone transforms
Hair, cape, and other physics bones use global sequences (continuously
looping timers independent of the character's current animation). The
character renderer was ignoring globalSequence entirely, causing these
bones to fall back to identity transforms and produce deformed/spiked
hair geometry. Added resolveTrackTime() to wrap global sequence time
correctly, matching the M2 renderer's existing behavior.
2026-04-03 22:37:46 -07:00
Kelsi
634bac6c7a Revert "fix(rendering): remap M2 vertex bone indices through bone lookup table"
This reverts commit 04ad88330f.
2026-04-03 22:26:14 -07:00