summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2022-12-13 12:14:43 +0000
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2022-12-13 12:14:43 +0000
commitc20c5167510758353d5a62cfff24fd5494b9c5a4 (patch)
tree2b249e1c94fe26593ea22972b486553da8b57bda /test
parentCalculate an accurate up vector for the camera (diff)
downloadilt-c20c5167510758353d5a62cfff24fd5494b9c5a4.tar.bz2
ilt-c20c5167510758353d5a62cfff24fd5494b9c5a4.tar.xz
ilt-c20c5167510758353d5a62cfff24fd5494b9c5a4.zip
Add Camera method to get the extents of the view frustrum at some distance
Diffstat (limited to 'test')
-rw-r--r--test/test-render.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test-render.cpp b/test/test-render.cpp
index 77501ac..1150a67 100644
--- a/test/test-render.cpp
+++ b/test/test-render.cpp
@@ -10,6 +10,7 @@
#include <gfx/models/texture.h>
#include <lib/glArrays.h>
#include <maths.h>
+#include <stream_support.hpp>
#include <ui/applicationBase.h>
#include <ui/window.h>
@@ -95,6 +96,22 @@ class TestScene : public SceneProvider {
BOOST_GLOBAL_FIXTURE(ApplicationBase);
BOOST_GLOBAL_FIXTURE(TestMainWindow);
+BOOST_DATA_TEST_CASE(cam,
+ boost::unit_test::data::xrange(0.5F, 30.F, 1.3F) * boost::unit_test::data::xrange(0.5F, 10.F, 0.3F)
+ * boost::unit_test::data::xrange(50.F, 500.F, 70.F),
+ dist, near, far)
+{
+ static constexpr glm::vec3 pos {-10, -10, 60};
+ Camera cam {pos, half_pi, 1.f, near, far};
+
+ const auto e = cam.extentsAtDist(dist);
+
+ BOOST_CHECK_CLOSE_VEC(e[0], pos + glm::vec3(-dist, dist, -dist));
+ BOOST_CHECK_CLOSE_VEC(e[1], pos + glm::vec3(-dist, dist, dist));
+ BOOST_CHECK_CLOSE_VEC(e[2], pos + glm::vec3(dist, dist, -dist));
+ BOOST_CHECK_CLOSE_VEC(e[3], pos + glm::vec3(dist, dist, dist));
+}
+
BOOST_FIXTURE_TEST_SUITE(w, TestRenderOutput);
BOOST_AUTO_TEST_CASE(basic)