From 15648e21ec41865387af94181c568948b0119909 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 05:16:16 -0700 Subject: [PATCH] fix(wob): per-vertex NaN/inf scrub on load (matches WOM) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same NaN guard as the just-applied WOM one. Sanitizes position/normal/ texCoord/color components after the bulk read. WMO renderer's matrix math is sensitive — a single NaN position could desync the entire group's draw state. --- src/pipeline/wowee_building.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pipeline/wowee_building.cpp b/src/pipeline/wowee_building.cpp index 5204c2fc..5ab672fe 100644 --- a/src/pipeline/wowee_building.cpp +++ b/src/pipeline/wowee_building.cpp @@ -56,6 +56,20 @@ WoweeBuilding WoweeBuildingLoader::load(const std::string& basePath) { grp.vertices.resize(vc); f.read(reinterpret_cast(grp.vertices.data()), vc * sizeof(WoweeBuilding::Vertex)); + // Sanitize vertex floats — WMO renderer matrix math is sensitive + // and a NaN position can desync the entire group's draw state. + for (auto& v : grp.vertices) { + if (!std::isfinite(v.position.x)) v.position.x = 0.0f; + if (!std::isfinite(v.position.y)) v.position.y = 0.0f; + if (!std::isfinite(v.position.z)) v.position.z = 0.0f; + if (!std::isfinite(v.normal.x)) v.normal.x = 0.0f; + if (!std::isfinite(v.normal.y)) v.normal.y = 0.0f; + if (!std::isfinite(v.normal.z)) v.normal.z = 1.0f; + if (!std::isfinite(v.texCoord.x)) v.texCoord.x = 0.0f; + if (!std::isfinite(v.texCoord.y)) v.texCoord.y = 0.0f; + for (int c = 0; c < 4; c++) + if (!std::isfinite(v.color[c])) v.color[c] = 1.0f; + } grp.indices.resize(ic); f.read(reinterpret_cast(grp.indices.data()), ic * 4);