mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
fix(editor): syncToTerrain converts world coords back to ADT placement coords
ADT loading converts MDDF/MODF positions from ADT space to render/world space via core::coords::adtToWorld, but syncToTerrain wrote object positions back as raw render coords. So saving and reloading would displace every placed object/WMO, accumulating each save cycle. Now calls worldToAdt() to round-trip cleanly.
This commit is contained in:
parent
63fe5da04e
commit
1f97cb957e
1 changed files with 12 additions and 6 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "object_placer.hpp"
|
||||
#include "terrain_biomes.hpp"
|
||||
#include "core/coordinates.hpp"
|
||||
#include "core/logger.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <algorithm>
|
||||
|
|
@ -346,12 +347,16 @@ void ObjectPlacer::syncToTerrain() {
|
|||
m2Names.push_back(obj.path);
|
||||
foundM2:
|
||||
|
||||
// Editor stores positions in render/world coords; ADT files use
|
||||
// ADT-space placement coords. Convert back so re-loading the saved
|
||||
// ADT yields identical world positions.
|
||||
glm::vec3 adtPos = core::coords::worldToAdt(obj.position);
|
||||
pipeline::ADTTerrain::DoodadPlacement dp{};
|
||||
dp.nameId = nameId;
|
||||
dp.uniqueId = obj.uniqueId;
|
||||
dp.position[0] = obj.position.x;
|
||||
dp.position[1] = obj.position.y;
|
||||
dp.position[2] = obj.position.z;
|
||||
dp.position[0] = adtPos.x;
|
||||
dp.position[1] = adtPos.y;
|
||||
dp.position[2] = adtPos.z;
|
||||
dp.rotation[0] = obj.rotation.x;
|
||||
dp.rotation[1] = obj.rotation.y;
|
||||
dp.rotation[2] = obj.rotation.z;
|
||||
|
|
@ -368,12 +373,13 @@ void ObjectPlacer::syncToTerrain() {
|
|||
wmoNames.push_back(obj.path);
|
||||
foundWMO:
|
||||
|
||||
glm::vec3 adtPos = core::coords::worldToAdt(obj.position);
|
||||
pipeline::ADTTerrain::WMOPlacement wp{};
|
||||
wp.nameId = nameId;
|
||||
wp.uniqueId = obj.uniqueId;
|
||||
wp.position[0] = obj.position.x;
|
||||
wp.position[1] = obj.position.y;
|
||||
wp.position[2] = obj.position.z;
|
||||
wp.position[0] = adtPos.x;
|
||||
wp.position[1] = adtPos.y;
|
||||
wp.position[2] = adtPos.z;
|
||||
wp.rotation[0] = obj.rotation.x;
|
||||
wp.rotation[1] = obj.rotation.y;
|
||||
wp.rotation[2] = obj.rotation.z;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue