fix(editor): clamp PlacedObject scale to 1.0 when JSON value is invalid

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.
This commit is contained in:
Kelsi 2026-05-06 04:59:28 -07:00
parent 199f18cdac
commit 1979d921a7

View file

@ -294,6 +294,8 @@ bool ObjectPlacer::loadFromFile(const std::string& path) {
obj.type = static_cast<PlaceableType>(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<float>(),