fix(editor): normalise NPC orientation to [0,360) and guard scale against NaN

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.
This commit is contained in:
Kelsi 2026-05-06 05:02:24 -07:00
parent 1979d921a7
commit d525318e9c

View file

@ -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);