From 1467417b11d1cb84b118c9b0b0feb19d7e58307b Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 05:12:53 -0700 Subject: [PATCH] fix(wom): sanitize boundRadius / boundMin / boundMax against NaN/inf on load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/pipeline/wowee_model.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pipeline/wowee_model.cpp b/src/pipeline/wowee_model.cpp index 91d3695c..cc6924fa 100644 --- a/src/pipeline/wowee_model.cpp +++ b/src/pipeline/wowee_model.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace wowee { namespace pipeline { @@ -39,6 +40,18 @@ WoweeModel WoweeModelLoader::load(const std::string& basePath) { f.read(reinterpret_cast(&model.boundMin), 12); f.read(reinterpret_cast(&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(&nameLen), 2); model.name.resize(nameLen);