mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Merge pull request #3106 from peppy/fix-repeat-arrow-interpolation
Add interpolation to repeat point during sliding
This commit is contained in:
commit
bc92bed72f
@ -75,6 +75,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool hasRotation;
|
||||||
|
|
||||||
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
||||||
{
|
{
|
||||||
bool isRepeatAtEnd = repeatPoint.RepeatIndex % 2 == 0;
|
bool isRepeatAtEnd = repeatPoint.RepeatIndex % 2 == 0;
|
||||||
@ -88,15 +90,33 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
int searchStart = isRepeatAtEnd ? curve.Count - 1 : 0;
|
int searchStart = isRepeatAtEnd ? curve.Count - 1 : 0;
|
||||||
int direction = isRepeatAtEnd ? -1 : 1;
|
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.
|
// 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)
|
for (int i = searchStart; i >= 0 && i < curve.Count; i += direction)
|
||||||
{
|
{
|
||||||
if (Precision.AlmostEquals(curve[i], Position))
|
if (Precision.AlmostEquals(curve[i], Position))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(curve[i].Y - Position.Y, curve[i].X - Position.X));
|
aimRotationVector = curve[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float aimRotation = MathHelper.RadiansToDegrees((float)Math.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
|
||||||
|
while (Math.Abs(aimRotation - Rotation) > 180)
|
||||||
|
aimRotation += aimRotation < Rotation ? 360 : -360;
|
||||||
|
|
||||||
|
if (!hasRotation)
|
||||||
|
{
|
||||||
|
Rotation = aimRotation;
|
||||||
|
hasRotation = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If we're already snaking, interpolate to smooth out sharp curves (linear sliders, mainly).
|
||||||
|
Rotation = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 100), Rotation, aimRotation, 0, 50, Easing.OutQuint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user