mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-08 10:03:51 +00:00
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:
parent
de983c2728
commit
1467417b11
1 changed files with 13 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue