Fix incorrect cursor trail size + scale

This commit is contained in:
smoogipoo 2019-09-09 19:30:31 +09:00
parent a200485fbd
commit e3b972187e
1 changed files with 17 additions and 4 deletions

View File

@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using osu.Framework.Allocation;
using osu.Framework.Caching;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Batches;
using osu.Framework.Graphics.OpenGL.Vertices;
@ -72,6 +73,20 @@ public Texture Texture
}
}
private readonly Cached<Vector2> partSizeCache = new Cached<Vector2>();
private Vector2 partSize => partSizeCache.IsValid
? partSizeCache.Value
: (partSizeCache.Value = new Vector2(Texture.DisplayWidth, Texture.DisplayHeight) * DrawInfo.Matrix.ExtractScale().Xy);
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
{
if ((invalidation & (Invalidation.DrawInfo | Invalidation.RequiredParentSizeToFit | Invalidation.Presence)) > 0)
partSizeCache.Invalidate();
return base.Invalidate(invalidation, source, shallPropagate);
}
/// <summary>
/// The amount of time to fade the cursor trail pieces.
/// </summary>
@ -104,8 +119,6 @@ private void resetTime()
timeOffset = Time.Current;
}
private Vector2 size => texture.Size * Scale;
/// <summary>
/// Whether to interpolate mouse movements and add trail pieces at intermediate points.
/// </summary>
@ -139,7 +152,7 @@ protected override bool OnMouseMove(MouseMoveEvent e)
float distance = diff.Length;
Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f;
float interval = partSize.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval)
{
@ -202,7 +215,7 @@ public override void ApplyState()
shader = Source.shader;
texture = Source.texture;
size = Source.size;
size = Source.partSize;
time = Source.time;
for (int i = 0; i < Source.parts.Length; ++i)