Fix animations resetting after repeat count (#10540)
# Objective After #9002, it seems that "single shot" animations were broken. When completing, they would reset to their initial value. Which is generally not what you want. - Fixes #10480 ## Solution Avoid `%`-ing the animation after the number of completions exceeds the specified one. Instead, we early-return. This is also true when the player is playing in reverse. --- ## Changelog - Avoid resetting animations after `Repeat::Never` animation completion.
This commit is contained in:
parent
6dc602da44
commit
f78a9460db
@ -190,15 +190,20 @@ impl PlayingAnimation {
|
|||||||
self.elapsed += delta;
|
self.elapsed += delta;
|
||||||
self.seek_time += delta * self.speed;
|
self.seek_time += delta * self.speed;
|
||||||
|
|
||||||
if (self.seek_time > clip_duration && self.speed > 0.0)
|
let over_time = self.speed > 0.0 && self.seek_time >= clip_duration;
|
||||||
|| (self.seek_time < 0.0 && self.speed < 0.0)
|
let under_time = self.speed < 0.0 && self.seek_time < 0.0;
|
||||||
{
|
|
||||||
self.completions += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if over_time || under_time {
|
||||||
|
self.completions += 1;
|
||||||
|
|
||||||
|
if self.is_finished() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if self.seek_time >= clip_duration {
|
if self.seek_time >= clip_duration {
|
||||||
self.seek_time %= clip_duration;
|
self.seek_time %= clip_duration;
|
||||||
}
|
}
|
||||||
|
// Note: assumes delta is never lower than -clip_duration
|
||||||
if self.seek_time < 0.0 {
|
if self.seek_time < 0.0 {
|
||||||
self.seek_time += clip_duration;
|
self.seek_time += clip_duration;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user