X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=tst%2Fmodel%2FGeometryTest.cpp;fp=tst%2Fmodel%2FGeometryTest.cpp;h=3776da14fd0172eac29a59a7bd8e9a7d6d8d8095;hb=7d3ab0dcce7abb6d5f766315685424e82478212f;hp=0000000000000000000000000000000000000000;hpb=d71d636af8b6f493abe537088464d1dc6b816c04;p=blank.git diff --git a/tst/model/GeometryTest.cpp b/tst/model/GeometryTest.cpp new file mode 100644 index 0000000..3776da1 --- /dev/null +++ b/tst/model/GeometryTest.cpp @@ -0,0 +1,41 @@ +#include "GeometryTest.hpp" + +#include "model/geometry.hpp" + +#include + +CPPUNIT_TEST_SUITE_REGISTRATION(blank::test::GeometryTest); + + +namespace blank { +namespace test { + +void GeometryTest::setUp() { +} + +void GeometryTest::tearDown() { +} + + +void GeometryTest::testRayAABBIntersection() { + Ray ray{ { 0, 0, 0 }, { 1, 0, 0 } }; // at origin, pointing right + AABB box{ { -1, -1, -1 }, { 1, 1, 1 } }; // 2x2x2 cube centered around origin + glm::mat4 M(1); // no transformation + + const float delta = std::numeric_limits::epsilon(); + + float distance = 0; + glm::vec3 normal(0); + + CPPUNIT_ASSERT_MESSAGE( + "ray at origin not intersecting box at origin", + Intersection(ray, box, M, &distance, &normal) + ); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "intersection distance way off", + 0.0f, distance, delta + ); +} + +} +}