X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=tst%2Fmodel%2FGeometryTest.cpp;fp=tst%2Fmodel%2FGeometryTest.cpp;h=51985aef7a70e38df8df09051d44911adf02cd72;hb=c592d2d6e230851bd7ed74d98f9046469f4086fd;hp=3776da14fd0172eac29a59a7bd8e9a7d6d8d8095;hpb=7d3ab0dcce7abb6d5f766315685424e82478212f;p=blank.git diff --git a/tst/model/GeometryTest.cpp b/tst/model/GeometryTest.cpp index 3776da1..51985ae 100644 --- a/tst/model/GeometryTest.cpp +++ b/tst/model/GeometryTest.cpp @@ -3,6 +3,7 @@ #include "model/geometry.hpp" #include +#include CPPUNIT_TEST_SUITE_REGISTRATION(blank::test::GeometryTest); @@ -29,12 +30,36 @@ void GeometryTest::testRayAABBIntersection() { CPPUNIT_ASSERT_MESSAGE( "ray at origin not intersecting box at origin", - Intersection(ray, box, M, &distance, &normal) + Intersection(ray, box, M, &distance) ); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "intersection distance way off", 0.0f, distance, delta ); + // normal undefined, so can't test + + // move ray outside the box, but have it still point at it + // should be 4 units to the left now + ray.orig.x = -5; + CPPUNIT_ASSERT_MESSAGE( + "ray pointing at box doesn't intersect", + Intersection(ray, box, M, &distance, &normal) + ); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( + "intersection distance way off", + 4.0f, distance, delta + ); + CPPUNIT_ASSERT_EQUAL_MESSAGE( + "wrong surface normal at intersection point", + glm::vec3(-1, 0, 0), normal + ); + + // move ray to the other side, so it's pointing away now + ray.orig.x = 5; + CPPUNIT_ASSERT_MESSAGE( + "ray pointing away from box still intersects", + !Intersection(ray, box, M) + ); } }