1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-22 07:47:29 +08:00

Cleanup + make travel time equal to the time span.

This commit is contained in:
smoogipooo 2017-06-02 16:04:14 +09:00
parent 563f746acf
commit 1eddc278a4

View File

@ -8,12 +8,6 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables
{ {
public class DrawableGravityTimingChange : DrawableTimingChange public class DrawableGravityTimingChange : DrawableTimingChange
{ {
// Amount of time to travel this container such that
// at time = 0, gravityTime = timeSpan and
// at time = travel_time, gravityTime = 0
// Where gravityTime is used as the position of the content
private const double travel_time = 1000;
public DrawableGravityTimingChange(TimingChange timingChange) public DrawableGravityTimingChange(TimingChange timingChange)
: base(timingChange) : base(timingChange)
{ {
@ -44,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables
// The sign of the relative time, this is used to apply backwards acceleration leading into startTime // The sign of the relative time, this is used to apply backwards acceleration leading into startTime
double sign = relativeTime < 0 ? -1 : 1; double sign = relativeTime < 0 ? -1 : 1;
return timeSpan - acceleration / 2 * relativeTime * relativeTime * sign; return timeSpan - acceleration * relativeTime * relativeTime * sign;
} }
/// <summary> /// <summary>
@ -55,20 +49,18 @@ namespace osu.Game.Rulesets.Mania.Timing.Drawables
/// <summary> /// <summary>
/// The acceleration due to "gravity" of the content of this container. /// The acceleration due to "gravity" of the content of this container.
/// </summary> /// </summary>
private double acceleration => 2 * timeSpan / travel_time / travel_time; private double acceleration => timeSpan / travelTime / travelTime;
/// <summary> /// <summary>
/// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="travel_time"/>. /// The travel time, after beat length adjustments.
/// </summary> /// </summary>
/// <param name="time">The non-offset time.</param> private double travelTime => timeSpan / TimingChange.SpeedMultiplier;
/// <returns>The current time relative to <paramref name="time"/> - <see cref="travel_time"/>. </returns>
private double relativeTimeAt(double time) => Time.Current - time + travel_time;
/// <summary> /// <summary>
/// The velocity of the content of this container at a time. /// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="travelTime"/>.
/// </summary> /// </summary>
/// <param name="time">The non-offset time.</param> /// <param name="time">The non-offset time.</param>
/// <returns>The velocity at <paramref name="time"/>.</returns> /// <returns>The current time relative to <paramref name="time"/> - <see cref="travelTime"/>. </returns>
private double velocityAt(double time) => acceleration * relativeTimeAt(time); private double relativeTimeAt(double time) => Time.Current - time + travelTime;
} }
} }