summaryrefslogtreecommitdiff
path: root/gfx/frustum.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-13 20:42:33 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-13 20:42:33 +0000
commitb9771cbeb80e5b540587a01be145154612bbc83d (patch)
tree6dff7eb8ff1deaa4b11697d7b5a27fac8bff3432 /gfx/frustum.h
parentSplit core view definition out of Camera into Frustum (diff)
parentSplit Terrain::generateMeshes into smaller functions (diff)
downloadilt-b9771cbeb80e5b540587a01be145154612bbc83d.tar.bz2
ilt-b9771cbeb80e5b540587a01be145154612bbc83d.tar.xz
ilt-b9771cbeb80e5b540587a01be145154612bbc83d.zip
Merge branch 'culling'
Diffstat (limited to 'gfx/frustum.h')
-rw-r--r--gfx/frustum.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/gfx/frustum.h b/gfx/frustum.h
index 25dcc18..a2d90e9 100644
--- a/gfx/frustum.h
+++ b/gfx/frustum.h
@@ -1,11 +1,13 @@
#pragma once
+#include "aabb.h"
+#include "config/types.h"
#include <array>
#include <glm/mat4x4.hpp>
class Frustum {
public:
- Frustum(const glm::mat4 & view, const glm::mat4 & projection);
+ Frustum(const GlobalPosition3D & pos, const glm::mat4 & view, const glm::mat4 & projection);
[[nodiscard]] auto &
getFrustumPlanes() const
@@ -19,12 +21,24 @@ public:
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 shadedBy(const BoundingBox &) const;
+
protected:
static constexpr size_t FACES = 6;
void updateCache();
+ [[nodiscard]] bool boundByPlanes(const BoundingBox &, size_t nplanes) const;
+ GlobalPosition3D position;
glm::mat4 view, projection;
glm::mat4 viewProjection, inverseViewProjection;
std::array<glm::vec4, FACES> planes;