- Added const references to GetPosition & GetOrientation
- Renamed OnCurrentFrameFinished()
- Added references to functions in comments
This commit is contained in:
Vladyslav Baranovskyi
2024-06-10 12:49:24 +03:00
parent c708950bc6
commit 1b9041c998
3 changed files with 23 additions and 11 deletions

View File

@@ -44,14 +44,14 @@ namespace OpenVulkano::Math
}
}
bool operator==(const Math::Pose<T> &otherPose)
bool operator==(const Math::Pose<T> &otherPose) const
{
return (GetOrientation() == otherPose.GetOrientation()) && (GetPosition() == otherPose.GetPosition());
}
[[nodiscard]] Quaternion<T> GetOrientation() const { return m_orientation; }
[[nodiscard]] const Quaternion<T>& GetOrientation() const { return m_orientation; }
[[nodiscard]] Vector3_SIMD<T> GetPosition() const { return m_position; }
[[nodiscard]] const Vector3_SIMD<T>& GetPosition() const { return m_position; }
[[nodiscard]] Pose<T> Interpolate(const Pose<T>& otherPose, T mixFactor) const
{

View File

@@ -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;

View File

@@ -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<SequenceAnimationController *> 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<Math::PoseF> poses, double duration);
void AddAnimationSteps(std::initializer_list<PoseDurationPair> steps);
PoseDurationPair GetStep(int index);
const std::vector<PoseDurationPair> &GetSteps() { return m_steps; }
const PoseDurationPair& GetStep(int index) const;
const std::vector<PoseDurationPair> &GetSteps() const { return m_steps; }
void Tick() override;
};