From 84c3d1bf32a0a91bdf7cb13dbcb2c7bea6e719ce Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 7 Feb 2026 17:01:41 -0800 Subject: [PATCH] Fix /unstuck to use full floor search via camera reset The previous approach used getFloorHeight which has tight spatial query bounds and couldn't find WMO floors far above the player. Now uses reset() which does multi-radius WMO/terrain scanning. --- include/rendering/camera_controller.hpp | 1 + src/core/application.cpp | 29 ++++--------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/include/rendering/camera_controller.hpp b/include/rendering/camera_controller.hpp index 329a018d..63b90a80 100644 --- a/include/rendering/camera_controller.hpp +++ b/include/rendering/camera_controller.hpp @@ -50,6 +50,7 @@ public: const glm::vec3& getDefaultPosition() const { return defaultPosition; } bool isMoving() const; float getYaw() const { return yaw; } + float getPitch() const { return pitch; } float getFacingYaw() const { return facingYaw; } bool isThirdPerson() const { return thirdPerson; } bool isGrounded() const { return grounded; } diff --git a/src/core/application.cpp b/src/core/application.cpp index cc884bf4..2ecb713c 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -530,36 +530,15 @@ void Application::setupUICallbacks() { loadOnlineWorldTerrain(mapId, x, y, z); }); - // Unstuck callback — snap player Z to WMO/terrain floor height + // Unstuck callback — re-run spawn search at current XY to find valid floor gameHandler->setUnstuckCallback([this]() { if (!renderer || !renderer->getCameraController()) return; auto* cc = renderer->getCameraController(); auto* ft = cc->getFollowTargetMutable(); if (!ft) return; - // Probe floor at current XY from high up to find WMO floors above - auto* wmo = renderer->getWMORenderer(); - auto* terrain = renderer->getTerrainManager(); - float bestZ = ft->z; - bool found = false; - // Probe from well above to catch WMO floors like Stormwind - float probeZ = ft->z + 200.0f; - if (wmo) { - auto wmoH = wmo->getFloorHeight(ft->x, ft->y, probeZ); - if (wmoH) { - bestZ = *wmoH; - found = true; - } - } - if (terrain) { - auto terrH = terrain->getHeightAt(ft->x, ft->y); - if (terrH && (!found || *terrH > bestZ)) { - bestZ = *terrH; - found = true; - } - } - if (found) { - ft->z = bestZ; - } + // Use reset() which does a full multi-radius WMO/terrain floor search + cc->setDefaultSpawn(*ft, cc->getYaw(), cc->getPitch()); + cc->reset(); }); // Faction hostility map is built in buildFactionHostilityMap() when character enters world