From c4854d40048fde964eff9f54e01e60458c052555 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 May 2022 17:55:12 +0900 Subject: [PATCH] Fix slider ball rotation becoming undefined when time is not flowing smoothly --- osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs index 8943a91076..710967b741 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs @@ -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