2024-05-29 16:29:08 +10:00
|
|
|
#include <cruft/util/tap.hpp>
|
2018-03-13 22:37:40 +11:00
|
|
|
|
2024-05-29 16:29:08 +10:00
|
|
|
#include <cruft/util/geom/frustum.hpp>
|
|
|
|
#include <cruft/util/geom/aabb.hpp>
|
|
|
|
#include <cruft/util/matrix.hpp>
|
2018-03-13 22:37:40 +11:00
|
|
|
|
2024-05-29 16:29:08 +10:00
|
|
|
#include <cruft/util/geom/iostream.hpp>
|
2018-03-22 16:10:06 +11:00
|
|
|
|
2018-03-13 22:37:40 +11:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::TAP::logger tap;
|
2018-03-13 22:37:40 +11:00
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
const cruft::geom::frustum3f origin90 (
|
|
|
|
cruft::perspective (cruft::to_radians (90.f), 1.f, {0.01f, 1.f})
|
2018-03-13 22:37:40 +11:00
|
|
|
);
|
|
|
|
|
|
|
|
static const struct {
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::geom::aabb3f box;
|
2018-03-13 22:37:40 +11:00
|
|
|
bool intersects;
|
|
|
|
const char *message;
|
|
|
|
} TESTS[] = {
|
|
|
|
{ { { -1, -1, -1 }, { 1, 1, 1 } }, true, "covers origin with unit radius" },
|
|
|
|
{ { { -9, -9, -9 }, { -8, -8, -8 } }, false, "out of view negative" },
|
|
|
|
{ { { -1, -1, 2 }, { 1, 1, 3 } }, false, "past far plane" },
|
2018-03-28 20:42:43 +11:00
|
|
|
{ { { 0, 0, 0 }, { 0, 0, 0 } }, false, "before near plane" },
|
2018-03-13 22:37:40 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
for (const auto &t: TESTS) {
|
2021-04-13 16:05:08 +10:00
|
|
|
tap.expect_eq (intersects (origin90, t.box), t.intersects, "origin frustrum, {:s}", t.message);
|
2018-03-13 22:37:40 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
return tap.status ();
|
|
|
|
};
|