adjusted BVH improved 2D/3D BVH new bounding volumes new test cases renamed some test-cases for grouping reasons made GPC header-only using slight adjustments
64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
#ifdef WITH_TESTS
|
|
|
|
#include "../Tests.h"
|
|
|
|
#include "../../geo/BBox2.h"
|
|
|
|
TEST(Geo_BBox2, noIntersect) {
|
|
|
|
BBox2 bb(Point2(1,1), Point2(3,3));
|
|
|
|
Line2 l1(Point2(0,0), Point2(9,0)); // below
|
|
Line2 l2(Point2(0,4), Point2(9,4)); // above
|
|
|
|
Line2 l3(Point2(0,0), Point2(0,9)); // left
|
|
Line2 l4(Point2(4,0), Point2(4,9)); // right
|
|
|
|
ASSERT_FALSE(bb.intersects(l1));
|
|
ASSERT_FALSE(bb.intersects(l2));
|
|
ASSERT_FALSE(bb.intersects(l3));
|
|
ASSERT_FALSE(bb.intersects(l4));
|
|
|
|
}
|
|
|
|
/*
|
|
TEST(Geo_BBox2, noDirectIntersect) {
|
|
|
|
BBox2 bb(Point2(1,1), Point2(3,3));
|
|
|
|
Line2 l1(Point2(0,1), Point2(9,1)); // lower
|
|
Line2 l2(Point2(0,3), Point2(9,3)); // upper
|
|
|
|
Line2 l3(Point2(1,0), Point2(1,9)); // left
|
|
Line2 l4(Point2(3,0), Point2(3,9)); // right
|
|
|
|
ASSERT_FALSE(bb.intersects(l1));
|
|
ASSERT_FALSE(bb.intersects(l2));
|
|
ASSERT_FALSE(bb.intersects(l3));
|
|
ASSERT_FALSE(bb.intersects(l4));
|
|
|
|
}
|
|
*/
|
|
|
|
|
|
TEST(Geo_BBox2, positiveIntersect) {
|
|
|
|
BBox2 bb(Point2(1,1), Point2(3,3));
|
|
|
|
Line2 l1(Point2(0,2), Point2(2,2)); // left hit
|
|
Line2 l2(Point2(2,2), Point2(4,2)); // right hit
|
|
|
|
Line2 l3(Point2(2,0), Point2(2,2)); // lower hit
|
|
Line2 l4(Point2(2,2), Point2(2,4)); // upper hit
|
|
|
|
ASSERT_TRUE(bb.intersects(l1));
|
|
ASSERT_TRUE(bb.intersects(l2));
|
|
ASSERT_TRUE(bb.intersects(l3));
|
|
ASSERT_TRUE(bb.intersects(l4));
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|