Skip to content

Commit

Permalink
Merge branch 'limit-max-triangles' into update-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Sep 16, 2021
2 parents fde7c88 + 07fec26 commit 6b43e95
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion osu.Game/Graphics/Backgrounds/Triangles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using osu.Framework.Allocation;
using System.Collections.Generic;
using osu.Framework.Graphics.Batches;
using osu.Framework.Graphics.OpenGL.Buffers;
using osu.Framework.Graphics.OpenGL.Vertices;
using osu.Framework.Lists;

Expand Down Expand Up @@ -181,7 +182,10 @@ public void Reset(int? seed = null)

private void addTriangles(bool randomY)
{
AimCount = (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio);
// limited by the maximum size of QuadVertexBuffer for safety.
const int max_triangles = QuadVertexBuffer<TexturedVertex2D>.MAX_QUADS;

AimCount = (int)Math.Min(max_triangles, (DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio));

for (int i = 0; i < AimCount - parts.Count; i++)
parts.Add(createTriangle(randomY));
Expand Down

0 comments on commit 6b43e95

Please sign in to comment.