summaryrefslogtreecommitdiff
path: root/gfx/frustum.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-05 23:52:18 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-05 23:52:18 +0000
commit4e10d57f83f719e02005fe41e70fe1a4721a9439 (patch)
tree44a7300f97e1a7c09ad560f2176e1c089da6fe20 /gfx/frustum.h
parentMove camera out of gl folder, it's not OpenGL specific (diff)
downloadilt-4e10d57f83f719e02005fe41e70fe1a4721a9439.tar.bz2
ilt-4e10d57f83f719e02005fe41e70fe1a4721a9439.tar.xz
ilt-4e10d57f83f719e02005fe41e70fe1a4721a9439.zip
Split core view definition out of Camera into Frustum
Diffstat (limited to 'gfx/frustum.h')
-rw-r--r--gfx/frustum.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/gfx/frustum.h b/gfx/frustum.h
new file mode 100644
index 0000000..25dcc18
--- /dev/null
+++ b/gfx/frustum.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <array>
+#include <glm/mat4x4.hpp>
+
+class Frustum {
+public:
+ Frustum(const glm::mat4 & view, const glm::mat4 & projection);
+
+ [[nodiscard]] auto &
+ getFrustumPlanes() const
+ {
+ return planes;
+ }
+
+ [[nodiscard]] auto &
+ getViewProjection() const
+ {
+ return viewProjection;
+ }
+
+ void updateView(const glm::mat4 & view);
+
+protected:
+ static constexpr size_t FACES = 6;
+ void updateCache();
+
+ glm::mat4 view, projection;
+ glm::mat4 viewProjection, inverseViewProjection;
+ std::array<glm::vec4, FACES> planes;
+};