From 50c6db34574ce5c9d67e9a7c70a7cafb19ac2007 Mon Sep 17 00:00:00 2001 From: untodesu Date: Fri, 26 Dec 2025 17:29:40 +0500 Subject: Rework collision. Possibly fixes #19 --- src/game/shared/world/ray_aabb.hh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/game/shared/world/ray_aabb.hh (limited to 'src/game/shared/world/ray_aabb.hh') 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; +} -- cgit