From f856a90281cf8e79da9f54de0d8e5a22f245efc3 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 03:40:03 -0700 Subject: [PATCH] feat(editor): preserve WMO instance scale across ADT load/save The MODF scale field (u16 / 1024 = float) is now propagated in both directions: load reads wp.scale -> obj.scale, syncToTerrain converts obj.scale * 1024 -> wp.scale (clamped to u16). Combined with the prior loader/writer changes this means non-1.0 WMO scales (used by some WotLK content) survive a save/reload cycle. --- tools/editor/editor_app.cpp | 4 +++- tools/editor/object_placer.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/editor/editor_app.cpp b/tools/editor/editor_app.cpp index 0f64ebd4..99138f1e 100644 --- a/tools/editor/editor_app.cpp +++ b/tools/editor/editor_app.cpp @@ -981,7 +981,9 @@ void EditorApp::loadADT(const std::string& mapName, int tileX, int tileY) { obj.path = terrain_.wmoNames[wp.nameId]; obj.position = core::coords::adtToWorld(wp.position[0], wp.position[1], wp.position[2]); obj.rotation = glm::vec3(-wp.rotation[2], -wp.rotation[0], wp.rotation[1] + 180.0f); - obj.scale = 1.0f; + // MODF scale is fixed-point u16 (1024 = 1.0); fall back to 1.0 + // for older expansions where the scale slot was always 0. + obj.scale = wp.scale > 0 ? static_cast(wp.scale) / 1024.0f : 1.0f; obj.uniqueId = wp.uniqueId; objectPlacer_.getObjects().push_back(obj); } diff --git a/tools/editor/object_placer.cpp b/tools/editor/object_placer.cpp index 335e4d79..8b807114 100644 --- a/tools/editor/object_placer.cpp +++ b/tools/editor/object_placer.cpp @@ -388,6 +388,10 @@ void ObjectPlacer::syncToTerrain() { wp.rotation[2] = -obj.rotation.x; wp.flags = 0; wp.doodadSet = 0; + wp.nameSet = 0; + // MODF scale is fixed-point u16 (1024 = 1.0); cap to u16 max. + float s1024 = obj.scale * 1024.0f; + wp.scale = static_cast(std::clamp(s1024, 0.0f, 65535.0f)); terrain_->wmoPlacements.push_back(wp); } }