blob: 640a02cce1474ab7a29960da8a7c3cb5ee1337d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2025 Kirill Dmitrievich
// File: ray_aabb.hh
// Description: Check ray intersections against an AABB
#ifndef SHARED_WORLD_RAY_AABB_HH
#define SHARED_WORLD_RAY_AABB_HH
#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;
}
#endif
|