diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2010-01-06 06:12:58 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2010-01-06 06:12:58 +0100 |
commit | a30ae7d0fb13b9a00a17e621463c186fb6ac5ada (patch) | |
tree | 883cf24043ea124de8f6162ba106dce8866d63e1 /src/Level.cpp | |
parent | 2aa2097b6cffd6ed58e127b0ed4f76d6255ac495 (diff) | |
download | zoom++-a30ae7d0fb13b9a00a17e621463c186fb6ac5ada.tar zoom++-a30ae7d0fb13b9a00a17e621463c186fb6ac5ada.zip |
Optimized triangle normal handling
Diffstat (limited to 'src/Level.cpp')
-rw-r--r-- | src/Level.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Level.cpp b/src/Level.cpp index 9b2aa78..c6ba915 100644 --- a/src/Level.cpp +++ b/src/Level.cpp @@ -172,13 +172,13 @@ TriangleRecord Level::loadWall(xmlNodePtr wallNode) { if(++vertexNum > 2) break; - wall.getTriangle().setVertex(vertexNum, loadVector(node)); + wall.getTriangle().setVertex(vertexNum, loadVector(node), false); } else if(!xmlStrcmp(node->name, (xmlChar*)"normal")) { if(vertexNum < 0) continue; - wall.getTriangle().setNormal(vertexNum, loadVector(node)); + wall.getTriangle().setVertexNormal(vertexNum, loadVector(node)); } else if(!xmlStrcmp(node->name, (xmlChar*)"texcoords")) { if(vertexNum < 0) continue; @@ -197,18 +197,14 @@ TriangleRecord Level::loadWall(xmlNodePtr wallNode) { } } - vmml::vec3f normal = wall.getTriangle().computeNormal(); + wall.getTriangle().updateNormal(); + vmml::vec3f normal = wall.getTriangle().getNormal(); - if(normal.squared_length() > 0) { - normal.normalize(); - - for(int i = 0; i < 3; ++i) { - if(wall.getTriangle().getNormal(i).squared_length() == 0) - wall.getTriangle().setNormal(i, normal); - } + for(int i = 0; i < 3; ++i) { + if(wall.getTriangle().getVertexNormal(i).squared_length() == 0) + wall.getTriangle().setVertexNormal(i, normal); } - return wall; } |