ccdemos/common_ply.h
branchpyrit
changeset 80 907929fa9b59
parent 72 7c3f38dff082
child 91 9d66d323c354
--- a/ccdemos/common_ply.h	Wed Apr 23 14:39:33 2008 +0200
+++ b/ccdemos/common_ply.h	Wed Apr 23 19:35:03 2008 +0200
@@ -57,7 +57,17 @@
 			continue;
 		}
 		f >> v1 >> v2 >> v3;
-		face = new Triangle(vertices.at(v1), vertices.at(v3), vertices.at(v2), mat);
+
+		// check for invalid faces and ignore them
+		if (vertices[v1]->P == vertices[v2]->P
+		 || vertices[v1]->P == vertices[v3]->P
+		 || vertices[v2]->P == vertices[v3]->P)
+		{
+			f.ignore(1000,'\n');
+			continue;
+		}
+
+		face = new Triangle(vertices[v1], vertices[v3], vertices[v2], mat);
 		rt.addShape(face);
 
 		normals.at(v1) += face->getNormal();