mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
InputResample CursorTrail
This commit is contained in:
parent
f5981b1ab9
commit
008ff9d2f9
@ -39,6 +39,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
private Vector2? lastPosition;
|
||||
|
||||
private InputResampler resampler = new InputResampler();
|
||||
|
||||
protected override DrawNode CreateDrawNode() => new TrailDrawNode();
|
||||
|
||||
protected override void ApplyDrawNode(DrawNode node)
|
||||
@ -116,12 +118,13 @@ namespace osu.Game.Graphics.Cursor
|
||||
if (lastPosition == null)
|
||||
{
|
||||
lastPosition = state.Mouse.NativeState.Position;
|
||||
resampler.AddPosition(lastPosition.Value);
|
||||
return base.OnMouseMove(state);
|
||||
}
|
||||
|
||||
Vector2 pos1 = lastPosition.Value;
|
||||
Vector2 pos2 = state.Mouse.NativeState.Position;
|
||||
|
||||
foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position))
|
||||
{
|
||||
Vector2 diff = pos2 - pos1;
|
||||
float distance = diff.Length;
|
||||
Vector2 direction = diff / distance;
|
||||
@ -133,6 +136,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
lastPosition = pos1 + direction * d;
|
||||
addPosition(lastPosition.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseMove(state);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user