From a1b9499480b152354588983235abf560cc982aa9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Jun 2017 18:41:11 +0900 Subject: [PATCH] More documentation and constants --- osu.Game/Screens/Menu/LogoVisualisation.cs | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 76f0292660..dcba07a8a3 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -23,16 +23,36 @@ namespace osu.Game.Screens.Menu { private readonly Bindable beatmap = new Bindable(); + /// + /// The number of bars to jump each update iteration. + /// private const int index_change = 5; + + /// + /// The maximum length of each bar in the visualiser. Will be reduced when kiai is not activated. + /// private const float bar_length = 600; + + /// + /// The number of bars in one rotation of the visualiser. + /// private const int bars_per_visualizer = 200; - private const float visualizers = 5; + + /// + /// How many times we should stretch around the circumference (overlapping overselves). + /// + private const float visualiser_rounds = 5; /// /// How much should each bar go down each milisecond (based on a full bar) /// private const float decay_per_milisecond = 0.0024f; + /// + /// Number of milliseconds between each amplitude update. + /// + private const float time_between_updates = 50; + private int indexOffset; public Color4 AccentColour { get; set; } @@ -59,7 +79,7 @@ namespace osu.Game.Screens.Menu shader = shaders?.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED); } - private void ensureAmplitudes() + private void updateAmplitudes() { float[] temporalAmplitudes = beatmap.Value?.Track?.CurrentAmplitudes.FrequencyAmplitudes ?? new float[256]; @@ -79,14 +99,15 @@ namespace osu.Game.Screens.Menu frequencyAmplitudes[i] = frequencyAmplitudes[(i + index_change) % bars_per_visualizer]; } } + indexOffset = (indexOffset + index_change) % bars_per_visualizer; - Scheduler.AddDelayed(ensureAmplitudes, 50); + Scheduler.AddDelayed(updateAmplitudes, time_between_updates); } protected override void LoadComplete() { base.LoadComplete(); - ensureAmplitudes(); + updateAmplitudes(); } protected override void Update() @@ -152,11 +173,11 @@ namespace osu.Game.Screens.Menu if (AudioData != null) { - for (int j = 0; j < visualizers; j++) + for (int j = 0; j < visualiser_rounds; j++) { for (int i = 0; i < bars_per_visualizer; i++) { - float rotation = MathHelper.DegreesToRadians(i / (float)bars_per_visualizer * 360 + j * 360 / visualizers); + float rotation = MathHelper.DegreesToRadians(i / (float)bars_per_visualizer * 360 + j * 360 / visualiser_rounds); float rotationCos = (float)Math.Cos(rotation); float rotationSin = (float)Math.Sin(rotation); //taking the cos and sin to the 0..1 range