Commit 6f48ec28 authored by Julian Schakib's avatar Julian Schakib
Browse files

obb intersection tests

parent fc01d804
Pipeline #13778 failed with stage
in 5 minutes and 48 seconds
typed-geometry @ 71aeccbb
Subproject commit 2644a88c77be3d83a79e518ffe64d7a2ce567513
Subproject commit 71aeccbb4212dc12be6b1ff4eb14827d0a53feba
......@@ -320,5 +320,44 @@ TG_FUZZ_TEST(Plane, Intersect)
plane = tg::plane3(-normalize(tg::vec3(offset)), offset);
CHECK(!intersects(plane, box));
}
// any plane inside the aabb (should intersect)
{
plane = tg::plane3(tg::uniform<tg::dir3>(rng), uniform(rng, box));
CHECK(intersects(plane, box));
}
}
// plane3 - box3
{
auto half_extents = tg::mat3();
half_extents[0] = tg::dir3::pos_x;
half_extents[1] = tg::dir3::pos_y;
half_extents[2] = tg::dir3::pos_z;
auto box = tg::box3(tg::pos3::zero, half_extents);
{
auto const plane = tg::plane3(tg::uniform<tg::dir3>(rng), tg::pos3::zero);
CHECK(intersects(plane, box));
}
{
auto plane = tg::plane3(tg::dir3::pos_x, tg::pos3(1, 0, 0));
CHECK(!intersects(plane, box));
plane = tg::plane3(tg::dir3::pos_x, tg::pos3(0.9f, 0, 0));
CHECK(intersects(plane, box));
}
// random box rotation
auto nx = tg::uniform<tg::dir3>(rng);
auto ny = any_normal(nx);
auto nz = normalize(cross(nx, ny));
// random box length
half_extents[0] = nx * uniform(rng, 1.0f, 10.0f);
half_extents[1] = ny * uniform(rng, 1.0f, 10.0f);
half_extents[2] = nz * uniform(rng, 1.0f, 10.0f);
}
}
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