mirror of
https://github.com/ppy/osu.git
synced 2025-02-10 11:03:21 +08:00
Smooth spm values into a time range.
This commit is contained in:
parent
e2e26c91af
commit
3de42ee405
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -187,7 +188,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
circle.Rotation = disc.Rotation;
|
circle.Rotation = disc.Rotation;
|
||||||
ticks.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;
|
float relativeCircleScale = spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
|
||||||
disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, Easing.OutQuint);
|
disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, Easing.OutQuint);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -76,9 +77,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
private float lastAngle;
|
private float lastAngle;
|
||||||
private float currentRotation;
|
private float currentRotation;
|
||||||
private double lastTime;
|
|
||||||
public float RotationAbsolute;
|
public float RotationAbsolute;
|
||||||
public double SpinsPerMinute;
|
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;
|
private int completeTick;
|
||||||
|
|
||||||
@ -109,11 +112,22 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
currentRotation += thisAngle - lastAngle;
|
currentRotation += thisAngle - lastAngle;
|
||||||
RotationAbsolute += Math.Abs(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;
|
lastAngle = thisAngle;
|
||||||
lastTime = Time.Current;
|
rotations.Enqueue(currentRotation);
|
||||||
|
times.Enqueue(Time.Current);
|
||||||
|
|
||||||
if (Complete && updateCompleteTick())
|
if (Complete && updateCompleteTick())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user