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

Smooth spm values into a time range.

This commit is contained in:
Huo Yaoyuan 2017-09-30 15:23:10 +08:00
parent e2e26c91af
commit 3de42ee405
2 changed files with 19 additions and 4 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -187,7 +188,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
circle.Rotation = disc.Rotation;
ticks.Rotation = disc.Rotation;
spmText.Text = disc.SpinsPerMinute.ToString(@"#0");
spmText.Text = Math.Truncate(disc.SpinsPerMinute).ToString(@"#0");
float relativeCircleScale = spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, Easing.OutQuint);

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
@ -76,9 +77,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private float lastAngle;
private float currentRotation;
private double lastTime;
public float RotationAbsolute;
public double SpinsPerMinute;
private readonly Queue<float> rotations = new Queue<float>();
private readonly Queue<double> times = new Queue<double>();
private const double spm_count_duration = 595; // not using hundreds to avoid frame rounding issues
private int completeTick;
@ -109,11 +112,22 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
currentRotation += thisAngle - lastAngle;
RotationAbsolute += Math.Abs(thisAngle - lastAngle);
SpinsPerMinute = (thisAngle - lastAngle) / (Time.Current - lastTime) * 1000 * 60 / 360;
if (rotations.Count > 0)
{
float rotationFrom = rotations.Peek();
double timeFrom = times.Peek();
while (Time.Current - times.Peek() > spm_count_duration)
{
rotationFrom = rotations.Dequeue();
timeFrom = times.Dequeue();
}
SpinsPerMinute = (currentRotation - rotationFrom) / (Time.Current - timeFrom) * 1000 * 60 / 360;
}
}
lastAngle = thisAngle;
lastTime = Time.Current;
rotations.Enqueue(currentRotation);
times.Enqueue(Time.Current);
if (Complete && updateCompleteTick())
{