diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-05 15:37:13 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-05 15:37:13 +0000 |
commit | acca54f3a12225454633dca2d56506c0dcebb653 (patch) | |
tree | 9b1367a07582cd8d6dffae58478d5ee832170b4e | |
parent | Fix and split linesCross (diff) | |
download | ilt-acca54f3a12225454633dca2d56506c0dcebb653.tar.bz2 ilt-acca54f3a12225454633dca2d56506c0dcebb653.tar.xz ilt-acca54f3a12225454633dca2d56506c0dcebb653.zip |
Fix calculating extents
-rw-r--r-- | game/geoData.cpp | 4 | ||||
-rw-r--r-- | test/test-geoData.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index 78f753f..781b41e 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -25,8 +25,8 @@ GeoData::loadFromAsciiGrid(const std::filesystem::path & input) vertices.reserve(ncols * nrows); GeoData mesh; mesh.lowerExtent = {xllcorner, yllcorner, std::numeric_limits<float>::max()}; - mesh.upperExtent - = {xllcorner + (cellsize * ncols), yllcorner + (cellsize * nrows), std::numeric_limits<float>::min()}; + mesh.upperExtent = {xllcorner + (cellsize * (ncols - 1)), yllcorner + (cellsize * (nrows - 1)), + std::numeric_limits<float>::min()}; for (size_t row = 0; row < nrows; ++row) { for (size_t col = 0; col < ncols; ++col) { float height = 0; diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 34c9cb6..2ea9b26 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(loadSuccess) BOOST_CHECK_EQUAL(2 * (ncols - 1) * (nrows - 1), n_faces()); const auto [lower, upper] = getExtents(); BOOST_CHECK_EQUAL(lower, glm::vec3(310000, 490000, -2.6)); - BOOST_CHECK_EQUAL(upper, glm::vec3(320000, 500000, 571.6)); + BOOST_CHECK_EQUAL(upper, glm::vec3(319950, 499950, 571.6)); } BOOST_AUTO_TEST_CASE(normalsAllPointUp) |