This commit is contained in:
@@ -12,25 +12,47 @@ using namespace maths;
|
||||
|
||||
#define let auto // sexy boiiii
|
||||
|
||||
static void test_basic() {
|
||||
static void test_left() {
|
||||
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
|
||||
let ray = Ray { {-3.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f} };
|
||||
let ray = Ray { {-2.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f} };
|
||||
|
||||
blitz_test_assert(Distance(ray, box));
|
||||
blitz_test_assert(Intersects(ray, box));
|
||||
}
|
||||
|
||||
static void test_right() {
|
||||
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
|
||||
let ray = Ray { {2.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f} };
|
||||
|
||||
blitz_test_assert(Intersects(ray, box));
|
||||
}
|
||||
|
||||
static void test_forward() {
|
||||
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
|
||||
let ray = Ray { {0.0f, 2.0f, 0.0f}, {0.0f, -1.0f, 0.0f} };
|
||||
|
||||
blitz_test_assert(Intersects(ray, box));
|
||||
}
|
||||
|
||||
static void test_backward() {
|
||||
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
|
||||
let ray = Ray { {0.0f, -2.0f, 0.0f}, {0.0f, 1.0f, 0.0f} };
|
||||
|
||||
blitz_test_assert(Intersects(ray, box));
|
||||
}
|
||||
|
||||
static void test_shifted() {
|
||||
|
||||
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
|
||||
let ray = Ray { {-3.0f, 0.0f, 100.0f}, {1.0f, 0.0f, 0.0f} };
|
||||
|
||||
blitz_test_assert(!Distance(ray, box));
|
||||
blitz_test_assert(!Intersects(ray, box));
|
||||
}
|
||||
|
||||
int main(int argc, const char* args[]) {
|
||||
test_basic();
|
||||
test_left();
|
||||
test_right();
|
||||
test_forward();
|
||||
test_backward();
|
||||
test_shifted();
|
||||
return BLITZ_TEST_SUCCESSFUL;
|
||||
}
|
||||
Reference in New Issue
Block a user