diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-07 00:11:07 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-11 01:13:59 +0000 |
commit | c310240881e9d1b474db6ef8f8f2891ce1646795 (patch) | |
tree | 4529b28457ef805015242f4579299cc39240ddde | |
parent | Create AxisAlignedBoundingBox (diff) | |
download | ilt-c310240881e9d1b474db6ef8f8f2891ce1646795.tar.bz2 ilt-c310240881e9d1b474db6ef8f8f2891ce1646795.tar.xz ilt-c310240881e9d1b474db6ef8f8f2891ce1646795.zip |
Position is moved to Frustum
-rw-r--r-- | gfx/camera.cpp | 2 | ||||
-rw-r--r-- | gfx/camera.h | 7 | ||||
-rw-r--r-- | gfx/frustum.cpp | 4 | ||||
-rw-r--r-- | gfx/frustum.h | 10 |
4 files changed, 12 insertions, 11 deletions
diff --git a/gfx/camera.cpp b/gfx/camera.cpp index cc6a2dd..f01054a 100644 --- a/gfx/camera.cpp +++ b/gfx/camera.cpp @@ -12,7 +12,7 @@ Camera::Camera(GlobalPosition3D pos, Angle fov, Angle aspect, GlobalDistance nea Camera::Camera(GlobalPosition3D pos, GlobalDistance near, GlobalDistance far, const glm::mat4 & view, const glm::mat4 & projection) : - Frustum {view, projection}, position {pos}, forward {::north}, up {::up}, near {near}, far {far} + Frustum {pos, view, projection}, forward {::north}, up {::up}, near {near}, far {far} { } diff --git a/gfx/camera.h b/gfx/camera.h index a52ec8b..d1bfc82 100644 --- a/gfx/camera.h +++ b/gfx/camera.h @@ -59,12 +59,6 @@ public: return forward; } - [[nodiscard]] auto - getPosition() const - { - return position; - } - [[nodiscard]] std::array<GlobalPosition4D, 4> extentsAtDist(GlobalDistance) const; [[nodiscard]] static Direction3D upFromForward(const Direction3D & forward); @@ -74,7 +68,6 @@ private: const glm::mat4 & projection); void updateView(); - GlobalPosition3D position; Direction3D forward; Direction3D up; GlobalDistance near, far; diff --git a/gfx/frustum.cpp b/gfx/frustum.cpp index 9e046f6..a9dbdf0 100644 --- a/gfx/frustum.cpp +++ b/gfx/frustum.cpp @@ -5,8 +5,8 @@ static constexpr auto PLANES = std::array {0, 1, 2} * std::array {1.F, -1.F}; -Frustum::Frustum(const glm::mat4 & view, const glm::mat4 & projection) : - view {view}, projection {projection}, viewProjection {}, inverseViewProjection {}, planes {} +Frustum::Frustum(const GlobalPosition3D & pos, const glm::mat4 & view, const glm::mat4 & projection) : + position {pos}, view {view}, projection {projection}, viewProjection {}, inverseViewProjection {}, planes {} { updateCache(); } diff --git a/gfx/frustum.h b/gfx/frustum.h index 25dcc18..46f4108 100644 --- a/gfx/frustum.h +++ b/gfx/frustum.h @@ -1,11 +1,12 @@ #pragma once +#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 +20,19 @@ public: 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; |