mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 17:13:51 +00:00
fix(wob): per-vertex NaN/inf scrub on load (matches WOM)
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.
This commit is contained in:
parent
29ae850307
commit
15648e21ec
1 changed files with 14 additions and 0 deletions
|
|
@ -56,6 +56,20 @@ WoweeBuilding WoweeBuildingLoader::load(const std::string& basePath) {
|
|||
|
||||
grp.vertices.resize(vc);
|
||||
f.read(reinterpret_cast<char*>(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<char*>(grp.indices.data()), ic * 4);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue