@@ -43,7 +43,7 @@ void AnimationClip::Pause() {
4343
4444void AnimationClip::Stop () {
4545 SetPlaying (false );
46- Seek (0 );
46+ Seek (SecondsF::zero () );
4747}
4848
4949bool AnimationClip::GetLoop () const {
@@ -70,39 +70,43 @@ void AnimationClip::SetWeight(Scalar weight) {
7070 weight_ = weight;
7171}
7272
73- Scalar AnimationClip::GetPlaybackTime () const {
73+ SecondsF AnimationClip::GetPlaybackTime () const {
7474 return playback_time_;
7575}
7676
77- void AnimationClip::Seek (Scalar time) {
78- playback_time_ = std::clamp (time, 0 . 0f , animation_->GetEndTime ());
77+ void AnimationClip::Seek (SecondsF time) {
78+ playback_time_ = std::clamp (time, SecondsF::zero () , animation_->GetEndTime ());
7979}
8080
81- void AnimationClip::Advance (Scalar delta_time) {
82- if (!playing_ || delta_time <= 0 ) {
81+ void AnimationClip::Advance (SecondsF delta_time) {
82+ if (!playing_ || delta_time <= SecondsF::zero () ) {
8383 return ;
8484 }
8585 delta_time *= playback_time_scale_;
8686 playback_time_ += delta_time;
8787
8888 // / Handle looping behavior.
8989
90- Scalar end_time = animation_->GetEndTime ();
91- if (end_time == 0 ) {
92- playback_time_ = 0 ;
90+ auto end_time = animation_->GetEndTime ();
91+ if (end_time == SecondsF::zero () ) {
92+ playback_time_ = SecondsF::zero () ;
9393 return ;
9494 }
95- if (!loop_ && (playback_time_ < 0 || playback_time_ > end_time)) {
95+ if (!loop_ &&
96+ (playback_time_ < SecondsF::zero () || playback_time_ > end_time)) {
9697 // If looping is disabled, clamp to the end (or beginning, if playing in
9798 // reverse) and pause.
9899 Pause ();
99- playback_time_ = std::clamp (playback_time_, 0 . 0f , end_time);
100+ playback_time_ = std::clamp (playback_time_, SecondsF::zero () , end_time);
100101 } else if (/* loop && */ playback_time_ > end_time) {
101102 // If looping is enabled and we ran off the end, loop to the beginning.
102- playback_time_ = std::fmod (std::abs (playback_time_), end_time);
103- } else if (/* loop && */ playback_time_ < 0 ) {
103+ playback_time_ =
104+ SecondsF (std::fmod (std::abs (playback_time_.count ()), end_time.count ()));
105+ } else if (/* loop && */ playback_time_ < SecondsF::zero ()) {
104106 // If looping is enabled and we ran off the beginning, loop to the end.
105- playback_time_ = end_time - std::fmod (std::abs (playback_time_), end_time);
107+ playback_time_ =
108+ end_time -
109+ SecondsF (std::fmod (std::abs (playback_time_.count ()), end_time.count ()));
106110 }
107111}
108112
0 commit comments