From a8d4e4037223816fb79ef80f72886879203b46a5 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 17 Mar 2011 16:50:33 +0000 Subject: [PATCH] avoid a crash when creating model decals if RSurf_ActiveModel does not produce normals (why not?) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10926 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index fb17237c..64143694 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -10285,11 +10285,23 @@ static void R_DecalSystem_SplatTriangle(decalsystem_t *decalsystem, float r, flo vertex3f = rsurface.modelvertex3f; normal3f = rsurface.modelnormal3f; - for (cornerindex = 0;cornerindex < 3;cornerindex++) + if (normal3f) { - index = 3*e[cornerindex]; - VectorMA(vertex3f + index, cl_decals_bias.value, normal3f + index, v[cornerindex]); + for (cornerindex = 0;cornerindex < 3;cornerindex++) + { + index = 3*e[cornerindex]; + VectorMA(vertex3f + index, cl_decals_bias.value, normal3f + index, v[cornerindex]); + } } + else + { + for (cornerindex = 0;cornerindex < 3;cornerindex++) + { + index = 3*e[cornerindex]; + VectorCopy(vertex3f + index, v[cornerindex]); + } + } + // cull backfaces //TriangleNormal(v[0], v[1], v[2], normal); //if (DotProduct(normal, localnormal) < 0.0f) -- 2.39.2