From 848fc7fe1349c36c839b3642f9607ba80ffe4e8e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 26 Feb 2024 01:42:26 +0000 Subject: Make terrain deformation test a data test Easily test multiple deformations and view them from different angles --- test/test-geoData.cpp | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index ac1d668..e1f8fce 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -205,23 +205,41 @@ BOOST_DATA_TEST_CASE(findEntries, BOOST_CHECK_EQUAL(fixedTerrtain.findEntry(from, to).idx(), heh); } -BOOST_AUTO_TEST_CASE(setTriangle, *boost::unit_test::timeout(5)) +using DeformTerrainData + = std::tuple, std::vector, const char *>>>; + +template +std::ostream & +operator<<(std::ostream & s, const Ray & ray) +{ + return s << "Ray" << std::make_pair(ray.start, ray.direction); +} + +BOOST_DATA_TEST_CASE(setTriangle, + boost::unit_test::data::make({ + {{ + {70100, 123000, 6000}, + {50100, 52300, 6000}, + {191000, 283000, 8000}, + {241000, 123330, -2000}, + }, + { + {{{20000, 20000, 90000}, glm::normalize(Direction3D {1, 1, -1.5F})}, + "/tmp/geoData0.tga"}, + {{{30000, 164000, 90000}, glm::normalize(Direction3D {1, -1, -1.5F})}, + "/tmp/geoData1.tga"}, + {{{288000, 162000, 90000}, glm::normalize(Direction3D {-1, -1, -1.5F})}, + "/tmp/geoData2.tga"}, + }}, + }), + points, cams) { auto gd = std::make_shared(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100)); - std::array points { - GlobalPosition3D {70100, 123000, 6000}, - GlobalPosition3D {50100, 52300, 6000}, - GlobalPosition3D {191000, 283000, 8000}, - GlobalPosition3D {241000, 123330, -2000}, - }; BOOST_CHECK_NO_THROW(gd->setHeights(points)); ApplicationBase ab; TestMainWindow tmw; - TestRenderOutput tro {{1792, 1024}}; - - SceneRenderer ss {tro.size, tro.output}; - ss.camera.setView({-90000, -90000, 300000}, glm::normalize(glm::vec3 {1, 1, -1.5F})); + TestRenderOutput tro {{640, 480}}; struct TestTerrain : public SceneProvider { explicit TestTerrain(std::shared_ptr gd) : terrain(std::move(gd)) { } @@ -256,6 +274,10 @@ BOOST_AUTO_TEST_CASE(setTriangle, *boost::unit_test::timeout(5)) }; TestTerrain t {gd}; - BOOST_CHECK_NO_THROW(ss.render(t)); - Texture::save(tro.outImage, "/tmp/geoData.tga"); + SceneRenderer ss {tro.size, tro.output}; + std::for_each(cams.begin(), cams.end(), [&ss, &t, &tro](const auto & cam) { + ss.camera.setView(cam.first.start, cam.first.direction); + BOOST_CHECK_NO_THROW(ss.render(t)); + Texture::save(tro.outImage, cam.second); + }); } -- cgit v1.2.3