From d525318e9cb0bcbfbcda344c5db889e7deebc0f6 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 05:02:24 -0700 Subject: [PATCH] fix(editor): normalise NPC orientation to [0,360) and guard scale against NaN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Orientation values from edited JSON could be negative or wrap multiple revolutions; now normalised once at load. Scale was already clamped on small-positive but didn't reject NaN/inf — now rejects both with the same defensive check object_placer just got. --- tools/editor/npc_spawner.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/editor/npc_spawner.cpp b/tools/editor/npc_spawner.cpp index bcb2dcd4..2f725def 100644 --- a/tools/editor/npc_spawner.cpp +++ b/tools/editor/npc_spawner.cpp @@ -142,8 +142,15 @@ bool NpcSpawner::loadFromFile(const std::string& path) { s.modelPath = js.value("model", ""); s.displayId = js.value("displayId", 0u); s.orientation = js.value("orientation", 0.0f); + // Normalise orientation to [0, 360) for consistent gizmo behaviour. + if (std::isfinite(s.orientation)) { + s.orientation = std::fmod(s.orientation, 360.0f); + if (s.orientation < 0.0f) s.orientation += 360.0f; + } else { + s.orientation = 0.0f; + } s.scale = js.value("scale", 1.0f); - if (s.scale < 0.1f) s.scale = 1.0f; + if (!std::isfinite(s.scale) || s.scale < 0.1f) s.scale = 1.0f; s.level = js.value("level", 1u); s.health = js.value("health", 100u); s.mana = js.value("mana", 0u);