diff options
| author | Mel <einebeere@gmail.com> | 2023-12-07 02:14:47 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-12-07 02:14:47 +0100 |
| commit | efd17623627607a26f33dac8f7ef1a1ddc931907 (patch) | |
| tree | 76cf0389ae927bfc697c830155d926843178030e /src/Math | |
| parent | 581f50e0bd45a19282d7958975997d376512b195 (diff) | |
| download | meowcraft-efd17623627607a26f33dac8f7ef1a1ddc931907.tar.zst meowcraft-efd17623627607a26f33dac8f7ef1a1ddc931907.zip | |
Gather all possibly colliding blocks in the player move domain for collision detection
Diffstat (limited to 'src/Math')
| -rw-r--r-- | src/Math/AABB.hpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Math/AABB.hpp b/src/Math/AABB.hpp index 22de760..53ce6d2 100644 --- a/src/Math/AABB.hpp +++ b/src/Math/AABB.hpp @@ -2,6 +2,7 @@ #include <array> #include "Vector.hpp" +#include "../Common/Lambda.hpp" struct AABB { AABB() = default; @@ -60,6 +61,13 @@ struct AABB { return {center() - new_size / 2, center() + new_size / 2}; } + AABB unite(AABB with) const { + return { + min.zip(with.min, LAMBDA(std::min, 2)), + max.zip(with.max, LAMBDA(std::max, 2)) + }; + } + AABB collision_response(Vector<3> v, AABB against) const; Vector<3> min, max; |
