mirror of
https://github.com/osukey/osukey.git
synced 2025-04-29 02:37:25 +09:00
Optimize recalculateValues
This commit is contained in:
parent
2cfc4eb515
commit
4b544903cb
@ -190,27 +190,24 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void recalculateValues()
|
private void recalculateValues()
|
||||||
{
|
{
|
||||||
var newValues = new List<float>();
|
int columnCount = ColumnCount;
|
||||||
|
if (values == null || values.Length == 0 || columnCount == 0)
|
||||||
if (values == null)
|
|
||||||
{
|
{
|
||||||
for (float i = 0; i < ColumnCount; i++)
|
calculatedValues = new float[0];
|
||||||
{
|
return;
|
||||||
newValues.Add(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int max = values.Max();
|
|
||||||
float step = values.Length / (float)ColumnCount;
|
|
||||||
|
|
||||||
for (float i = 0; i < values.Length; i += step)
|
|
||||||
{
|
|
||||||
newValues.Add((float)values[(int)i] / max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
calculatedValues = newValues.ToArray();
|
float ratio = values.Length / (float)columnCount;
|
||||||
|
|
||||||
|
if (calculatedValues.Length != columnCount)
|
||||||
|
calculatedValues = new float[columnCount];
|
||||||
|
|
||||||
|
float max = (float)values.Max();
|
||||||
|
|
||||||
|
for (int i = 0; i < calculatedValues.Length; i++)
|
||||||
|
{
|
||||||
|
calculatedValues[i] = values[(int)(i * ratio)] / max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Column : Container, IStateful<ColumnState>
|
public partial class Column : Container, IStateful<ColumnState>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user