]> git.mxchange.org Git - simgear.git/commitdiff
- fix binobj unit test. Simgear now rejects zero area triangles in .btg files, and...
authorPeter Sadrozinski <psadrozinski@gmail.com>
Sat, 27 Dec 2014 18:02:49 +0000 (13:02 -0500)
committerPeter Sadrozinski <psadrozinski@gmail.com>
Sat, 27 Dec 2014 18:08:53 +0000 (13:08 -0500)
simgear/io/test_binobj.cxx

index f51a9a19980fd58e14da691fd93b3e35c4e6caae..c41075dca5d1a83184f938149de4b2e0c454cc58 100644 (file)
@@ -93,13 +93,36 @@ void compareTexCoords(const SGBinObject& rd, const std::vector<SGVec2f>& b)
         VERIFY(equivalent(pos, b[i], 0.001f));        
     }
 }
+
 int_list make_tri(int maxIndex)
 {
     int_list r;
-    r.push_back(random() % maxIndex);
-    r.push_back(random() % maxIndex);
-    r.push_back(random() % maxIndex);
+    int a, b, c;
+        
+    bool valid = false;
+    int retry  = 10;
+    
+    while(!valid && retry--) {
+        a = (random() % maxIndex);
+        b = (random() % maxIndex);
+        c = (random() % maxIndex);
+    
+        valid = ( (a!=b) && (b!=c) && (c!=a) );
+        
+        if (!valid) {
+            num_invalid++;
+        }
+    }
+    
+    if (!valid) {
+        cerr << "can't generate valid triangle" << endl;
+        exit(1);
+    }
+    
+    r.push_back(a);
+    r.push_back(b);
+    r.push_back(c);
+    
     return r;
 }