X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=tst%2Fgeometry%2FIntersectionTest.cpp;fp=tst%2Fgeometry%2FIntersectionTest.cpp;h=36cacdfa8bd309293c8224a0da636f9dd544e34d;hb=bda41b98427c8d34f954dae0dcaf261c5ad6cb43;hp=d2332fe7f74b7ddb55ee2a449b0fdb9459788411;hpb=d220b0348951ce210ad4ea18dbe9934dd2999a60;p=gong.git diff --git a/tst/geometry/IntersectionTest.cpp b/tst/geometry/IntersectionTest.cpp index d2332fe..36cacdf 100644 --- a/tst/geometry/IntersectionTest.cpp +++ b/tst/geometry/IntersectionTest.cpp @@ -21,6 +21,64 @@ void IntersectionTest::tearDown() { } +void IntersectionTest::testAABB() { + AABB a{ { -1, -1, -1 }, { 1, 1, 1 } }; + AABB b(a); + + CPPUNIT_ASSERT_MESSAGE( + "coincidental AABBs should intersect", + Intersection(a, b) + ); + + b.Move({ 1, 0, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should intersect", + Intersection(a, b) + ); + + b.Move({ 2, 0, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should not intersect", + !Intersection(a, b) + ); + + b.Move({ -4, 0, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should intersect", + Intersection(a, b) + ); + + b.Move({ -2, 0, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should not intersect", + !Intersection(a, b) + ); + + b.Move({ 3, 1, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should intersect", + Intersection(a, b) + ); + + b.Move({ 0, 2, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should not intersect", + !Intersection(a, b) + ); + + b.Move({ 2, 0, 0 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should not intersect", + !Intersection(a, b) + ); + + b.Move({ 0, 0, 2 }); + CPPUNIT_ASSERT_MESSAGE( + "AABBs should not intersect", + !Intersection(a, b) + ); +} + void IntersectionTest::testSimpleRayBox() { Ray ray{ { 0, 0, 0 }, { 1, 0, 0 }, { } }; // at origin, pointing right ray.Update();