mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 01:23:52 +00:00
fix(wmo): degenerate-normal guard during tangent generation
A WMO vertex with zero-length or NaN normal would produce a NaN normalized normal, contaminating the Gram-Schmidt tangent for the whole vertex and producing visibly broken normal mapping for the affected face. Length-check before normalize and fall back to (0,0,1) when degenerate.
This commit is contained in:
parent
86c544b841
commit
ae20fbf621
1 changed files with 10 additions and 1 deletions
|
|
@ -1869,7 +1869,16 @@ bool WMORenderer::createGroupResources(const pipeline::WMOGroup& group, GroupRes
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < vertices.size(); i++) {
|
||||
glm::vec3 n = glm::normalize(vertices[i].normal);
|
||||
// Vertex normals from corrupt WMO data could be zero-length or
|
||||
// NaN. glm::normalize on either returns NaN that contaminates
|
||||
// the entire Gram-Schmidt tangent below; fall back to up-axis.
|
||||
glm::vec3 n;
|
||||
float normLen = glm::length(vertices[i].normal);
|
||||
if (std::isfinite(normLen) && normLen > 1e-6f) {
|
||||
n = vertices[i].normal / normLen;
|
||||
} else {
|
||||
n = glm::vec3(0, 0, 1);
|
||||
}
|
||||
glm::vec3 t = tan1[i];
|
||||
|
||||
if (glm::dot(t, t) < 1e-8f) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue