Files
OpenVulkano/openVulkanoCpp/Scene/SimpleAnimationController.cpp
Vladyslav Baranovskyi 193c942f06 Summary:
- Additional getters/setters
- Passing setters' value as by reference
- Changed includes order
- Moved callback function to MovingCubeApp
- Made Event public
2024-06-06 13:21:02 +03:00

35 lines
1002 B
C++

/*
* 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<float> currentPose = m_initialPose.Interpolate(m_targetPose, progress);
m_node->SetMatrix(currentPose.ToMatrix());
}
}