Commit fc01d804 authored by Julian Schakib's avatar Julian Schakib
Browse files

any_point and plane aabb intersection

parent 52b969c4
Pipeline #13774 failed with stage
in 6 minutes and 19 seconds
typed-geometry @ 2644a88c
Subproject commit f98a78e690b49be701eb4dd6f6415e8c697130fd
Subproject commit 2644a88c77be3d83a79e518ffe64d7a2ce567513
......@@ -226,7 +226,7 @@ TG_FUZZ_TEST(Plane, Intersect)
// all above triangle in plane
c = {center + n + bi, center + n, center + n + t};
// check all possible orders
// all 6 possible orderings
for (auto i = 0; i < 3; i++)
{
triangle = tg::triangle(c[(i + 0) % 3], c[(i + 1) % 3], c[(i + 2) % 3]);
......@@ -238,7 +238,7 @@ TG_FUZZ_TEST(Plane, Intersect)
// all below triangle in plane
c = {center - n + bi, center - n, center - n + t};
// check all possible orders
// all 6 possible orderings
for (auto i = 0; i < 3; i++)
{
triangle = tg::triangle(c[(i + 0) % 3], c[(i + 1) % 3], c[(i + 2) % 3]);
......@@ -250,7 +250,7 @@ TG_FUZZ_TEST(Plane, Intersect)
// 2 on 1 side
c = {center - n + bi, center + n, center - n + t};
// check all possible orders
// all 6 possible orderings
for (auto i = 0; i < 3; i++)
{
triangle = tg::triangle(c[(i + 0) % 3], c[(i + 1) % 3], c[(i + 2) % 3]);
......@@ -259,5 +259,66 @@ TG_FUZZ_TEST(Plane, Intersect)
triangle = tg::triangle(c[(i + 1) % 3], c[(i + 0) % 3], c[(i + 2) % 3]);
CHECK(intersects(plane, triangle));
}
// 2 on 1 side
c = {center + n + bi, center - n, center + n + t};
// all 6 possible orderings
for (auto i = 0; i < 3; i++)
{
triangle = tg::triangle(c[(i + 0) % 3], c[(i + 1) % 3], c[(i + 2) % 3]);
CHECK(intersects(plane, triangle));
triangle = tg::triangle(c[(i + 1) % 3], c[(i + 0) % 3], c[(i + 2) % 3]);
CHECK(intersects(plane, triangle));
}
}
// plane3 - aabb3
{
auto const size = 10;
auto const box = tg::aabb3(tg::pos3(-size), tg::pos3(size));
auto const center = tg::pos3::zero;
auto const n = tg::dir3::pos_y; // tg::uniform<tg::dir3>(rng);
auto plane = tg::plane3(n, center);
CHECK(intersects(box, plane));
plane = tg::plane3(n, center + n * (size + 0.1f));
CHECK(!intersects(box, plane));
plane = tg::plane3(n, center - n * (size + 0.1f));
CHECK(!intersects(box, plane));
plane = tg::plane3(tg::dir3::pos_x, center + tg::dir3::pos_x * (size + 0.1f));
CHECK(!intersects(plane, box));
plane = tg::plane3(tg::dir3::neg_x, center + tg::dir3::pos_x * (size + 0.1f));
CHECK(!intersects(plane, box));
plane = tg::plane3(tg::dir3::neg_x, center + tg::dir3::pos_x * (size - 0.1f));
CHECK(intersects(plane, box));
plane = tg::plane3(normalize(tg::vec3(1, 1, 0)), tg::pos3(size + 0.1f));
CHECK(!intersects(plane, box));
plane = tg::plane3(normalize(tg::vec3(1, 1, 0)), tg::pos3(size - 0.1f));
CHECK(intersects(plane, box));
{
auto const offset = uniform(rng, box) * 100;
plane = tg::plane3(any_normal(tg::vec3(offset)), offset);
CHECK(intersects(plane, box));
}
{
auto const offset = uniform(rng, box) * 100;
plane = tg::plane3(normalize(tg::vec3(offset)), offset);
CHECK(!intersects(plane, box));
plane = tg::plane3(-normalize(tg::vec3(offset)), offset);
CHECK(!intersects(plane, box));
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment