mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 00:53:22 +08:00
Improve timeline selection performance
But selecting a large number of hit objects is still very slow because all DHOs must be added and also `AddBlueprintFor` has quadratic behaviors
This commit is contained in:
parent
0613388aaa
commit
00b3d97f69
@ -58,13 +58,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
case NotifyCollectionChangedAction.Add:
|
case NotifyCollectionChangedAction.Add:
|
||||||
foreach (object o in args.NewItems)
|
foreach (object o in args.NewItems)
|
||||||
SelectionBlueprints.FirstOrDefault(b => b.Item == o)?.Select();
|
{
|
||||||
|
if (blueprintMap.TryGetValue((T)o, out var blueprint))
|
||||||
|
blueprint.Select();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
case NotifyCollectionChangedAction.Remove:
|
||||||
foreach (object o in args.OldItems)
|
foreach (object o in args.OldItems)
|
||||||
SelectionBlueprints.FirstOrDefault(b => b.Item == o)?.Deselect();
|
{
|
||||||
|
if (blueprintMap.TryGetValue((T)o, out var blueprint))
|
||||||
|
blueprint.Deselect();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -182,21 +182,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
var dragBox = (TimelineDragBox)DragBox;
|
var dragBox = (TimelineDragBox)DragBox;
|
||||||
double minTime = dragBox.MinTime;
|
double minTime = dragBox.MinTime;
|
||||||
double maxTime = dragBox.MaxTime;
|
double maxTime = dragBox.MaxTime;
|
||||||
Console.WriteLine($"{minTime}, {maxTime}");
|
|
||||||
|
|
||||||
// TODO: performance
|
SelectedItems.RemoveAll(hitObject => !shouldBeSelected(hitObject));
|
||||||
foreach (var hitObject in Beatmap.HitObjects)
|
SelectedItems.AddRange(Beatmap.HitObjects.Except(SelectedItems).Where(hitObject => shouldBeSelected(hitObject)));
|
||||||
{
|
|
||||||
bool shouldBeSelected = minTime <= hitObject.StartTime && hitObject.StartTime <= maxTime;
|
bool shouldBeSelected(HitObject hitObject) => minTime <= hitObject.StartTime && hitObject.StartTime <= maxTime;
|
||||||
bool isSelected = SelectedItems.Contains(hitObject);
|
|
||||||
if (isSelected != shouldBeSelected)
|
|
||||||
{
|
|
||||||
if (!isSelected)
|
|
||||||
SelectedItems.Add(hitObject);
|
|
||||||
else
|
|
||||||
SelectedItems.Remove(hitObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleScrollViaDrag(DragEvent e)
|
private void handleScrollViaDrag(DragEvent e)
|
||||||
|
Loading…
Reference in New Issue
Block a user