diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-03 18:37:09 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-01-03 18:37:09 +0000 |
commit | d33f528f17ed1be17aca82e5c0bc9f39c1d496ae (patch) | |
tree | 17f37991e09d8d7345557e6a6d24a16ab8032d87 /test/test-geo.cpp | |
parent | More complete and tested stream output support (diff) | |
download | ilt-d33f528f17ed1be17aca82e5c0bc9f39c1d496ae.tar.bz2 ilt-d33f528f17ed1be17aca82e5c0bc9f39c1d496ae.tar.xz ilt-d33f528f17ed1be17aca82e5c0bc9f39c1d496ae.zip |
Support for querying terrain height in GeoData
Diffstat (limited to 'test/test-geo.cpp')
-rw-r--r-- | test/test-geo.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/test-geo.cpp b/test/test-geo.cpp index b6f276a..a28b83a 100644 --- a/test/test-geo.cpp +++ b/test/test-geo.cpp @@ -69,3 +69,28 @@ BOOST_FIXTURE_TEST_CASE(load_uk_heightmap, TestGeoData) return n.height > 0; })); } + +BOOST_FIXTURE_TEST_CASE(get_height_at, TestGeoData) +{ + // at(x,y) is index based + nodes[at(0, 0)].height = 1; + nodes[at(1, 0)].height = 2; + nodes[at(0, 1)].height = 3; + nodes[at(1, 1)].height = 4; + + // positionAt(x,y) is world based + // Corners + BOOST_CHECK_EQUAL(positionAt({0, 0}), glm::vec3(0, 0, 1)); + BOOST_CHECK_EQUAL(positionAt({5, 0}), glm::vec3(5, 0, 2)); + BOOST_CHECK_EQUAL(positionAt({0, 5}), glm::vec3(0, 5, 3)); + BOOST_CHECK_EQUAL(positionAt({5, 5}), glm::vec3(5, 5, 4)); + + // Edge midpoints + BOOST_CHECK_EQUAL(positionAt({0, 2.5F}), glm::vec3(0, 2.5F, 2)); + BOOST_CHECK_EQUAL(positionAt({5, 2.5F}), glm::vec3(5, 2.5F, 3)); + BOOST_CHECK_EQUAL(positionAt({2.5F, 0}), glm::vec3(2.5F, 0, 1.5F)); + BOOST_CHECK_EQUAL(positionAt({2.5F, 5}), glm::vec3(2.5F, 5, 3.5F)); + + // Centre + BOOST_CHECK_EQUAL(positionAt({2.5F, 2.5F}), glm::vec3(2.5F, 2.5F, 2.5F)); +} |