summaryrefslogtreecommitdiff
path: root/gfx/gl/camera.cpp
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/camera.cpp
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/camera.cpp')
-rw-r--r--gfx/gl/camera.cpp7
1 files changed, 3 insertions, 4 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);
}