summaryrefslogtreecommitdiffstats
path: root/src/game/shared/world/ray_aabb.hh
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-12-26 17:29:40 +0500
committeruntodesu <kirill@untode.su>2025-12-26 17:29:40 +0500
commit50c6db34574ce5c9d67e9a7c70a7cafb19ac2007 (patch)
tree730a59d1f08b8344df7653b98d884328449fc8d1 /src/game/shared/world/ray_aabb.hh
parente73282ec5c8fd2b04cdae5c2641e7bc622ccce1f (diff)
downloadvoxelius-50c6db34574ce5c9d67e9a7c70a7cafb19ac2007.tar.bz2
voxelius-50c6db34574ce5c9d67e9a7c70a7cafb19ac2007.zip
Rework collision. Possibly fixes #19
Diffstat (limited to 'src/game/shared/world/ray_aabb.hh')
-rw-r--r--src/game/shared/world/ray_aabb.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/game/shared/world/ray_aabb.hh b/src/game/shared/world/ray_aabb.hh
new file mode 100644
index 0000000..49c0846
--- /dev/null
+++ b/src/game/shared/world/ray_aabb.hh
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "core/math/aabb.hh"
+
+class RayAABB final {
+public:
+ RayAABB(void) = default;
+ explicit RayAABB(const glm::fvec3& start, const glm::fvec3& dir) noexcept;
+
+ constexpr const glm::fvec3& start_pos(void) const noexcept;
+ constexpr const glm::fvec3& direction(void) const noexcept;
+
+ void reset(const glm::fvec3& start, const glm::fvec3& dir) noexcept;
+
+ bool intersect(const math::AABBf& aabb, float& distance, glm::fvec3& surface) const noexcept;
+
+private:
+ glm::fvec3 m_start_pos;
+ glm::fvec3 m_direction;
+};
+
+constexpr const glm::fvec3& RayAABB::start_pos(void) const noexcept
+{
+ return m_start_pos;
+}
+
+constexpr const glm::fvec3& RayAABB::direction(void) const noexcept
+{
+ return m_direction;
+}