From: Peter Sadrozinski Date: Sat, 27 Dec 2014 18:02:49 +0000 (-0500) Subject: - fix binobj unit test. Simgear now rejects zero area triangles in .btg files, and... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=32b60f9b8012d7c588208b4d1c910371eb288476;p=simgear.git - fix binobj unit test. Simgear now rejects zero area triangles in .btg files, and the unit test could generate them. --- diff --git a/simgear/io/test_binobj.cxx b/simgear/io/test_binobj.cxx index f51a9a19..c41075dc 100644 --- a/simgear/io/test_binobj.cxx +++ b/simgear/io/test_binobj.cxx @@ -93,13 +93,36 @@ void compareTexCoords(const SGBinObject& rd, const std::vector& 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; }