1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 20:25:39 +08:00

Add toggle for cursor trail interpolation

This commit is contained in:
smoogipoo 2019-09-09 19:22:27 +09:00
parent 1d225ba81e
commit 3b1b7910bb

View File

@ -106,6 +106,11 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private Vector2 size => texture.Size * Scale;
/// <summary>
/// Whether to interpolate mouse movements and add trail pieces at intermediate points.
/// </summary>
protected virtual bool InterpolateMovements => true;
private Vector2? lastPosition;
private readonly InputResampler resampler = new InputResampler();
@ -126,6 +131,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
{
Trace.Assert(lastPosition.HasValue);
if (InterpolateMovements)
{
// ReSharper disable once PossibleInvalidOperationException
Vector2 pos1 = lastPosition.Value;
Vector2 diff = pos2 - pos1;
@ -137,18 +144,28 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (float d = interval; d < distance; d += interval)
{
lastPosition = pos1 + direction * d;
parts[currentIndex].Position = lastPosition.Value;
parts[currentIndex].Time = time;
++parts[currentIndex].InvalidationID;
currentIndex = (currentIndex + 1) % max_sprites;
addPart(lastPosition.Value);
}
}
else
{
lastPosition = pos2;
addPart(lastPosition.Value);
}
}
return base.OnMouseMove(e);
}
private void addPart(Vector2 screenSpacePosition)
{
parts[currentIndex].Position = screenSpacePosition;
parts[currentIndex].Time = time;
++parts[currentIndex].InvalidationID;
currentIndex = (currentIndex + 1) % max_sprites;
}
protected override DrawNode CreateDrawNode() => new TrailDrawNode(this);
private struct TrailPart