From 5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 6 Aug 2023 04:27:07 +0200 Subject: Create separate Player entity and add bad collision system --- src/Math/AABB.hpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/Math/AABB.hpp') diff --git a/src/Math/AABB.hpp b/src/Math/AABB.hpp index 2c02abf..11d26a8 100644 --- a/src/Math/AABB.hpp +++ b/src/Math/AABB.hpp @@ -1,10 +1,27 @@ #pragma once -#include "Vector.hpp" -namespace Math { +#include +#include "Vector.hpp" struct AABB { + AABB() = default; + AABB(Vector<3> min, Vector<3> max) : min(min), max(max) {} + explicit AABB(Vector<3> max) : max(max) {} + + std::array, 8> corners() const { + return {{ + {min.x(), min.y(), min.z()}, + {min.x(), min.y(), max.z()}, + {min.x(), max.y(), min.z()}, + {min.x(), max.y(), max.z()}, + {max.x(), min.y(), min.z()}, + {max.x(), min.y(), max.z()}, + {max.x(), max.y(), min.z()}, + {max.x(), max.y(), max.z()}, + }}; + } + + AABB offset(Vector<3> by) const { return {min + by, max + by}; } + Vector<3> min, max; }; - -} -- cgit 1.4.1