diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-02-24 00:27:49 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-02-24 00:27:49 +0000 |
commit | 744e6ad2fb88671800e39db33d08b2cd451c8338 (patch) | |
tree | 563da22ef0240131fe0540e9ccc3fed5d10fc9a2 /test/test-geoData.cpp | |
parent | Simplify vector addition/subtraction with differnt types (diff) | |
parent | First cut of terrain deformation (diff) | |
download | ilt-744e6ad2fb88671800e39db33d08b2cd451c8338.tar.bz2 ilt-744e6ad2fb88671800e39db33d08b2cd451c8338.tar.xz ilt-744e6ad2fb88671800e39db33d08b2cd451c8338.zip |
Psycho-rebased branch deform-terrain on top of main
Diffstat (limited to 'test/test-geoData.cpp')
-rw-r--r-- | test/test-geoData.cpp | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 302cab7..ac1d668 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -1,7 +1,12 @@ #define BOOST_TEST_MODULE terrain +#include "game/terrain.h" +#include "test/testMainWindow.h" +#include "test/testRenderOutput.h" #include "testHelpers.h" +#include "ui/applicationBase.h" #include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> +#include <gfx/gl/sceneRenderer.h> #include <stream_support.h> #include <game/geoData.h> @@ -114,7 +119,7 @@ BOOST_DATA_TEST_CASE(findRayIntersect, }), p, d, i) { - BOOST_CHECK_EQUAL(fixedTerrtain.intersectRay({p, d}).value(), i); + BOOST_CHECK_EQUAL(fixedTerrtain.intersectRay({p, d})->first, i); } BOOST_AUTO_TEST_CASE(boundaryWalk) @@ -199,3 +204,58 @@ BOOST_DATA_TEST_CASE(findEntries, { BOOST_CHECK_EQUAL(fixedTerrtain.findEntry(from, to).idx(), heh); } + +BOOST_AUTO_TEST_CASE(setTriangle, *boost::unit_test::timeout(5)) +{ + auto gd = std::make_shared<GeoData>(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})); + + struct TestTerrain : public SceneProvider { + explicit TestTerrain(std::shared_ptr<GeoData> gd) : terrain(std::move(gd)) { } + + const Terrain terrain; + + void + content(const SceneShader & shader) const override + { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + terrain.render(shader); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + + void + environment(const SceneShader &, const SceneRenderer & sr) const override + { + sr.setAmbientLight({0.1, 0.1, 0.1}); + sr.setDirectionalLight({1, 1, 1}, south + down, *this); + } + + void + lights(const SceneShader &) const override + { + } + + void + shadows(const ShadowMapper & shadowMapper) const override + { + terrain.shadows(shadowMapper); + } + }; + + TestTerrain t {gd}; + BOOST_CHECK_NO_THROW(ss.render(t)); + Texture::save(tro.outImage, "/tmp/geoData.tga"); +} |