From 778f4aca3e290ab1e730dd90e7537f771b90c416 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 07:32:07 -0700 Subject: [PATCH] fix(wob): warn + clamp uint32 indices on WMO conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WoB allows uint32 indices but WMO format is uint16. The previous static_cast would silently wrap a >65k index into a wrong-but- valid value — producing visible mis-stitched triangles in the renderer. Now log a warning once per group and clamp to 0 (degenerate triangle) so the bug is visible. --- src/pipeline/wowee_building.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pipeline/wowee_building.cpp b/src/pipeline/wowee_building.cpp index bba6add8..8f6fc0bc 100644 --- a/src/pipeline/wowee_building.cpp +++ b/src/pipeline/wowee_building.cpp @@ -379,8 +379,22 @@ bool WoweeBuildingLoader::toWMOModel(const WoweeBuilding& building, WMOModel& ou } wmoGroup.indices.reserve(grp.indices.size()); - for (uint32_t idx : grp.indices) - wmoGroup.indices.push_back(static_cast(idx)); + // WMO format uses uint16 indices, so each group must stay under 65k + // verts. WoB allows uint32 — log + clamp instead of silently + // wrapping and producing garbage triangles in the renderer. + bool warnedTrunc = false; + for (uint32_t idx : grp.indices) { + if (idx > 0xFFFF) { + if (!warnedTrunc) { + LOG_WARNING("toWMOModel: group '", grp.name, + "' has index > 65535 (clamping to 0)"); + warnedTrunc = true; + } + wmoGroup.indices.push_back(0); + } else { + wmoGroup.indices.push_back(static_cast(idx)); + } + } outModel.groups.push_back(std::move(wmoGroup)); }