This commit is contained in:
ColdVolcano
2017-06-18 23:52:42 -05:00
parent 84aa17dea3
commit 77ca48c1bd

View File

@ -162,34 +162,37 @@ namespace osu.Game.Screens.Menu
if (AudioData != null) if (AudioData != null)
{ {
for (int i = 0; i < bars_per_visualizer * visualizers; i++) for (int j = 0; j < visualizers; j++)
{ {
float rotation = MathHelper.DegreesToRadians(i / (float)bars_per_visualizer * 360 + (i / bars_per_visualizer) * (360 / visualizers)); for (int i = 0; i < bars_per_visualizer; i++)
float rotationCos = (float)Math.Cos(rotation); {
float rotationSin = (float)Math.Sin(rotation); float rotation = MathHelper.DegreesToRadians(i / (float)bars_per_visualizer * 360 + j * 360 / visualizers);
//taking the cos and sin to the 0..1 range float rotationCos = (float)Math.Cos(rotation);
var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * Size; float rotationSin = (float)Math.Sin(rotation);
//taking the cos and sin to the 0..1 range
var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * Size;
var barSize = new Vector2(Size * (float)Math.Sqrt(2 * (1 - Math.Cos(MathHelper.DegreesToRadians(360f / bars_per_visualizer)))) / 2f, bar_length * AudioData[i % bars_per_visualizer]); var barSize = new Vector2(Size * (float)Math.Sqrt(2 * (1 - Math.Cos(MathHelper.DegreesToRadians(360f / bars_per_visualizer)))) / 2f, bar_length * AudioData[i % bars_per_visualizer]);
//The distance between the position and the sides of the bar. //The distance between the position and the sides of the bar.
var bottomOffset = new Vector2(-rotationSin * barSize.X / 2, rotationCos * barSize.X / 2); var bottomOffset = new Vector2(-rotationSin * barSize.X / 2, rotationCos * barSize.X / 2);
//The distance between the bottom side of the bar and the top side. //The distance between the bottom side of the bar and the top side.
var amplitudeOffset = new Vector2(rotationCos * barSize.Y, rotationSin * barSize.Y); var amplitudeOffset = new Vector2(rotationCos * barSize.Y, rotationSin * barSize.Y);
var rectangle = new Quad( var rectangle = new Quad(
(barPosition - bottomOffset) * DrawInfo.Matrix, (barPosition - bottomOffset) * DrawInfo.Matrix,
(barPosition - bottomOffset + amplitudeOffset) * DrawInfo.Matrix, (barPosition - bottomOffset + amplitudeOffset) * DrawInfo.Matrix,
(barPosition + bottomOffset) * DrawInfo.Matrix, (barPosition + bottomOffset) * DrawInfo.Matrix,
(barPosition + bottomOffset + amplitudeOffset) * DrawInfo.Matrix (barPosition + bottomOffset + amplitudeOffset) * DrawInfo.Matrix
); );
Texture.DrawQuad( Texture.DrawQuad(
rectangle, rectangle,
colourInfo, colourInfo,
null, null,
Shared.VertexBatch.Add, Shared.VertexBatch.Add,
//barSize by itself will make it smooth more in the X axis than in the Y axis, this reverts that. //barSize by itself will make it smooth more in the X axis than in the Y axis, this reverts that.
Vector2.Divide(inflation, barSize.Yx)); Vector2.Divide(inflation, barSize.Yx));
}
} }
} }
Shader.Unbind(); Shader.Unbind();