mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 17:13:06 +08:00
Tidy up lastAngle
usage and add assertion of maximum delta
This commit is contained in:
parent
04af46b8c7
commit
10bab61441
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -68,6 +69,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
float thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2));
|
float thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2));
|
||||||
float delta = lastAngle == null ? 0 : thisAngle - lastAngle.Value;
|
float delta = lastAngle == null ? 0 : thisAngle - lastAngle.Value;
|
||||||
|
|
||||||
|
// Normalise the delta to -180 .. 180
|
||||||
|
if (delta > 180) delta -= 360;
|
||||||
|
if (delta < -180) delta += 360;
|
||||||
|
|
||||||
if (Tracking)
|
if (Tracking)
|
||||||
AddRotation(delta);
|
AddRotation(delta);
|
||||||
|
|
||||||
@ -84,8 +89,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Will be a no-op if not a valid time to spin.
|
/// Will be a no-op if not a valid time to spin.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="angle">The delta angle.</param>
|
/// <param name="delta">The delta angle.</param>
|
||||||
public void AddRotation(float angle)
|
public void AddRotation(float delta)
|
||||||
{
|
{
|
||||||
if (!isSpinnableTime)
|
if (!isSpinnableTime)
|
||||||
return;
|
return;
|
||||||
@ -96,21 +101,15 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|||||||
rotationTransferred = true;
|
rotationTransferred = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angle > 180)
|
currentRotation += delta;
|
||||||
{
|
|
||||||
lastAngle += 360;
|
double rate = gameplayClock?.GetTrueGameplayRate() ?? Clock.Rate;
|
||||||
angle -= 360;
|
|
||||||
}
|
Debug.Assert(Math.Abs(delta) <= 180);
|
||||||
else if (-angle > 180)
|
|
||||||
{
|
|
||||||
lastAngle -= 360;
|
|
||||||
angle += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentRotation += angle;
|
|
||||||
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
||||||
// (see: ModTimeRamp)
|
// (see: ModTimeRamp)
|
||||||
drawableSpinner.Result.TotalRotation += (float)(Math.Abs(angle) * (gameplayClock?.GetTrueGameplayRate() ?? Clock.Rate));
|
drawableSpinner.Result.TotalRotation += (float)(Math.Abs(delta) * rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetState(DrawableHitObject obj)
|
private void resetState(DrawableHitObject obj)
|
||||||
|
Loading…
Reference in New Issue
Block a user