summaryrefslogtreecommitdiff
path: root/gfx/gl
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-18 16:47:36 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-18 16:47:36 +0000
commitfd16562719e89eb71fc065a7c46df892865af13f (patch)
treea2f207228d94c0314b90c8e98489dd30252549fa /gfx/gl
parentFirst cut of view scope shadow mapper view (diff)
downloadilt-fd16562719e89eb71fc065a7c46df892865af13f.tar.bz2
ilt-fd16562719e89eb71fc065a7c46df892865af13f.tar.xz
ilt-fd16562719e89eb71fc065a7c46df892865af13f.zip
No need to store view or unView
view is transient to create viewProjection, unview only needed on unproject
Diffstat (limited to 'gfx/gl')
-rw-r--r--gfx/gl/camera.cpp7
-rw-r--r--gfx/gl/camera.h1
2 files changed, 3 insertions, 5 deletions
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;
};