summary refs log tree commit diff
path: root/src/Math/AABB.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-12-07 01:26:04 +0100
committerMel <einebeere@gmail.com>2023-12-07 01:26:04 +0100
commit581f50e0bd45a19282d7958975997d376512b195 (patch)
treedb42e31524efc49caab06efeb3d1a1331ec4f2b5 /src/Math/AABB.hpp
parentacc6e0e53d981428c15baf5b7efe568d98044290 (diff)
downloadmeowcraft-581f50e0bd45a19282d7958975997d376512b195.tar.zst
meowcraft-581f50e0bd45a19282d7958975997d376512b195.zip
AABB-AABB dynamic-static collision response with sliding
Diffstat (limited to 'src/Math/AABB.hpp')
-rw-r--r--src/Math/AABB.hpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Math/AABB.hpp b/src/Math/AABB.hpp
index 19aa81c..22de760 100644
--- a/src/Math/AABB.hpp
+++ b/src/Math/AABB.hpp
@@ -8,6 +8,13 @@ struct AABB {
     AABB(Vector<3> min, Vector<3> max) : min(min), max(max) {}
     explicit AABB(Vector<3> max) : max(max) {}
 
+    static AABB from_center(Vector<3> center, Vector<3> size) {
+        auto min = center - size / 2.0;
+        auto max = min + size;
+
+        return {min, max};
+    }
+
     Vector<3> size() const { return max - min; }
     Vector<3> center() const { return (min + max) / 2; }
 
@@ -53,7 +60,7 @@ struct AABB {
         return {center() - new_size / 2, center() + new_size / 2};
     }
 
-    AABB cast_box(Vector<3> v, AABB against) const;
+    AABB collision_response(Vector<3> v, AABB against) const;
 
     Vector<3> min, max;
 };