Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions osu.Game.Rulesets.Osu/Skinning/Default/SliderBall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down