summary refs log tree commit diff
path: root/src/Math/AABB.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-08-06 04:27:07 +0200
committerMel <einebeere@gmail.com>2023-08-06 04:27:07 +0200
commit5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 (patch)
tree3acc0240cd8dedd0764eeae6df04e134b04584c8 /src/Math/AABB.hpp
parente6f5f9e03f673db796f1babb308609ca2576db2f (diff)
downloadmeowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.tar.zst
meowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.zip
Create separate Player entity and add bad collision system
Diffstat (limited to 'src/Math/AABB.hpp')
-rw-r--r--src/Math/AABB.hpp25
1 files changed, 21 insertions, 4 deletions
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 <array>
+#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<Vector<3>, 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;
 };
-
-}