From c310240881e9d1b474db6ef8f8f2891ce1646795 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 7 Mar 2025 00:11:07 +0000 Subject: Position is moved to Frustum --- gfx/camera.cpp | 2 +- gfx/camera.h | 7 ------- gfx/frustum.cpp | 4 ++-- gfx/frustum.h | 10 +++++++++- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'gfx') 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 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 #include 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 planes; -- cgit v1.2.3