diff options
author | neoraider <devnull@localhost> | 2007-05-14 21:11:02 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2007-05-14 21:11:02 +0200 |
commit | a4339f057080f9d8ea51dec8dfbc5a29ab586215 (patch) | |
tree | 8fc1520e73e5a18314b99cdc84e559f7780f6317 | |
parent | a5aa4b54e23d0793793384a6794cc543ea48ad34 (diff) | |
download | libzoom-a4339f057080f9d8ea51dec8dfbc5a29ab586215.tar libzoom-a4339f057080f9d8ea51dec8dfbc5a29ab586215.zip |
libzoom: Compute default normals
-rw-r--r-- | level.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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++; } |