From 1b9041c998f3a76b16a1795cf26b715527354af7 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Mon, 10 Jun 2024 12:49:24 +0300 Subject: [PATCH] Summary: - Added const references to GetPosition & GetOrientation - Renamed OnCurrentFrameFinished() - Added references to functions in comments --- openVulkanoCpp/Math/Pose.hpp | 6 ++--- .../Scene/SequenceAnimationController.cpp | 6 ++--- .../Scene/SequenceAnimationController.hpp | 22 ++++++++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/openVulkanoCpp/Math/Pose.hpp b/openVulkanoCpp/Math/Pose.hpp index 56d2dbb..22fbee8 100644 --- a/openVulkanoCpp/Math/Pose.hpp +++ b/openVulkanoCpp/Math/Pose.hpp @@ -44,14 +44,14 @@ namespace OpenVulkano::Math } } - bool operator==(const Math::Pose &otherPose) + bool operator==(const Math::Pose &otherPose) const { return (GetOrientation() == otherPose.GetOrientation()) && (GetPosition() == otherPose.GetPosition()); } - [[nodiscard]] Quaternion GetOrientation() const { return m_orientation; } + [[nodiscard]] const Quaternion& GetOrientation() const { return m_orientation; } - [[nodiscard]] Vector3_SIMD GetPosition() const { return m_position; } + [[nodiscard]] const Vector3_SIMD& GetPosition() const { return m_position; } [[nodiscard]] Pose Interpolate(const Pose& otherPose, T mixFactor) const { diff --git a/openVulkanoCpp/Scene/SequenceAnimationController.cpp b/openVulkanoCpp/Scene/SequenceAnimationController.cpp index b056827..9ad4c9b 100644 --- a/openVulkanoCpp/Scene/SequenceAnimationController.cpp +++ b/openVulkanoCpp/Scene/SequenceAnimationController.cpp @@ -10,17 +10,17 @@ namespace OpenVulkano::Scene { SequenceAnimationController::SequenceAnimationController() { - m_animationController.m_completionEvent += EventHandler(this, &SequenceAnimationController::OnCurrentFrameFinished); + m_animationController.m_completionEvent += EventHandler(this, &SequenceAnimationController::OnSequenceCompleted); } - SequenceAnimationController::PoseDurationPair SequenceAnimationController::GetStep(int index) + const SequenceAnimationController::PoseDurationPair& SequenceAnimationController::GetStep(int index) const { if(index >= 0 && index < m_steps.size()) return m_steps[index]; return PoseDurationPair(); } - void SequenceAnimationController::OnCurrentFrameFinished(SimpleAnimationController *ignored) + void SequenceAnimationController::OnSequenceCompleted(SimpleAnimationController *ignored) { if(m_steps.empty()) return; diff --git a/openVulkanoCpp/Scene/SequenceAnimationController.hpp b/openVulkanoCpp/Scene/SequenceAnimationController.hpp index cb8007a..92e6451 100644 --- a/openVulkanoCpp/Scene/SequenceAnimationController.hpp +++ b/openVulkanoCpp/Scene/SequenceAnimationController.hpp @@ -30,34 +30,46 @@ namespace OpenVulkano::Scene bool m_loop = false; double m_resetTime = 0; - void OnCurrentFrameFinished(SimpleAnimationController *animationController); + void OnSequenceCompleted(SimpleAnimationController *animationController); public: Event m_sequenceCompletionEvent; SequenceAnimationController(); - /* + /** * Enables or disables looping of the animation sequence. * * When looping is enabled, the sequence will restart from the first step after the last step is completed. * If the start and end poses of the step list are equal or the reset time is 0, the sequence will jump * directly to the first step. Otherwise, it will animate the transition back to the first step using the * reset time set by the user. + * + * @param loop A boolean value to enable or disable looping. */ void EnableLoop(bool value) { m_loop = value; } void SetNode(Node *node) { m_animationController.SetNode(node); } Node* GetNode() const { return m_animationController.GetNode(); } - /* + /** * Sets the time to transition back to the first pose when looping is enabled. * * If the reset time is set to 0, the sequence will jump directly to the first step. If the start and end poses * of the step list are equal, the sequence will also jump directly to the first step regardless of the reset time. * Otherwise, the sequence will animate the transition back to the first step using the reset time. + * + * @param resetTime The time to transition back to the first pose. + * @see GetAnimationPoseResetTime */ void SetAnimationPoseResetTime(double resetTime) { m_resetTime = resetTime; } + + /** + * Gets the current reset time for transitioning back to the first pose. + * + * @return The current reset time. + * @see SetAnimationPoseResetTime + */ double GetAnimationPoseResetTime() const { return m_resetTime; } void Restart(); @@ -66,8 +78,8 @@ namespace OpenVulkano::Scene void AddAnimationStep(const Math::PoseF &pose, double duration); void AddAnimationSteps(std::initializer_list poses, double duration); void AddAnimationSteps(std::initializer_list steps); - PoseDurationPair GetStep(int index); - const std::vector &GetSteps() { return m_steps; } + const PoseDurationPair& GetStep(int index) const; + const std::vector &GetSteps() const { return m_steps; } void Tick() override; };