1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Fix invalid cursor trail parts being drawn (#6256)

Fix invalid cursor trail parts being drawn
This commit is contained in:
Dean Herbert 2019-09-25 16:42:05 +09:00 committed by GitHub
commit 576ca31499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,9 +40,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (int i = 0; i < max_sprites; i++)
{
// InvalidationID 1 forces an update of each part of the cursor trail the first time ApplyState is run on the draw node
// This is to prevent garbage data from being sent to the vertex shader, resulting in visual issues on some platforms
parts[i].InvalidationID = 1;
// -1 signals that the part is unusable, and should not be drawn
parts[i].InvalidationID = -1;
}
}
@ -112,6 +111,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (int i = 0; i < parts.Length; ++i)
{
parts[i].Time -= time;
if (parts[i].InvalidationID != -1)
++parts[i].InvalidationID;
}
@ -205,8 +206,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public TrailDrawNode(CursorTrail source)
: base(source)
{
for (int i = 0; i < max_sprites; i++)
parts[i].InvalidationID = 0;
}
public override void ApplyState()
@ -218,11 +217,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
size = Source.partSize;
time = Source.time;
for (int i = 0; i < Source.parts.Length; ++i)
{
if (Source.parts[i].InvalidationID > parts[i].InvalidationID)
parts[i] = Source.parts[i];
}
Source.parts.CopyTo(parts, 0);
}
public override void Draw(Action<TexturedVertex2D> vertexAction)
@ -234,6 +229,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
for (int i = 0; i < parts.Length; ++i)
{
if (parts[i].InvalidationID == -1)
continue;
vertexBatch.DrawTime = parts[i].Time;
Vector2 pos = parts[i].Position;