mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
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:
parent
199f18cdac
commit
1979d921a7
1 changed files with 2 additions and 0 deletions
|
|
@ -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>(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue