From fd16562719e89eb71fc065a7c46df892865af13f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 18 Dec 2022 16:47:36 +0000 Subject: No need to store view or unView view is transient to create viewProjection, unview only needed on unproject --- gfx/gl/camera.cpp | 7 +++---- gfx/gl/camera.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'gfx/gl') diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index 31be9a6..ff706e7 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -14,15 +14,14 @@ Ray Camera::unProject(const glm::vec2 & mouse) const { static constexpr const glm::vec4 screen {0, 0, 1, 1}; - return {position, glm::normalize(glm::unProject(mouse ^ 1, unView, projection, screen))}; + const auto mouseProjection = glm::lookAt(::origin, forward, up); + return {position, glm::normalize(glm::unProject(mouse ^ 1, mouseProjection, projection, screen))}; } void Camera::updateView() { - view = glm::lookAt(position, position + forward, up); - unView = glm::lookAt(::origin, forward, up); - viewProjection = projection * view; + viewProjection = projection * glm::lookAt(position, position + forward, up); inverseViewProjection = glm::inverse(viewProjection); } diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h index 1ded3e0..5b2b4f4 100644 --- a/gfx/gl/camera.h +++ b/gfx/gl/camera.h @@ -74,6 +74,5 @@ private: float fov, aspect, near, far; glm::mat4 projection; - glm::mat4 view, unView; glm::mat4 viewProjection, inverseViewProjection; }; -- cgit v1.2.3