Summary:
- Additional getters/setters - Passing setters' value as by reference - Changed includes order - Moved callback function to MovingCubeApp - Made Event public
This commit is contained in:
@@ -4,32 +4,31 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "SimpleAnimationController.hpp"
|
||||
#include "Base/FrameMetadata.hpp"
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
void SimpleAnimationController::OnAnimationCompleted()
|
||||
double SimpleAnimationController::GetProgress()
|
||||
{
|
||||
std::swap(m_targetPose, m_initialPose);
|
||||
m_elapsed = 0;
|
||||
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;
|
||||
float progress = m_elapsed / m_duration;
|
||||
if(progress >= 1.0)
|
||||
{
|
||||
progress = 1;
|
||||
m_event.NotifyAll();
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user