Early exiting Tick function, returning Poses as const references
This commit is contained in:
@@ -19,17 +19,16 @@ namespace OpenVulkano::Scene
|
||||
|
||||
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)
|
||||
if(!m_node || m_duration <= 0 || m_elapsed > m_duration)
|
||||
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());
|
||||
|
||||
if(m_elapsed > m_duration)
|
||||
m_completionEvent.NotifyAll(this);
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ namespace OpenVulkano::Scene
|
||||
class SimpleAnimationController : public ITickable
|
||||
{
|
||||
OpenVulkano::Scene::Node *m_node = nullptr;
|
||||
OpenVulkano::Math::Pose<float> m_targetPose;
|
||||
OpenVulkano::Math::Pose<float> m_initialPose;
|
||||
OpenVulkano::Math::PoseF m_targetPose;
|
||||
OpenVulkano::Math::PoseF m_initialPose;
|
||||
double m_duration = 0;
|
||||
double m_elapsed = 0;
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace OpenVulkano::Scene
|
||||
OpenVulkano::Scene::Node* GetNode() { return m_node; }
|
||||
void SetNode(OpenVulkano::Scene::Node *node) { m_node = node; }
|
||||
|
||||
OpenVulkano::Math::Pose<float> GetInitialPose() { return m_initialPose; }
|
||||
OpenVulkano::Math::Pose<float> GetTargetPose() { return m_targetPose; }
|
||||
void SetPoses(const OpenVulkano::Math::Pose<float> &initialPose, const OpenVulkano::Math::Pose<float> &targetPose) { m_initialPose = initialPose; m_targetPose = targetPose; }
|
||||
const OpenVulkano::Math::PoseF GetInitialPose() { return m_initialPose; }
|
||||
const OpenVulkano::Math::PoseF GetTargetPose() { return m_targetPose; }
|
||||
void SetPoses(const OpenVulkano::Math::PoseF &initialPose, const OpenVulkano::Math::PoseF &targetPose) { m_initialPose = initialPose; m_targetPose = targetPose; }
|
||||
|
||||
double GetDuration() { return m_duration; }
|
||||
void SetDuration(double duration) { m_duration = duration; }
|
||||
|
||||
Reference in New Issue
Block a user