From a4339f057080f9d8ea51dec8dfbc5a29ab586215 Mon Sep 17 00:00:00 2001 From: neoraider Date: Mon, 14 May 2007 19:11:02 +0000 Subject: libzoom: Compute default normals --- level.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/level.c b/level.c index 0d22f64..9118499 100644 --- a/level.c +++ b/level.c @@ -270,11 +270,19 @@ LEVEL *LoadLevel(char *filename) { } } } + v = VectorCross( VectorSub(level->rooms[i].walls[j].vertices[1], level->rooms[i].walls[j].vertices[0]), VectorSub(level->rooms[i].walls[j].vertices[2], level->rooms[i].walls[j].vertices[0]) ); - if(VectorLengthSq(v)) level->rooms[i].walls[j].normal = VectorNormalize(v); + if(VectorLengthSq(v) > 0.0) { + level->rooms[i].walls[j].normal = VectorNormalize(v); + + for(k = 0; k < 3; k++) { + if(VectorLengthSq(level->rooms[i].walls[j].normals[k]) == 0.0) + level->rooms[i].walls[j].normals[k] = level->rooms[i].walls[j].normal; + } + } j++; } -- cgit v1.2.3