1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

InputResample CursorTrail

This commit is contained in:
WebFreak001 2017-05-03 18:33:42 +02:00
parent f5981b1ab9
commit 008ff9d2f9

View File

@ -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,22 +118,24 @@ 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;
Vector2 diff = pos2 - pos1;
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position))
{
lastPosition = pos1 + direction * d;
addPosition(lastPosition.Value);
Vector2 diff = pos2 - pos1;
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
{
lastPosition = pos1 + direction * d;
addPosition(lastPosition.Value);
}
}
return base.OnMouseMove(state);