diff options
Diffstat (limited to 'src/Math/AABB.cpp')
| -rw-r--r-- | src/Math/AABB.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Math/AABB.cpp b/src/Math/AABB.cpp new file mode 100644 index 0000000..aa814a1 --- /dev/null +++ b/src/Math/AABB.cpp @@ -0,0 +1,17 @@ +// This file breaks the Ray.hpp <-> AABB.hpp dependency cycle. + +#include "AABB.hpp" +#include "Ray.hpp" + +AABB AABB::cast_box(Vector<3> v, AABB against) const { + auto ray = Ray{center(), v}; + + auto expanded_target = against.sum(*this); + auto raycast = ray.cast(expanded_target); + if (!raycast.hit) return *this; + + auto result_from = raycast.point - size() / 2.0; + auto result_to = result_from + size(); + + return {result_from, result_to}; +} |
