From 75260f9f2c298d9da0ffbfd00540ec7bce1e21d3 Mon Sep 17 00:00:00 2001 From: Ian Curtis Date: Fri, 29 Dec 2023 13:28:10 +0000 Subject: [PATCH] Clamp LODscale. If the object is drawn at zero we produce an Inf value which will produce Nans with later calculations. --- Src/Graphics/New3D/New3D.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index 639c4d6..bcda293 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -738,6 +738,8 @@ void CNew3D::DescendCullingNode(UINT32 addr) float LODscale = m_nodeAttribs.currentDisableCulling ? std::numeric_limits::max() : (fBlendRadius / std::hypot(x, y, z)); const LOD *lod = m_LODBlendTable->table[lodTablePointer].lod; + LODscale = std::clamp(LODscale, 0.0f, std::numeric_limits::max()); + if (m_nodeAttribs.currentDisableCulling || (!outsideFrustum && LODscale >= lod[3].deleteSize)) { // Descend down first link