Commit 6fe09f9f authored by Aaron Grabowy's avatar Aaron Grabowy
Browse files

Added intersects aabb + boundary

parent a3ddba2a
......@@ -233,12 +233,6 @@ template <int D, class ScalarT, class Obj>
{
return intersects(obj, b);
}
// Explicit intersects aabb aabb to prevent infinite recursion
template <int D, class ScalarT>
[[nodiscard]] constexpr bool intersects(aabb<D, ScalarT> const& a, aabb<D, ScalarT> const& b)
{
return intersection(a, b).has_value();
}
// if a value-typed intersection parameter is available and applicable, use that
template <class A, class B>
......@@ -1215,6 +1209,30 @@ template <int D, class ScalarT>
return shadow >= dist;
}
template <int D, class ScalarT>
[[nodiscard]] constexpr bool intersects(aabb<D, ScalarT> const& a, aabb<D, ScalarT> const& b)
{
for (auto i = 0; i < D; ++i)
{
if (b.max[i] < a.min[i] || a.max[i] < b.min[i])
return false;
}
return true;
}
template <int D, class ScalarT>
[[nodiscard]] constexpr bool intersects(aabb_boundary<D, ScalarT> const& a, aabb<D, ScalarT> const& b)
{
auto contained = true;
for (auto i = 0; i < D; ++i)
{
if (b.max[i] < a.min[i] || a.max[i] < b.min[i])
return false;
contained = contained && a.min[i] < b.min[i] && b.max[i] < a.max[i];
}
return !contained;
}
template <int D, class ScalarT>
[[nodiscard]] constexpr bool intersects(sphere<D, ScalarT> const& a, aabb<D, ScalarT> const& b)
{
......
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