From dc7100a63f09aa67a2fa59e354f8e681bfd7fcb9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 8 Jul 2011 23:21:51 -0500 Subject: SH-2008 Fix for crash when generating normals on objects with no texture coordinates. --- indra/llprimitive/llmodel.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 986bde0581..ba7abd4c79 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1209,10 +1209,23 @@ void LLModel::generateNormals(F32 angle_cutoff) LLVolumeFace::VertexData v; new_face.mPositions[i] = vol_face.mPositions[idx]; new_face.mNormals[i].clear(); - new_face.mTexCoords[i] = vol_face.mTexCoords[idx]; new_face.mIndices[i] = i; } + if (vol_face.mTexCoords) + { + for (U32 i = 0; i < vol_face.mNumIndices; i++) + { + U32 idx = vol_face.mIndices[i]; + new_face.mTexCoords[i] = vol_face.mTexCoords[idx]; + } + } + else + { + ll_aligned_free_16(new_face.mTexCoords); + new_face.mTexCoords = NULL; + } + //generate normals for new face for (U32 i = 0; i < new_face.mNumIndices; i += 3) { //for each triangle -- cgit v1.2.3