/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include "SimpleAnimationController.hpp" #include "Base/FrameMetadata.hpp" namespace OpenVulkano::Scene { double SimpleAnimationController::GetProgress() { double progress = m_elapsed / m_duration; if(progress >= 1.0) progress = 1; return progress; } void SimpleAnimationController::Tick() { // NOTE(vb): We can't early quit by condition elapsed > duration because we need to // emit an event when animation is completed if(!m_node || m_duration <= 0) return; m_elapsed += OpenVulkano::CURRENT_FRAME.frameTime; if(m_elapsed > m_duration) m_completionEvent.NotifyAll(this); double progress = GetProgress(); OpenVulkano::Math::Pose currentPose = m_initialPose.Interpolate(m_targetPose, progress); m_node->SetMatrix(currentPose.ToMatrix()); } }