diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-28 15:42:50 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-28 15:42:50 +0000 |
commit | de9909df038d1b6bb47bcc82fea5f8dc9dec2491 (patch) | |
tree | b1f1337603c1bda68760d3f5f5147bc345e3e77f /test/test-maths.cpp | |
parent | Component position mouse click check should only match mouse button events (diff) | |
download | ilt-de9909df038d1b6bb47bcc82fea5f8dc9dec2491.tar.bz2 ilt-de9909df038d1b6bb47bcc82fea5f8dc9dec2491.tar.xz ilt-de9909df038d1b6bb47bcc82fea5f8dc9dec2491.zip |
Initial implementation for being able to click in the main window to select something
Diffstat (limited to 'test/test-maths.cpp')
-rw-r--r-- | test/test-maths.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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 <type_traits> #include <game/network/link.h> +#include <gfx/gl/camera.h> #include <glm/glm.hpp> #include <maths.h> #include <tuple> @@ -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)); +} |