1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Fix storyboard animations not starting their animation playback from the correct point in time

This commit is contained in:
Dean Herbert 2022-09-12 14:05:16 +09:00
parent aa823161f1
commit 24138b65a7
2 changed files with 25 additions and 1 deletions

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Textures;
using osu.Framework.Utils;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
using osuTK;
@ -115,6 +116,21 @@ namespace osu.Game.Storyboards.Drawables
Animation.ApplyTransforms(this);
}
[Resolved]
private IGameplayClock gameplayClock { get; set; }
protected override void LoadComplete()
{
base.LoadComplete();
// Framework animation class tries its best to synchronise the animation at LoadComplete,
// but in some cases (such as fast forward) this results in an incorrect start offset.
//
// In the case of storyboard animations, we want to synchronise with game time perfectly
// so let's get a correct time based on gameplay clock and earliest transform.
PlaybackPosition = gameplayClock.CurrentTime - Animation.EarliestTransformTime;
}
private void skinSourceChanged()
{
ClearFrames();

View File

@ -26,7 +26,7 @@ namespace osu.Game.Storyboards
public readonly CommandTimelineGroup TimelineGroup = new CommandTimelineGroup();
public double StartTime
public virtual double StartTime
{
get
{
@ -54,6 +54,14 @@ namespace osu.Game.Storyboards
return firstAlpha.startTime;
}
return EarliestTransformTime;
}
}
public double EarliestTransformTime
{
get
{
// If we got to this point, either no alpha commands were present, or the earliest had a non-zero start value.
// The sprite's StartTime will be determined by the earliest command, regardless of type.
double earliestStartTime = TimelineGroup.StartTime;