diff --git a/include/core/coordinates.hpp b/include/core/coordinates.hpp index 85a31549..af38b453 100644 --- a/include/core/coordinates.hpp +++ b/include/core/coordinates.hpp @@ -53,17 +53,20 @@ inline float normalizeAngleRad(float a) { // Convert server/wire yaw (radians) → canonical yaw (radians). // -// Under server<->canonical X/Y swap: -// dir_s = (cos(s), sin(s)) -// dir_c = swap(dir_s) = (sin(s), cos(s)) => c = PI/2 - s +// Codebase canonical convention: atan2(-dy, dx) in (canonical_X=north, canonical_Y=west). +// North=0, East=+π/2, South=±π, West=-π/2. +// +// Server direction at angle s: (cos s, sin s) in (server_X=canonical_Y, server_Y=canonical_X). +// After swap: dir_c = (sin s, cos s) in (canonical_X, canonical_Y). +// atan2(-dy, dx) = atan2(-cos s, sin s) = s - π/2. inline float serverToCanonicalYaw(float serverYaw) { - return normalizeAngleRad((PI * 0.5f) - serverYaw); + return normalizeAngleRad(serverYaw - (PI * 0.5f)); } // Convert canonical yaw (radians) → server/wire yaw (radians). -// This mapping is its own inverse. +// Inverse of serverToCanonicalYaw: s = c + π/2. inline float canonicalToServerYaw(float canonicalYaw) { - return normalizeAngleRad((PI * 0.5f) - canonicalYaw); + return normalizeAngleRad(canonicalYaw + (PI * 0.5f)); } // Convert between canonical WoW and engine rendering coordinates (just swap X/Y). diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index b8d22581..60fc2d3e 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -4684,9 +4684,12 @@ void GameScreen::renderNameplates(game::GameHandler& gameHandler) { glm::vec3 ndc = glm::vec3(clipPos) / clipPos.w; if (ndc.x < -1.2f || ndc.x > 1.2f || ndc.y < -1.2f || ndc.y > 1.2f) continue; - // NDC → screen pixels (Y axis inverted) + // NDC → screen pixels. + // The camera bakes the Vulkan Y-flip into the projection matrix, so + // NDC y = -1 is the top of the screen and y = 1 is the bottom. + // Map directly: sy = (ndc.y + 1) / 2 * screenH (no extra inversion). float sx = (ndc.x * 0.5f + 0.5f) * screenW; - float sy = (1.0f - (ndc.y * 0.5f + 0.5f)) * screenH; + float sy = (ndc.y * 0.5f + 0.5f) * screenH; // Fade out in the last 5 units of range float alpha = dist < 35.0f ? 1.0f : 1.0f - (dist - 35.0f) / 5.0f;