mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 07:03:21 +08:00
Reduce per-triangle per-frame computation significantly
This commit is contained in:
parent
d3f2d480a8
commit
db444a61cb
@ -109,27 +109,27 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
|
|
||||||
Invalidate(Invalidation.DrawNode, shallPropagate: false);
|
Invalidate(Invalidation.DrawNode, shallPropagate: false);
|
||||||
|
|
||||||
addTriangles(false);
|
if (CreateNewTriangles)
|
||||||
|
addTriangles(false);
|
||||||
|
|
||||||
|
float adjustedAlpha = HideAlphaDiscrepancies ?
|
||||||
|
// Cubically scale alpha to make it drop off more sharply.
|
||||||
|
(float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) :
|
||||||
|
1;
|
||||||
|
|
||||||
|
float movedDistance = ((float)Time.Elapsed / 950) * Velocity * (50 / DrawHeight) / triangleScale;
|
||||||
|
|
||||||
for (int i = 0; i < parts.Count; i++)
|
for (int i = 0; i < parts.Count; i++)
|
||||||
{
|
{
|
||||||
TriangleParticle newParticle = parts[i];
|
TriangleParticle newParticle = parts[i];
|
||||||
|
|
||||||
float adjustedAlpha = HideAlphaDiscrepancies ?
|
// Scale moved distance by the size of the triangle. Smaller triangles should move more slowly.
|
||||||
// Cubically scale alpha to make it drop off more sharply.
|
newParticle.Position.Y += -parts[i].Scale * movedDistance;
|
||||||
(float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) :
|
|
||||||
1;
|
|
||||||
|
|
||||||
newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950);
|
|
||||||
newParticle.Colour.A = adjustedAlpha;
|
newParticle.Colour.A = adjustedAlpha;
|
||||||
|
|
||||||
parts[i] = newParticle;
|
parts[i] = newParticle;
|
||||||
|
|
||||||
if (!CreateNewTriangles)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight;
|
float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight;
|
||||||
|
|
||||||
if (bottomPos < 0)
|
if (bottomPos < 0)
|
||||||
parts.RemoveAt(i);
|
parts.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user