clray
diff src/mesh.cc @ 15:754faf15ba36
burp
author | John Tsiombikas |
---|---|
date | Sun, 08 Aug 2010 09:51:45 +0100 |
parents | 29f9330cfa4b |
children | 9e4a28063394 |
line diff
1.1 --- a/src/mesh.cc Sat Aug 07 03:36:36 2010 +0100 1.2 +++ b/src/mesh.cc Sun Aug 08 09:51:45 2010 +0100 1.3 @@ -1,6 +1,7 @@ 1.4 #include <stdio.h> 1.5 #include <stdlib.h> 1.6 #include <string.h> 1.7 +#include <math.h> 1.8 #include <errno.h> 1.9 #include <limits.h> 1.10 #include <string> 1.11 @@ -115,6 +116,26 @@ 1.12 1.13 static map<string, int> matnames; 1.14 1.15 + 1.16 +#define FEQ(a, b) (fabs((a) - (b)) < 1e-8) 1.17 +bool Face::operator ==(const Face &f) const 1.18 +{ 1.19 + for(int i=0; i<3; i++) { 1.20 + for(int j=0; j<3; j++) { 1.21 + if(!FEQ(v[i].pos[j], f.v[i].pos[j])) { 1.22 + return false; 1.23 + } 1.24 + if(!FEQ(v[i].normal[j], f.v[i].normal[j])) { 1.25 + return false; 1.26 + } 1.27 + } 1.28 + if(!FEQ(normal[i], f.normal[i])) { 1.29 + return false; 1.30 + } 1.31 + } 1.32 + return true; 1.33 +} 1.34 + 1.35 bool Scene::add_mesh(Mesh *m) 1.36 { 1.37 // make sure triangles have material ids