summaryrefslogtreecommitdiff
path: root/test/test-maths.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 21:07:37 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-02 21:07:37 +0000
commit7c8b8a39fd36e190578587d8d92f28f460a1fc4b (patch)
tree03c0943bcec657992aa92afb91a3613eb1c8423b /test/test-maths.cpp
parentNo need to pass GameState around, it has a global pointer (diff)
downloadilt-7c8b8a39fd36e190578587d8d92f28f460a1fc4b.tar.bz2
ilt-7c8b8a39fd36e190578587d8d92f28f460a1fc4b.tar.xz
ilt-7c8b8a39fd36e190578587d8d92f28f460a1fc4b.zip
Encapsulate Ray
Diffstat (limited to 'test/test-maths.cpp')
-rw-r--r--test/test-maths.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/test/test-maths.cpp b/test/test-maths.cpp
index 86cb7b8..1f2a096 100644
--- a/test/test-maths.cpp
+++ b/test/test-maths.cpp
@@ -254,35 +254,36 @@ BOOST_DATA_TEST_CASE(curve1,
BOOST_AUTO_TEST_CASE(camera_clicks)
{
- Camera camera {{0, 0, 0}, ::half_pi, 1.25F, .1F, 10000.F};
+ Camera camera {::origin, ::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));
+ BOOST_CHECK_EQUAL(camera.unProject({centre, centre}).start, ::origin);
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, ::north);
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}).direction, glm::normalize(::north + ::west));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}).direction, glm::normalize(::north + ::east));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}).direction, glm::normalize(::north + ::up));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, bottom}).direction, glm::normalize(::north + ::down));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({left, top}).direction, glm::normalize(::north + ::west + ::up));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({right, top}).direction, glm::normalize(::north + ::east + ::up));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({left, bottom}).direction, glm::normalize(::north + ::west + ::down));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({right, bottom}).direction, 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));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, ::east);
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}).direction, glm::normalize(::north + ::east));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}).direction, 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));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, glm::normalize(::north + ::down));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}).direction, 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));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, glm::normalize(::north + ::west + ::down));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}).direction, 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));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, glm::normalize(::north + ::west));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, top}).direction, glm::normalize(::north + ::west + ::up * 1.2F));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}).direction, glm::normalize(::north));
+ BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}).direction, glm::normalize(::west));
}