mirror of
https://github.com/ppy/osu
synced 2024-12-15 03:16:17 +00:00
Remove delay of lifetime update
The scheduling is no longer necessary because `OnAdd` is changed to not invoked immediately for non-pooled DHOs.
This commit is contained in:
parent
3cedc0824d
commit
742c5b442b
@ -17,11 +17,6 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
private readonly IBindable<double> timeRange = new BindableDouble();
|
private readonly IBindable<double> timeRange = new BindableDouble();
|
||||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Hit objects which require lifetime computation in the next update call.
|
|
||||||
/// </summary>
|
|
||||||
private readonly HashSet<DrawableHitObject> toComputeLifetime = new HashSet<DrawableHitObject>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A set of top-level <see cref="DrawableHitObject"/>s which have an up-to-date layout.
|
/// A set of top-level <see cref="DrawableHitObject"/>s which have an up-to-date layout.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -54,7 +49,6 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
{
|
{
|
||||||
base.Clear();
|
base.Clear();
|
||||||
|
|
||||||
toComputeLifetime.Clear();
|
|
||||||
layoutComputed.Clear();
|
layoutComputed.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,20 +152,14 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
|
|
||||||
protected override void OnRemove(DrawableHitObject drawableHitObject)
|
protected override void OnRemove(DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
toComputeLifetime.Remove(drawableHitObject);
|
|
||||||
layoutComputed.Remove(drawableHitObject);
|
layoutComputed.Remove(drawableHitObject);
|
||||||
|
|
||||||
drawableHitObject.DefaultsApplied -= invalidateHitObject;
|
drawableHitObject.DefaultsApplied -= invalidateHitObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Make this <see cref="DrawableHitObject"/> lifetime and layout computed in next update.
|
|
||||||
/// </summary>
|
|
||||||
private void invalidateHitObject(DrawableHitObject hitObject)
|
private void invalidateHitObject(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
// Lifetime computation is delayed until next update because
|
hitObject.LifetimeStart = computeOriginAdjustedLifetimeStart(hitObject);
|
||||||
// when the hit object is not pooled this container is not loaded here and `scrollLength` cannot be computed.
|
|
||||||
toComputeLifetime.Add(hitObject);
|
|
||||||
layoutComputed.Remove(hitObject);
|
layoutComputed.Remove(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,39 +169,29 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (!layoutCache.IsValid)
|
if (layoutCache.IsValid) return;
|
||||||
|
|
||||||
|
foreach (var hitObject in Objects)
|
||||||
{
|
{
|
||||||
toComputeLifetime.Clear();
|
if (hitObject.HitObject != null)
|
||||||
|
invalidateHitObject(hitObject);
|
||||||
foreach (var hitObject in Objects)
|
|
||||||
{
|
|
||||||
if (hitObject.HitObject != null)
|
|
||||||
toComputeLifetime.Add(hitObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutComputed.Clear();
|
|
||||||
|
|
||||||
scrollingInfo.Algorithm.Reset();
|
|
||||||
|
|
||||||
switch (direction.Value)
|
|
||||||
{
|
|
||||||
case ScrollingDirection.Up:
|
|
||||||
case ScrollingDirection.Down:
|
|
||||||
scrollLength = DrawSize.Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
scrollLength = DrawSize.X;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutCache.Validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var hitObject in toComputeLifetime)
|
scrollingInfo.Algorithm.Reset();
|
||||||
hitObject.LifetimeStart = computeOriginAdjustedLifetimeStart(hitObject);
|
|
||||||
|
|
||||||
toComputeLifetime.Clear();
|
switch (direction.Value)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
scrollLength = DrawSize.Y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
scrollLength = DrawSize.X;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
layoutCache.Validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildrenLife()
|
protected override void UpdateAfterChildrenLife()
|
||||||
|
Loading…
Reference in New Issue
Block a user