From 1979d921a7ca42255bf403a33b2ef6dfc0cc3f9e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 04:59:28 -0700 Subject: [PATCH] fix(editor): clamp PlacedObject scale to 1.0 when JSON value is invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same defensive check the WoB doodad load just got — guards against corrupted/partial-write JSON where scale ends up 0/NaN/inf. Without this an invisible (scale=0) or crashed (NaN matrix) placement could silently bork a loaded zone. --- tools/editor/object_placer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/editor/object_placer.cpp b/tools/editor/object_placer.cpp index bc0c7d0c..25b92d60 100644 --- a/tools/editor/object_placer.cpp +++ b/tools/editor/object_placer.cpp @@ -294,6 +294,8 @@ bool ObjectPlacer::loadFromFile(const std::string& path) { obj.type = static_cast(jo.value("type", 0)); obj.path = jo.value("path", ""); obj.scale = jo.value("scale", 1.0f); + // Guard against corrupted/partial-write JSON: clamp invalid scale. + if (!std::isfinite(obj.scale) || obj.scale <= 0.0001f) obj.scale = 1.0f; if (jo.contains("pos") && jo["pos"].is_array() && jo["pos"].size() >= 3) { obj.position = glm::vec3(jo["pos"][0].get(),