From 656350d7906c156d87405bf71338475226268081 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Wed, 26 Jun 2024 20:59:06 +0300 Subject: [PATCH] Refactored UpdateProjectionMatrix(), SetTargetState() now launches the transition --- openVulkanoCpp/Scene/MorphableCamera.cpp | 23 ++++++++++--------- .../Scene/MorphableCameraController.cpp | 6 +++++ .../Scene/MorphableCameraController.hpp | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/openVulkanoCpp/Scene/MorphableCamera.cpp b/openVulkanoCpp/Scene/MorphableCamera.cpp index 9397058..3643bf6 100644 --- a/openVulkanoCpp/Scene/MorphableCamera.cpp +++ b/openVulkanoCpp/Scene/MorphableCamera.cpp @@ -23,18 +23,19 @@ namespace OpenVulkano::Scene void MorphableCamera::UpdateProjectionMatrix() { PerspectiveCamera::UpdateProjectionMatrix(); - float aspectH = m_aspect; - float aspectV = 1; - if (m_morphState == 0) { UpdateViewProjectionMatrix(); } - else if (m_morphState == 1) + if (m_morphState != 0) { - m_projection = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane); - UpdateViewProjectionMatrix(); - } - else - { - m_orthoMatrix = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane); - m_projection = BlendMatrices(m_projection, m_orthoMatrix, m_morphState); + float aspectH = m_aspect; + float aspectV = 1; + if (m_morphState == 1) + { + m_projection = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane); + } + else + { + m_orthoMatrix = Math::Utils::orthoRH_ZO(-aspectH, aspectH, -aspectV, aspectV, m_nearPlane, m_farPlane); + m_projection = BlendMatrices(m_projection, m_orthoMatrix, m_morphState); + } UpdateViewProjectionMatrix(); } } diff --git a/openVulkanoCpp/Scene/MorphableCameraController.cpp b/openVulkanoCpp/Scene/MorphableCameraController.cpp index 9ad569b..af3371c 100644 --- a/openVulkanoCpp/Scene/MorphableCameraController.cpp +++ b/openVulkanoCpp/Scene/MorphableCameraController.cpp @@ -56,4 +56,10 @@ namespace OpenVulkano::Scene static_cast(GetCamera())->SetMorphState(newState); } } + + void MorphableCameraController::SetTargetState(bool toPerspective) + { + m_targetMorphStatePerspective = toPerspective; + m_isMorphing = true; + } } \ No newline at end of file diff --git a/openVulkanoCpp/Scene/MorphableCameraController.hpp b/openVulkanoCpp/Scene/MorphableCameraController.hpp index f5c5084..be9cb87 100644 --- a/openVulkanoCpp/Scene/MorphableCameraController.hpp +++ b/openVulkanoCpp/Scene/MorphableCameraController.hpp @@ -31,7 +31,7 @@ namespace OpenVulkano::Scene void SetDuration(double duration) { m_animationDuration = duration; } double GetDuration() { return m_animationDuration; } - void SetTargetState(bool toPerspective) { m_targetMorphStatePerspective = toPerspective; } + void SetTargetState(bool toPerspective); void Reset() { m_currentTime = 0; } }; } \ No newline at end of file