From 32b60f9b8012d7c588208b4d1c910371eb288476 Mon Sep 17 00:00:00 2001 From: Peter Sadrozinski Date: Sat, 27 Dec 2014 13:02:49 -0500 Subject: [PATCH] - fix binobj unit test. Simgear now rejects zero area triangles in .btg files, and the unit test could generate them. --- simgear/io/test_binobj.cxx | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) 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; } -- 2.39.5