mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 00:03:08 +08:00
Simplify rotation sync with no clocks involved
This commit is contained in:
parent
7a6355d7cf
commit
2eb63e6fe0
@ -18,7 +18,6 @@ using osu.Framework.Graphics.Visualisation;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Osu.Skinning.Legacy;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Graphics.ES30;
|
||||
@ -41,6 +40,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
private double timeOffset;
|
||||
private float time;
|
||||
protected bool Spin { get; set; }
|
||||
public float PartRotation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The scale used on creation of a new trail part.
|
||||
@ -80,12 +80,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
shader = shaders.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
|
||||
}
|
||||
|
||||
private double loadCompleteTime;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
loadCompleteTime = Parent!.Clock.CurrentTime; // using parent's clock since our is overridden
|
||||
resetTime();
|
||||
}
|
||||
|
||||
@ -245,8 +242,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
texture = Source.texture;
|
||||
time = Source.time;
|
||||
fadeExponent = Source.FadeExponent;
|
||||
// The goal is to sync trail rotation with the cursor. Cursor uses spin transform which starts rotation at LoadComplete time.
|
||||
angle = Source.Spin ? (float)((Source.Parent!.Clock.CurrentTime - Source.loadCompleteTime) * 2 * Math.PI / LegacyCursor.REVOLUTION_DURATION) : 0;
|
||||
angle = Source.Spin ? float.DegreesToRadians(Source.PartRotation) : 0;
|
||||
|
||||
originPosition = Vector2.Zero;
|
||||
|
||||
|
@ -36,6 +36,11 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
/// </summary>
|
||||
public Vector2 CurrentExpandedScale => skinnableCursor.ExpandTarget?.Scale ?? Vector2.One;
|
||||
|
||||
/// <summary>
|
||||
/// The current rotation of the cursor.
|
||||
/// </summary>
|
||||
public float CurrentRotation => skinnableCursor.ExpandTarget?.Rotation ?? 0;
|
||||
|
||||
public IBindable<float> CursorScale => cursorScale;
|
||||
|
||||
/// <summary>
|
||||
|
@ -83,7 +83,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
base.Update();
|
||||
|
||||
if (cursorTrail.Drawable is CursorTrail trail)
|
||||
{
|
||||
trail.NewPartScale = ActiveCursor.CurrentExpandedScale;
|
||||
trail.PartRotation = ActiveCursor.CurrentRotation;
|
||||
}
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
||||
|
Loading…
Reference in New Issue
Block a user