From c2abacf2e7d188aa0999a38dce259b0d8e76b982 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 11 Dec 2022 14:52:09 +0000 Subject: Cache unView matrix for unprojecting mouse clicks, update only on camera movement --- gfx/gl/camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gfx/gl/camera.cpp') diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index 994d8ab..72b5240 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -14,13 +14,13 @@ 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, glm::lookAt(::origin, forward, up), projection, screen))}; + return {position, glm::normalize(glm::unProject(mouse ^ 1, unView, projection, screen))}; } void Camera::updateView() { view = glm::lookAt(position, position + forward, up); + unView = glm::lookAt(::origin, forward, up); viewProjection = projection * view; } -- cgit v1.2.3