From beeea386aa7831bfc819d6ae7ad3a5903203879c Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sun, 30 Jun 2024 13:58:11 +0200 Subject: [PATCH] Fix issues with camera --- openVulkanoCpp/Scene/Camera.hpp | 4 ++-- openVulkanoCpp/Scene/MorphableCameraController.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openVulkanoCpp/Scene/Camera.hpp b/openVulkanoCpp/Scene/Camera.hpp index e8711e2..6164e99 100644 --- a/openVulkanoCpp/Scene/Camera.hpp +++ b/openVulkanoCpp/Scene/Camera.hpp @@ -245,7 +245,7 @@ namespace OpenVulkano::Scene return 2.0f * atanf(tanf(m_fov * 0.5f) * m_aspect); } - void UpdateProjectionMatrix() + void UpdateProjectionMatrix() override { m_projection = Math::Utils::perspectiveRH_ZO(m_fov, m_aspect, m_nearPlane, m_farPlane); UpdateViewProjectionMatrix(); @@ -255,7 +255,7 @@ namespace OpenVulkano::Scene class OrthographicCamera : public Camera { public: - void UpdateProjectionMatrix() final + void UpdateProjectionMatrix() override { const float scale = 0.5f * m_contentScaleFactor * m_zoom; const float widthHalf = m_width * scale, heightHalf = m_height * scale; diff --git a/openVulkanoCpp/Scene/MorphableCameraController.cpp b/openVulkanoCpp/Scene/MorphableCameraController.cpp index af3371c..daa172d 100644 --- a/openVulkanoCpp/Scene/MorphableCameraController.cpp +++ b/openVulkanoCpp/Scene/MorphableCameraController.cpp @@ -17,7 +17,7 @@ namespace OpenVulkano::Scene , m_animationDuration(1.0f) , m_currentTime(0.0f) , m_isMorphing(false) - , m_targetMorphStatePerspective(false) + , m_targetMorphStatePerspective(true) { auto input = OpenVulkano::Input::InputManager::GetInstance(); m_actionMorph = input->GetAction("morph"); @@ -52,13 +52,14 @@ namespace OpenVulkano::Scene t = 1.0f; m_isMorphing = false; } - float newState = m_targetMorphStatePerspective ? t : (1.0f - t); + float newState = m_targetMorphStatePerspective ? (1.0f - t) : t; static_cast(GetCamera())->SetMorphState(newState); } } void MorphableCameraController::SetTargetState(bool toPerspective) { + if (toPerspective == m_targetMorphStatePerspective) return; m_targetMorphStatePerspective = toPerspective; m_isMorphing = true; }