mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-07 17:43:51 +00:00
fix(m2): degenerate-normal guard during walkable-floor raycast
The matrix-transformed normal could be near-zero if the M2 instance has a degenerate scale; glm::normalize then returns NaN that contaminates the slope check (NaN < 0.35 is false → no early-out) and bestNormalZ goes NaN, breaking the walkable-floor heuristic. Length-check the transformed normal and fall back to the (0,0,1) flat default — same pattern as the WMO renderer.
This commit is contained in:
parent
ae20fbf621
commit
61fb486b9e
1 changed files with 6 additions and 2 deletions
|
|
@ -765,8 +765,12 @@ std::optional<float> M2Renderer::getFloorHeight(float glX, float glY, float glZ,
|
|||
if (nLen > 0.001f) {
|
||||
localN /= nLen;
|
||||
if (localN.z < 0.0f) localN = -localN;
|
||||
worldN = glm::normalize(
|
||||
glm::vec3(instance.modelMatrix * glm::vec4(localN, 0.0f)));
|
||||
glm::vec3 transformedN = glm::vec3(
|
||||
instance.modelMatrix * glm::vec4(localN, 0.0f));
|
||||
float wnLen = glm::length(transformedN);
|
||||
if (wnLen > 0.001f) {
|
||||
worldN = transformedN / wnLen;
|
||||
} // else: keep worldN = (0,0,1) flat default
|
||||
if (std::abs(worldN.z) < 0.35f) continue; // too steep (~70° max slope)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue