From efd17623627607a26f33dac8f7ef1a1ddc931907 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 7 Dec 2023 02:14:47 +0100 Subject: Gather all possibly colliding blocks in the player move domain for collision detection --- src/Math/AABB.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Math/AABB.hpp') diff --git a/src/Math/AABB.hpp b/src/Math/AABB.hpp index 22de760..53ce6d2 100644 --- a/src/Math/AABB.hpp +++ b/src/Math/AABB.hpp @@ -2,6 +2,7 @@ #include #include "Vector.hpp" +#include "../Common/Lambda.hpp" struct AABB { AABB() = default; @@ -60,6 +61,13 @@ struct AABB { return {center() - new_size / 2, center() + new_size / 2}; } + AABB unite(AABB with) const { + return { + min.zip(with.min, LAMBDA(std::min, 2)), + max.zip(with.max, LAMBDA(std::max, 2)) + }; + } + AABB collision_response(Vector<3> v, AABB against) const; Vector<3> min, max; -- cgit 1.4.1