mirror of
https://github.com/osukey/osukey.git
synced 2025-05-31 02:17:34 +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 Vector2? lastPosition;
|
||||||
|
|
||||||
|
private InputResampler resampler = new InputResampler();
|
||||||
|
|
||||||
protected override DrawNode CreateDrawNode() => new TrailDrawNode();
|
protected override DrawNode CreateDrawNode() => new TrailDrawNode();
|
||||||
|
|
||||||
protected override void ApplyDrawNode(DrawNode node)
|
protected override void ApplyDrawNode(DrawNode node)
|
||||||
@ -116,12 +118,13 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
if (lastPosition == null)
|
if (lastPosition == null)
|
||||||
{
|
{
|
||||||
lastPosition = state.Mouse.NativeState.Position;
|
lastPosition = state.Mouse.NativeState.Position;
|
||||||
|
resampler.AddPosition(lastPosition.Value);
|
||||||
return base.OnMouseMove(state);
|
return base.OnMouseMove(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 pos1 = lastPosition.Value;
|
Vector2 pos1 = lastPosition.Value;
|
||||||
Vector2 pos2 = state.Mouse.NativeState.Position;
|
foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position))
|
||||||
|
{
|
||||||
Vector2 diff = pos2 - pos1;
|
Vector2 diff = pos2 - pos1;
|
||||||
float distance = diff.Length;
|
float distance = diff.Length;
|
||||||
Vector2 direction = diff / distance;
|
Vector2 direction = diff / distance;
|
||||||
@ -133,6 +136,7 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
lastPosition = pos1 + direction * d;
|
lastPosition = pos1 + direction * d;
|
||||||
addPosition(lastPosition.Value);
|
addPosition(lastPosition.Value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return base.OnMouseMove(state);
|
return base.OnMouseMove(state);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user