fix(wom): sanitize boundRadius / boundMin / boundMax against NaN/inf on load

WOM bound fields drive M2 culling and collision AABBs — non-finite
values would either cull the model out entirely or crash the cull math.
Now boundRadius defaults to 1.0 when invalid, and each boundMin/boundMax
component defaults to 0 when non-finite.
This commit is contained in:
Kelsi 2026-05-06 05:12:53 -07:00
parent de983c2728
commit 1467417b11

View file

@ -5,6 +5,7 @@
#include <fstream>
#include <filesystem>
#include <cstring>
#include <cmath>
namespace wowee {
namespace pipeline {
@ -39,6 +40,18 @@ WoweeModel WoweeModelLoader::load(const std::string& basePath) {
f.read(reinterpret_cast<char*>(&model.boundMin), 12);
f.read(reinterpret_cast<char*>(&model.boundMax), 12);
// Bound sanity — radius drives M2 culling, min/max drive collision AABBs.
// NaN/inf would either cull-out the model or crash the cull math.
if (!std::isfinite(model.boundRadius) || model.boundRadius < 0.0f)
model.boundRadius = 1.0f;
auto sanitiseVec = [](glm::vec3& v) {
if (!std::isfinite(v.x)) v.x = 0.0f;
if (!std::isfinite(v.y)) v.y = 0.0f;
if (!std::isfinite(v.z)) v.z = 0.0f;
};
sanitiseVec(model.boundMin);
sanitiseVec(model.boundMax);
uint16_t nameLen;
f.read(reinterpret_cast<char*>(&nameLen), 2);
model.name.resize(nameLen);