animations: don't ignore curves with one keyframe (#4406)
# Objective - While playing with animated models, I noticed some were a little off ## Solution - Some animations curves only have one keyframe, they are used to set a transform to a given value - Those were ignored as we're never exactly at the ts 0.0 of an animation. going there explicitly (`.set_elapsed(0.0).pause()`) would crash - Special case this as there isn't much to animate in this case
This commit is contained in:
parent
032b0f4bac
commit
5e70ad96c6
@ -218,6 +218,18 @@ pub fn animation_player(
|
|||||||
}
|
}
|
||||||
if let Ok(mut transform) = transforms.get_mut(current_entity) {
|
if let Ok(mut transform) = transforms.get_mut(current_entity) {
|
||||||
for curve in curves {
|
for curve in curves {
|
||||||
|
// Some curves have only one keyframe used to set a transform
|
||||||
|
if curve.keyframe_timestamps.len() == 1 {
|
||||||
|
match &curve.keyframes {
|
||||||
|
Keyframes::Rotation(keyframes) => transform.rotation = keyframes[0],
|
||||||
|
Keyframes::Translation(keyframes) => {
|
||||||
|
transform.translation = keyframes[0]
|
||||||
|
}
|
||||||
|
Keyframes::Scale(keyframes) => transform.scale = keyframes[0],
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the current keyframe
|
// Find the current keyframe
|
||||||
// PERF: finding the current keyframe can be optimised
|
// PERF: finding the current keyframe can be optimised
|
||||||
let step_start = match curve
|
let step_start = match curve
|
||||||
|
Loading…
Reference in New Issue
Block a user