From 7acde76025a6af9679ccaded5b6721b3371582da Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 05:29:30 -0700 Subject: [PATCH] fix(wob): fromWMO sanitizes vertex floats during conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sanitize at conversion time too, not just on WoB load. Avoids the case where a corrupt source WMO (extracted from a partially-decoded MPQ) silently poisons the WOB the editor exports — and the WOB load-time guard from the previous commit only catches it on later reload, not during the first conversion. Also catches the boundRadius calculation which would otherwise inherit a NaN from one bad vertex. --- src/pipeline/wowee_building.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pipeline/wowee_building.cpp b/src/pipeline/wowee_building.cpp index 5ab672fe..404474f1 100644 --- a/src/pipeline/wowee_building.cpp +++ b/src/pipeline/wowee_building.cpp @@ -374,10 +374,22 @@ WoweeBuilding WoweeBuildingLoader::fromWMO(const WMOModel& wmo, const std::strin wv.normal = v.normal; wv.texCoord = v.texCoord; wv.color = v.color; + // Sanitize on conversion so a corrupt source WMO doesn't poison + // the WOB and then surprise us on later reload. + if (!std::isfinite(wv.position.x)) wv.position.x = 0.0f; + if (!std::isfinite(wv.position.y)) wv.position.y = 0.0f; + if (!std::isfinite(wv.position.z)) wv.position.z = 0.0f; + if (!std::isfinite(wv.normal.x)) wv.normal.x = 0.0f; + if (!std::isfinite(wv.normal.y)) wv.normal.y = 0.0f; + if (!std::isfinite(wv.normal.z)) wv.normal.z = 1.0f; + if (!std::isfinite(wv.texCoord.x)) wv.texCoord.x = 0.0f; + if (!std::isfinite(wv.texCoord.y)) wv.texCoord.y = 0.0f; + for (int c = 0; c < 4; c++) + if (!std::isfinite(wv.color[c])) wv.color[c] = 1.0f; wobGroup.vertices.push_back(wv); - float d = glm::length(v.position); - if (d > maxDist) maxDist = d; + float d = glm::length(wv.position); + if (std::isfinite(d) && d > maxDist) maxDist = d; } wobGroup.indices.reserve(grp.indices.size());