Update spm value when spinner not active.

This commit is contained in:
Huo Yaoyuan 2017-10-05 19:23:58 +08:00
parent 3de42ee405
commit 134e1299bb
1 changed files with 11 additions and 11 deletions

View File

@ -112,20 +112,20 @@ protected override void Update()
currentRotation += thisAngle - lastAngle;
RotationAbsolute += Math.Abs(thisAngle - lastAngle);
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;
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;
}
rotations.Enqueue(currentRotation);
times.Enqueue(Time.Current);