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 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,22 +118,24 @@ 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;
|
|
||||||
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;
|
Vector2 diff = pos2 - pos1;
|
||||||
addPosition(lastPosition.Value);
|
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);
|
return base.OnMouseMove(state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user