From 6f74ecc43971f4ccd10e6d7b0837f181766c36e5 Mon Sep 17 00:00:00 2001 From: VB Date: Sun, 5 Mar 2017 22:22:06 +0100 Subject: [PATCH] out of bounds in normals calculation --- Ground.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Ground.cpp b/Ground.cpp index 236d7ac6..fb17c938 100644 --- a/Ground.cpp +++ b/Ground.cpp @@ -206,8 +206,14 @@ void TGroundNode::InitNormals() } if (Vertices[i].Normal == vector3(0, 0, 0)) Vertices[i].Normal = (n1 + n2) / 2; - if (Vertices[i + 1].Normal == vector3(0, 0, 0)) - Vertices[i + 1].Normal = n2; + if (i + 1 < iNumVerts) + { + if (Vertices[i + 1].Normal == vector3(0, 0, 0)) + Vertices[i + 1].Normal = n2; + } + else + WriteLog("odd number of vertices, normals may be wrong!"); + break; case GL_TRIANGLE_FAN: