From de9909df038d1b6bb47bcc82fea5f8dc9dec2491 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 28 Dec 2021 15:42:50 +0000 Subject: Initial implementation for being able to click in the main window to select something --- test/test-maths.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index edc3e60..86cb7b8 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -250,3 +251,38 @@ BOOST_DATA_TEST_CASE(curve1, } } } + +BOOST_AUTO_TEST_CASE(camera_clicks) +{ + Camera camera {{0, 0, 0}, ::half_pi, 1.25F, .1F, 10000.F}; + constexpr float centre {0.5F}, right {0.9F}, left {0.1F}, top {1.F}, bottom {0.F}; + camera.forward = ::north; + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}), ::north); + BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}), glm::normalize(::north + ::west)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}), glm::normalize(::north + ::east)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}), glm::normalize(::north + ::up)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, bottom}), glm::normalize(::north + ::down)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({left, top}), glm::normalize(::north + ::west + ::up)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({right, top}), glm::normalize(::north + ::east + ::up)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({left, bottom}), glm::normalize(::north + ::west + ::down)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({right, bottom}), glm::normalize(::north + ::east + ::down)); + + camera.forward = ::east; + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}), ::east); + BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}), glm::normalize(::north + ::east)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}), glm::normalize(::south + ::east)); + + camera.forward = glm::normalize(::north + ::down); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}), glm::normalize(::north + ::down)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}), glm::normalize(::north)); + + camera.forward = glm::normalize(::north + ::west + ::down); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}), glm::normalize(::north + ::west + ::down)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}), glm::normalize(::north + ::west + ::up * 0.2F)); + + camera.forward = glm::normalize(::north + ::west); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}), glm::normalize(::north + ::west)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}), glm::normalize(::north + ::west + ::up * 1.2F)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}), glm::normalize(::north)); + BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}), glm::normalize(::west)); +} -- cgit v1.2.3