mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 07:43:01 +08:00
Merge branch 'master' into editor-timing-screen-change-handling
This commit is contained in:
commit
b14b16071c
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(TextureStore textures)
|
private void load(TextureStore textures, DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Texture = textures.Get(@"Gameplay/osu/disc"),
|
Texture = textures.Get(@"Gameplay/osu/disc"),
|
||||||
},
|
},
|
||||||
new TrianglesPiece
|
new TrianglesPiece((int)drawableHitObject.HitObject.StartTime)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
|
@ -11,7 +11,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
protected override bool CreateNewTriangles => false;
|
protected override bool CreateNewTriangles => false;
|
||||||
protected override float SpawnRatio => 0.5f;
|
protected override float SpawnRatio => 0.5f;
|
||||||
|
|
||||||
public TrianglesPiece()
|
public TrianglesPiece(int? seed = null)
|
||||||
|
: base(seed)
|
||||||
{
|
{
|
||||||
TriangleScale = 1.2f;
|
TriangleScale = 1.2f;
|
||||||
HideAlphaDiscrepancies = false;
|
HideAlphaDiscrepancies = false;
|
||||||
|
@ -86,13 +86,24 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float Velocity = 1;
|
public float Velocity = 1;
|
||||||
|
|
||||||
|
private readonly Random stableRandom;
|
||||||
|
|
||||||
|
private float nextRandom() => (float)(stableRandom?.NextDouble() ?? RNG.NextSingle());
|
||||||
|
|
||||||
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
||||||
|
|
||||||
private IShader shader;
|
private IShader shader;
|
||||||
private readonly Texture texture;
|
private readonly Texture texture;
|
||||||
|
|
||||||
public Triangles()
|
/// <summary>
|
||||||
|
/// Construct a new triangle visualisation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seed">An optional seed to stabilise random positions / attributes. Note that this does not guarantee stable playback when seeking in time.</param>
|
||||||
|
public Triangles(int? seed = null)
|
||||||
{
|
{
|
||||||
|
if (seed != null)
|
||||||
|
stableRandom = new Random(seed.Value);
|
||||||
|
|
||||||
texture = Texture.WhitePixel;
|
texture = Texture.WhitePixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +186,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
{
|
{
|
||||||
TriangleParticle particle = CreateTriangle();
|
TriangleParticle particle = CreateTriangle();
|
||||||
|
|
||||||
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
|
particle.Position = new Vector2(nextRandom(), randomY ? nextRandom() : 1);
|
||||||
particle.ColourShade = RNG.NextSingle();
|
particle.ColourShade = nextRandom();
|
||||||
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
||||||
|
|
||||||
return particle;
|
return particle;
|
||||||
@ -191,8 +202,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
const float std_dev = 0.16f;
|
const float std_dev = 0.16f;
|
||||||
const float mean = 0.5f;
|
const float mean = 0.5f;
|
||||||
|
|
||||||
float u1 = 1 - RNG.NextSingle(); //uniform(0,1] random floats
|
float u1 = 1 - nextRandom(); //uniform(0,1] random floats
|
||||||
float u2 = 1 - RNG.NextSingle();
|
float u2 = 1 - nextRandom();
|
||||||
float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); // random normal(0,1)
|
float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); // random normal(0,1)
|
||||||
var scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
var scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user