mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 06:12:56 +08:00
Add interpolation to repeat point during sliding
This commit is contained in:
parent
9dc55688d2
commit
10656be954
@ -74,6 +74,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
private bool hasRotation;
|
||||
|
||||
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
||||
{
|
||||
bool isRepeatAtEnd = repeatPoint.RepeatIndex % 2 == 0;
|
||||
@ -87,15 +89,30 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
int searchStart = isRepeatAtEnd ? curve.Count - 1 : 0;
|
||||
int direction = isRepeatAtEnd ? -1 : 1;
|
||||
|
||||
Vector2 aimRotationVector = Vector2.Zero;
|
||||
|
||||
// find the next vector2 in the curve which is not equal to our current position to infer a rotation.
|
||||
for (int i = searchStart; i >= 0 && i < curve.Count; i += direction)
|
||||
{
|
||||
if (Precision.AlmostEquals(curve[i], Position))
|
||||
continue;
|
||||
|
||||
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(curve[i].Y - Position.Y, curve[i].X - Position.X));
|
||||
aimRotationVector = curve[i];
|
||||
break;
|
||||
}
|
||||
|
||||
float aimRotation = MathHelper.RadiansToDegrees(
|
||||
(float)Math.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
|
||||
|
||||
if (!hasRotation || Math.Abs(aimRotation - Rotation) > 180)
|
||||
{
|
||||
Rotation = aimRotation;
|
||||
hasRotation = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rotation = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 100), Rotation, aimRotation, 0, 600, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user