summaryrefslogtreecommitdiff
path: root/gfx/frustum.h
blob: 46f4108f6191ffc995c5ae727be03c77598ee810 (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
#pragma once

#include "config/types.h"
#include <array>
#include <glm/mat4x4.hpp>

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);

protected:
	static constexpr size_t FACES = 6;
	void updateCache();

	GlobalPosition3D position;
	glm::mat4 view, projection;
	glm::mat4 viewProjection, inverseViewProjection;
	std::array<glm::vec4, FACES> planes;
};