From 66e436d0f2cf3c33105d8a5bce43bf64d5e72255 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 25 Jan 2024 11:25:29 +0100 Subject: Mostly functioning world collisions --- src/Math/AABB.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Math/AABB.hpp') diff --git a/src/Math/AABB.hpp b/src/Math/AABB.hpp index 53ce6d2..4ad5534 100644 --- a/src/Math/AABB.hpp +++ b/src/Math/AABB.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Vector.hpp" #include "../Common/Lambda.hpp" @@ -41,6 +42,13 @@ struct AABB { return intersects_on_x(other) && intersects_on_y(other) && intersects_on_z(other); } + Bool collides(std::vector others) { + for (auto& other : others) { + if (collides(other)) return true; + } + return false; + } + std::array, 8> corners() const { return {{ {min.x(), min.y(), min.z()}, @@ -68,7 +76,7 @@ struct AABB { }; } - AABB collision_response(Vector<3> v, AABB against) const; + Vec3 pushout(Vector<3> v, AABB against) const; Vector<3> min, max; }; -- cgit 1.4.1