1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 12:22:57 +08:00

Make SpawnRatio public

This commit is contained in:
Andrei Zavatski 2022-11-16 15:17:50 +03:00
parent cc4f05f3d3
commit 13cf3fc40c
2 changed files with 20 additions and 5 deletions

View File

@ -12,6 +12,8 @@ namespace osu.Game.Tests.Visual.Background
{
public class TestSceneTrianglesV2Background : OsuTestScene
{
private readonly TrianglesV2 triangles;
public TestSceneTrianglesV2Background()
{
AddRange(new Drawable[]
@ -25,10 +27,10 @@ namespace osu.Game.Tests.Visual.Background
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200),
Size = new Vector2(500),
Masking = true,
CornerRadius = 40,
Child = new TrianglesV2
Child = triangles = new TrianglesV2
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -39,5 +41,12 @@ namespace osu.Game.Tests.Visual.Background
}
});
}
protected override void LoadComplete()
{
base.LoadComplete();
AddSliderStep("Spawn ratio", 0f, 2f, 1f, s => triangles.SpawnRatio = s);
}
}
}

View File

@ -52,10 +52,16 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
protected virtual bool CreateNewTriangles => true;
private readonly BindableFloat spawnRatio = new BindableFloat(1f);
/// <summary>
/// The amount of triangles we want compared to the default distribution.
/// </summary>
protected virtual float SpawnRatio => 1;
public float SpawnRatio
{
get => spawnRatio.Value;
set => spawnRatio.Value = value;
}
/// <summary>
/// The relative velocity of the triangles. Default is 1.
@ -94,7 +100,7 @@ namespace osu.Game.Graphics.Backgrounds
colourTop.BindValueChanged(_ => updateTexture());
colourBottom.BindValueChanged(_ => updateTexture(), true);
addTriangles(true);
spawnRatio.BindValueChanged(_ => Reset(), true);
}
private void updateTexture()
@ -166,7 +172,7 @@ namespace osu.Game.Graphics.Backgrounds
// Limited by the maximum size of QuadVertexBuffer for safety.
const int max_triangles = ushort.MaxValue / (IRenderer.VERTICES_PER_QUAD + 2);
AimCount = (int)Math.Min(max_triangles, DrawWidth * DrawHeight * 0.001f * SpawnRatio);
AimCount = (int)Math.Min(max_triangles, DrawWidth * DrawHeight * 0.0005f * SpawnRatio);
int currentCount = parts.Count;