1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-23 03:59:52 +08:00

Avoid Triangles draw node invalidation when nothing is changing

Basically only helps when time is paused. ie in the editor.
This commit is contained in:
Dean Herbert
2025-03-20 14:24:17 +09:00
Unverified
parent 80ff974594
commit b1131ffd23
2 changed files with 22 additions and 4 deletions
+11 -2
View File
@@ -127,8 +127,6 @@ namespace osu.Game.Graphics.Backgrounds
{
base.Update();
Invalidate(Invalidation.DrawNode);
if (CreateNewTriangles)
addTriangles(false);
@@ -138,6 +136,10 @@ namespace osu.Game.Graphics.Backgrounds
: 1;
float elapsedSeconds = (float)Time.Elapsed / 1000;
if (elapsedSeconds == 0)
return;
// Since position is relative, the velocity needs to scale inversely with DrawHeight.
// Since we will later multiply by the scale of individual triangles we normalize by
// dividing by triangleScale.
@@ -157,6 +159,8 @@ namespace osu.Game.Graphics.Backgrounds
if (bottomPos < 0)
parts.RemoveAt(i);
}
Invalidate(Invalidation.DrawNode);
}
/// <summary>
@@ -183,8 +187,13 @@ namespace osu.Game.Graphics.Backgrounds
int currentCount = parts.Count;
if (AimCount - currentCount == 0)
return;
for (int i = 0; i < AimCount - currentCount; i++)
parts.Add(createTriangle(randomY));
Invalidate(Invalidation.DrawNode);
}
private TriangleParticle createTriangle(bool randomY)
+11 -2
View File
@@ -91,12 +91,14 @@ namespace osu.Game.Graphics.Backgrounds
{
base.Update();
Invalidate(Invalidation.DrawNode);
if (CreateNewTriangles)
addTriangles(false);
float elapsedSeconds = (float)Time.Elapsed / 1000;
if (elapsedSeconds == 0)
return;
// Since position is relative, the velocity needs to scale inversely with DrawHeight.
float movedDistance = -elapsedSeconds * Velocity * base_velocity / DrawHeight;
@@ -112,6 +114,8 @@ namespace osu.Game.Graphics.Backgrounds
if (bottomPos < 0)
parts.RemoveAt(i);
}
Invalidate(Invalidation.DrawNode);
}
/// <summary>
@@ -138,8 +142,13 @@ namespace osu.Game.Graphics.Backgrounds
int currentCount = parts.Count;
if (AimCount - currentCount == 0)
return;
for (int i = 0; i < AimCount - currentCount; i++)
parts.Add(createTriangle(randomY));
Invalidate(Invalidation.DrawNode);
}
private TriangleParticle createTriangle(bool randomY)