mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
fix(editor): NPC + object position/rotation NaN guards on JSON load
Mirrors the recent scale guards. NaN/inf positions or rotations make the M2 renderer's matrix math produce chaos-shaped instances or crash during normal computation. Now both fields are reset to zero on load when any component is non-finite.
This commit is contained in:
parent
d525318e9c
commit
604d29d375
2 changed files with 14 additions and 0 deletions
|
|
@ -177,6 +177,12 @@ bool NpcSpawner::loadFromFile(const std::string& path) {
|
|||
s.position = glm::vec3(js["position"][0].get<float>(),
|
||||
js["position"][1].get<float>(),
|
||||
js["position"][2].get<float>());
|
||||
// Reject NaN/inf positions — they crash the M2 renderer's
|
||||
// matrix math and produce invisible / chaos-shaped instances.
|
||||
if (!std::isfinite(s.position.x) || !std::isfinite(s.position.y) ||
|
||||
!std::isfinite(s.position.z)) {
|
||||
s.position = glm::vec3(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (js.contains("patrol") && js["patrol"].is_array()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue