From c20c5167510758353d5a62cfff24fd5494b9c5a4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 13 Dec 2022 12:14:43 +0000 Subject: Add Camera method to get the extents of the view frustrum at some distance --- test/test-render.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') 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 #include #include +#include #include #include @@ -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) -- cgit v1.2.3