Fix slider ball rotation becoming undefined when time is not flowing smoothly

This commit is contained in:
Dean Herbert 2022-05-12 17:55:12 +09:00
parent 5f2d9bf04c
commit c4854d4004
1 changed files with 6 additions and 6 deletions

View File

@ -195,16 +195,16 @@ private bool isValidTrackingAction(OsuAction action)
public void UpdateProgress(double completionProgress)
{
var newPos = drawableSlider.HitObject.CurvePositionAt(completionProgress);
Position = drawableSlider.HitObject.CurvePositionAt(completionProgress);
var diff = lastPosition.HasValue ? lastPosition.Value - newPos : newPos - drawableSlider.HitObject.CurvePositionAt(completionProgress + 0.01f);
if (diff == Vector2.Zero)
var diff = lastPosition.HasValue ? lastPosition.Value - Position : Position - drawableSlider.HitObject.CurvePositionAt(completionProgress + 0.01f);
// Ensure the value is substantially high enough to allow for Atan2 to get a valid angle.
if (diff.LengthFast < 0.01f)
return;
Position = newPos;
ball.Rotation = -90 + (float)(-Math.Atan2(diff.X, diff.Y) * 180 / Math.PI);
lastPosition = newPos;
lastPosition = Position;
}
private class FollowCircleContainer : CircularContainer