From 5b4a34cb8c272c96f94fc0d45684f675085587a6 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 21 Feb 2026 00:50:31 +0000 Subject: Simplified Frustum Don't need to differentiate between shadedBy by contains. The 5 plane/face variant is actually fine in both cases. For a perspective projection, the near plane is essentially at the origin and is handled by the left/right/top/bottom planes meeting. For the directional light case (orthographic projection) the near plane is omitted as objects in front of the clip space still cast shadows into it. Also includes a fix the distance calculation to not add .w, don't know where I got the idea this was right. --- gfx/frustum.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'gfx/frustum.h') diff --git a/gfx/frustum.h b/gfx/frustum.h index 1493a36..cd4cbe1 100644 --- a/gfx/frustum.h +++ b/gfx/frustum.h @@ -33,14 +33,11 @@ public: using BoundingBox = AxisAlignedBoundingBox; [[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; + static constexpr size_t FACES = 5; void updateCache(); - [[nodiscard]] bool boundByPlanes(const BoundingBox &, size_t nplanes) const; - [[nodiscard]] bool contains(std::span, size_t nplanes, RelativeDistance) const; + [[nodiscard]] bool contains(std::span, RelativeDistance) const; GlobalPosition3D position; glm::mat4 view, projection; -- cgit v1.3