From 7630c7aec73ed43e5c7a1e395776fb83d486d552 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 6 Mar 2026 18:48:12 -0800 Subject: [PATCH] Fix WMO doodad rotation: remove incorrect quaternion X/Y swap The glm::quat(w,x,y,z) constructor was receiving swapped X/Y components, causing doodads like the Deeprun Tram gears to be oriented horizontally instead of vertically. Also use createInstanceWithMatrix for instance WMO doodads to preserve full rotation from the quaternion. --- src/core/application.cpp | 6 +++--- src/rendering/terrain_manager.cpp | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/application.cpp b/src/core/application.cpp index 8450dfb8..d169b156 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -3712,8 +3712,8 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float } if (!m2Model.isValid()) continue; - glm::quat fixedRotation(doodad.rotation.w, doodad.rotation.y, - doodad.rotation.x, doodad.rotation.z); + glm::quat fixedRotation(doodad.rotation.w, doodad.rotation.x, + doodad.rotation.y, doodad.rotation.z); glm::mat4 doodadLocal(1.0f); doodadLocal = glm::translate(doodadLocal, doodad.position); doodadLocal *= glm::mat4_cast(fixedRotation); @@ -3724,7 +3724,7 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float uint32_t doodadModelId = static_cast(std::hash{}(m2Path)); m2Renderer->loadModel(m2Model, doodadModelId); - uint32_t doodadInstId = m2Renderer->createInstance(doodadModelId, worldPos, glm::vec3(0.0f), doodad.scale); + uint32_t doodadInstId = m2Renderer->createInstanceWithMatrix(doodadModelId, worldMatrix, worldPos); if (doodadInstId) m2Renderer->setSkipCollision(doodadInstId, true); loadedDoodads++; } diff --git a/src/rendering/terrain_manager.cpp b/src/rendering/terrain_manager.cpp index 9ecd3df9..5fbca940 100644 --- a/src/rendering/terrain_manager.cpp +++ b/src/rendering/terrain_manager.cpp @@ -567,8 +567,7 @@ std::shared_ptr TerrainManager::prepareTile(int x, int y) { // Build doodad's local transform (WoW coordinates) // WMO doodads use quaternion rotation - // Fix: WoW quaternions need X/Y swap for correct orientation - glm::quat fixedRotation(doodad.rotation.w, doodad.rotation.y, doodad.rotation.x, doodad.rotation.z); + glm::quat fixedRotation(doodad.rotation.w, doodad.rotation.x, doodad.rotation.y, doodad.rotation.z); glm::mat4 doodadLocal(1.0f); doodadLocal = glm::translate(doodadLocal, doodad.position);