1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Don't add nested hit objects to the sets

Only top-level hit objects are checked for layout computation caching.
Also, lifetime of nested hit objects are not managed by the HitObjectContainer.
This commit is contained in:
ekrctb 2021-05-31 16:02:33 +09:00
parent 8c6277f0d8
commit 3cedc0824d

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
private readonly HashSet<DrawableHitObject> toComputeLifetime = new HashSet<DrawableHitObject>();
/// <summary>
/// A set containing all <see cref="HitObjectContainer.AliveObjects"/> which have an up-to-date layout.
/// A set of top-level <see cref="DrawableHitObject"/>s which have an up-to-date layout.
/// </summary>
private readonly HashSet<DrawableHitObject> layoutComputed = new HashSet<DrawableHitObject>();
@ -150,29 +150,18 @@ namespace osu.Game.Rulesets.UI.Scrolling
}
}
protected override void OnAdd(DrawableHitObject drawableHitObject) => onAddRecursive(drawableHitObject);
protected override void OnRemove(DrawableHitObject drawableHitObject) => onRemoveRecursive(drawableHitObject);
private void onAddRecursive(DrawableHitObject hitObject)
protected override void OnAdd(DrawableHitObject drawableHitObject)
{
invalidateHitObject(hitObject);
hitObject.DefaultsApplied += invalidateHitObject;
foreach (var nested in hitObject.NestedHitObjects)
onAddRecursive(nested);
invalidateHitObject(drawableHitObject);
drawableHitObject.DefaultsApplied += invalidateHitObject;
}
private void onRemoveRecursive(DrawableHitObject hitObject)
protected override void OnRemove(DrawableHitObject drawableHitObject)
{
toComputeLifetime.Remove(hitObject);
layoutComputed.Remove(hitObject);
toComputeLifetime.Remove(drawableHitObject);
layoutComputed.Remove(drawableHitObject);
hitObject.DefaultsApplied -= invalidateHitObject;
foreach (var nested in hitObject.NestedHitObjects)
onRemoveRecursive(nested);
drawableHitObject.DefaultsApplied -= invalidateHitObject;
}
/// <summary>