Fix nested objects in overlapping scrolling hit object container ruleset not using correct reference time

This commit is contained in:
Dean Herbert 2022-10-18 16:15:21 +09:00
parent ec3761ced9
commit d237c818f6
6 changed files with 13 additions and 12 deletions

View File

@ -20,7 +20,7 @@ public float GetLength(double startTime, double endTime, double timeRange, float
return -PositionAt(startTime, endTime, timeRange, scrollLength);
}
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength, double? originTime = null)
=> (float)((time - currentTime) / timeRange * scrollLength);
public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)

View File

@ -53,8 +53,9 @@ public interface IScrollAlgorithm
/// <param name="currentTime">The current time.</param>
/// <param name="timeRange">The amount of visible time.</param>
/// <param name="scrollLength">The absolute spatial length through <paramref name="timeRange"/>.</param>
/// <param name="originTime">The time to be used for control point lookups (ie. the parent's start time for nested hit objects).</param>
/// <returns>The absolute spatial position.</returns>
float PositionAt(double time, double currentTime, double timeRange, float scrollLength);
float PositionAt(double time, double currentTime, double timeRange, float scrollLength, double? originTime = null);
/// <summary>
/// Computes the time which brings a point to a provided spatial position given the current time.
@ -63,7 +64,7 @@ public interface IScrollAlgorithm
/// <param name="currentTime">The current time.</param>
/// <param name="timeRange">The amount of visible time.</param>
/// <param name="scrollLength">The absolute spatial length through <paramref name="timeRange"/>.</param>
/// <returns>The time at which <see cref="PositionAt(double,double,double,float)"/> == <paramref name="position"/>.</returns>
/// <returns>The time at which <see cref="PositionAt(double,double,double,float, double?)"/> == <paramref name="position"/>.</returns>
double TimeAt(float position, double currentTime, double timeRange, float scrollLength);
/// <summary>

View File

@ -34,8 +34,8 @@ public float GetLength(double startTime, double endTime, double timeRange, float
return -PositionAt(startTime, endTime, timeRange, scrollLength);
}
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
=> (float)((time - currentTime) / timeRange * controlPointAt(time).Multiplier * scrollLength);
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength, double? originTime = null)
=> (float)((time - currentTime) / timeRange * controlPointAt(originTime ?? time).Multiplier * scrollLength);
public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)
{

View File

@ -38,7 +38,7 @@ public float GetLength(double startTime, double endTime, double timeRange, float
return (float)(objectLength * scrollLength);
}
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength, double? originTime = null)
{
double timelineLength = relativePositionAt(time, timeRange) - relativePositionAt(currentTime, timeRange);
return (float)(timelineLength * scrollLength);

View File

@ -93,9 +93,9 @@ public double TimeAtScreenSpacePosition(Vector2 screenSpacePosition)
/// <summary>
/// Given a time, return the position along the scrolling axis within this <see cref="HitObjectContainer"/> at time <paramref name="currentTime"/>.
/// </summary>
public float PositionAtTime(double time, double currentTime)
public float PositionAtTime(double time, double currentTime, double? originTime = null)
{
float scrollPosition = scrollingInfo.Algorithm.PositionAt(time, currentTime, timeRange.Value, scrollLength);
float scrollPosition = scrollingInfo.Algorithm.PositionAt(time, currentTime, timeRange.Value, scrollLength, originTime);
return axisInverted ? -scrollPosition : scrollPosition;
}
@ -252,14 +252,14 @@ private void updateLayoutRecursive(DrawableHitObject hitObject)
updateLayoutRecursive(obj);
// Nested hitobjects don't need to scroll, but they do need accurate positions and start lifetime
updatePosition(obj, hitObject.HitObject.StartTime);
updatePosition(obj, hitObject.HitObject.StartTime, hitObject.HitObject.StartTime);
setComputedLifetimeStart(obj.Entry);
}
}
private void updatePosition(DrawableHitObject hitObject, double currentTime)
private void updatePosition(DrawableHitObject hitObject, double currentTime, double? parentHitObjectStartTime = null)
{
float position = PositionAtTime(hitObject.HitObject.StartTime, currentTime);
float position = PositionAtTime(hitObject.HitObject.StartTime, currentTime, parentHitObjectStartTime);
if (scrollingAxis == Direction.Horizontal)
hitObject.X = position;

View File

@ -99,7 +99,7 @@ public double GetDisplayStartTime(double originTime, float offset, double timeRa
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
=> implementation.GetLength(startTime, endTime, timeRange, scrollLength);
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength, double? originTime = null)
=> implementation.PositionAt(time, currentTime, timeRange, scrollLength);
public double TimeAt(float position, double currentTime, double timeRange, float scrollLength)