diff options
| author | Mel <einebeere@gmail.com> | 2024-01-25 11:25:29 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2024-01-25 11:25:29 +0100 |
| commit | 66e436d0f2cf3c33105d8a5bce43bf64d5e72255 (patch) | |
| tree | 3ee36001907453336cf96a57d8ec0154a9ae3135 /src/Math/AABB.hpp | |
| parent | efd17623627607a26f33dac8f7ef1a1ddc931907 (diff) | |
| download | meowcraft-66e436d0f2cf3c33105d8a5bce43bf64d5e72255.tar.zst meowcraft-66e436d0f2cf3c33105d8a5bce43bf64d5e72255.zip | |
Mostly functioning world collisions
Diffstat (limited to 'src/Math/AABB.hpp')
| -rw-r--r-- | src/Math/AABB.hpp | 10 |
1 files changed, 9 insertions, 1 deletions
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 <array> +#include <vector> #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<AABB> others) { + for (auto& other : others) { + if (collides(other)) return true; + } + return false; + } + std::array<Vector<3>, 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; }; |
