diff options
| author | Mel <einebeere@gmail.com> | 2024-02-01 00:52:45 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2024-02-01 00:52:45 +0100 |
| commit | 7b107078a2a3b9f62a076f91e873f5ad0597d167 (patch) | |
| tree | bf7f5d0f2d75996d5b021211651f6f33531bbbe8 /src/Math/AABB.hpp | |
| parent | 286261c1c730f3d8f3412b0f502ace366ba1ea76 (diff) | |
| download | meowcraft-7b107078a2a3b9f62a076f91e873f5ad0597d167.tar.zst meowcraft-7b107078a2a3b9f62a076f91e873f5ad0597d167.zip | |
Correctly sort collision responses and apply in correct order
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 4ad5534..b50ba56 100644 --- a/src/Math/AABB.hpp +++ b/src/Math/AABB.hpp @@ -76,7 +76,15 @@ struct AABB { }; } - Vec3 pushout(Vector<3> v, AABB against) const; + struct CollisionResponse { + // Velocity until the collision. + // Always has the same direction as the original velocity, and lower magnitude. + Vec3 v_to_collision; + // Velocity sliding along the collision plane. + // Projection of the fraction of the original velocity that was blocked by collision, onto the collision plane. + Vec3 v_slide; + }; + CollisionResponse collision_response(Vector<3> v, AABB against) const; Vector<3> min, max; }; |
