blob: 1493a36d6ea7d02ae4bf60f596d825dd70ee0459 (
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
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include "aabb.h"
#include "config/types.h"
#include <array>
#include <glm/mat4x4.hpp>
#include <span>
class Frustum {
public:
Frustum(const GlobalPosition3D & pos, const glm::mat4 & view, const glm::mat4 & projection);
[[nodiscard]] auto &
getFrustumPlanes() const
{
return planes;
}
[[nodiscard]] auto &
getViewProjection() const
{
return viewProjection;
}
[[nodiscard]] auto
getPosition() const
{
return position;
}
void updateView(const glm::mat4 & view);
using BoundingBox = AxisAlignedBoundingBox<GlobalDistance>;
[[nodiscard]] bool contains(const BoundingBox &) const;
[[nodiscard]] bool contains(GlobalPosition3D, RelativeDistance size = 0) const;
[[nodiscard]] bool shadedBy(const BoundingBox &) const;
[[nodiscard]] bool shadedBy(GlobalPosition3D, RelativeDistance size = 0) const;
protected:
static constexpr size_t FACES = 6;
void updateCache();
[[nodiscard]] bool boundByPlanes(const BoundingBox &, size_t nplanes) const;
[[nodiscard]] bool contains(std::span<const RelativePosition4D>, size_t nplanes, RelativeDistance) const;
GlobalPosition3D position;
glm::mat4 view, projection;
glm::mat4 viewProjection, inverseViewProjection;
std::array<glm::vec4, FACES> planes;
};
|