summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-05-14 21:11:02 +0200
committerneoraider <devnull@localhost>2007-05-14 21:11:02 +0200
commita4339f057080f9d8ea51dec8dfbc5a29ab586215 (patch)
tree8fc1520e73e5a18314b99cdc84e559f7780f6317
parenta5aa4b54e23d0793793384a6794cc543ea48ad34 (diff)
downloadlibzoom-a4339f057080f9d8ea51dec8dfbc5a29ab586215.tar
libzoom-a4339f057080f9d8ea51dec8dfbc5a29ab586215.zip
libzoom: Compute default normals
-rw-r--r--level.c10
1 files changed, 9 insertions, 1 deletions
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++;
}