Merge pull request #13258 from ekrctb/fix-scrolling-lifetime

Fix lifetime of scrolling hit object not updated when scrolling speed is adjusted
This commit is contained in:
Dan Balasescu
2021-06-02 11:48:48 +09:00
committed by GitHub
3 changed files with 23 additions and 8 deletions

View File

@ -90,6 +90,20 @@ namespace osu.Game.Tests.Visual.Gameplay
assertChildPosition(5);
}
[TestCase("pooled")]
[TestCase("non-pooled")]
public void TestLifetimeRecomputedWhenTimeRangeChanges(string pooled)
{
var beatmap = createBeatmap(_ => pooled == "pooled" ? new TestPooledHitObject() : new TestHitObject());
beatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = time_range });
createTest(beatmap);
assertDead(3);
AddStep("increase time range", () => drawableRuleset.TimeRange.Value = 3 * time_range);
assertPosition(3, 1);
}
[Test]
public void TestRelativeBeatLengthScaleSingleTimingPoint()
{

View File

@ -35,11 +35,11 @@ namespace osu.Game.Rulesets.Objects
HitObject = hitObject;
startTimeBindable.BindTo(HitObject.StartTimeBindable);
startTimeBindable.BindValueChanged(_ => setInitialLifetime(), true);
startTimeBindable.BindValueChanged(_ => SetInitialLifetime(), true);
// Subscribe to this event before the DrawableHitObject so that the local callback is invoked before the entry is re-applied as a result of DefaultsApplied.
// This way, the DrawableHitObject can use OnApply() to overwrite the LifetimeStart that was set inside setInitialLifetime().
HitObject.DefaultsApplied += _ => setInitialLifetime();
HitObject.DefaultsApplied += _ => SetInitialLifetime();
}
// The lifetime, as set by the hitobject.
@ -94,6 +94,6 @@ namespace osu.Game.Rulesets.Objects
/// <summary>
/// Set <see cref="LifetimeEntry.LifetimeStart"/> using <see cref="InitialLifetimeOffset"/>.
/// </summary>
private void setInitialLifetime() => LifetimeStart = HitObject.StartTime - InitialLifetimeOffset;
internal void SetInitialLifetime() => LifetimeStart = HitObject.StartTime - InitialLifetimeOffset;
}
}

View File

@ -172,11 +172,12 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (layoutCache.IsValid) return;
foreach (var hitObject in Objects)
{
if (hitObject.HitObject != null)
invalidateHitObject(hitObject);
}
layoutComputed.Clear();
// Reset lifetime to the conservative estimation.
// If a drawable becomes alive by this lifetime, its lifetime will be updated to a more precise lifetime in the next update.
foreach (var entry in Entries)
entry.SetInitialLifetime();
scrollingInfo.Algorithm.Reset();