mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 09:33:51 +00:00
fix(wom): per-vertex NaN/inf scrub on load
Even after the bound-field guards, individual vertex floats (position, normal, texCoord) could still poison the GPU. NaN positions would crash the M2 vertex shader on some drivers (silent device-lost). Now each component defaults to 0 (or 1 for normal Z) when non-finite — vertex ends up at origin instead of corrupting the whole pipeline.
This commit is contained in:
parent
1467417b11
commit
29ae850307
1 changed files with 13 additions and 0 deletions
|
|
@ -73,6 +73,19 @@ WoweeModel WoweeModelLoader::load(const std::string& basePath) {
|
|||
model.vertices[i].texCoord = v1.uv;
|
||||
}
|
||||
}
|
||||
// Sanitize per-vertex floats. NaN/inf positions crash the M2 vertex
|
||||
// shader (silent device-lost on some drivers) — safer to render the
|
||||
// vertex at the origin than corrupt the whole pipeline.
|
||||
for (auto& v : model.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;
|
||||
}
|
||||
|
||||
model.indices.resize(indexCount);
|
||||
f.read(reinterpret_cast<char*>(model.indices.data()), indexCount * 4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue