Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slow performance of polygon generation tool #30214

Merged
merged 13 commits into from
Nov 14, 2024
Prev Previous commit
Next Next commit
Make sure to properly update hitobjects
  • Loading branch information
minetoblend committed Oct 11, 2024
commit f76a2d02f61e522ae69eef5f1c3e8af0836bb42d
13 changes: 11 additions & 2 deletions osu.Game.Rulesets.Osu/Edit/PolygonGenerationPopover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ public partial class PolygonGenerationPopover : OsuPopover
[Resolved]
private HitObjectComposer composer { get; set; } = null!;

private Bindable<TernaryState> newComboState = null!;

[BackgroundDependencyLoader]
private void load()
{
var selectionHandler = (EditorSelectionHandler)composer.BlueprintContainer.SelectionHandler;
newComboState = selectionHandler.SelectionNewComboState.GetBoundCopy();

Child = new FillFlowContainer
{
Width = 220,
Expand Down Expand Up @@ -122,6 +127,7 @@ protected override void LoadComplete()
offsetAngleInput.Current.BindValueChanged(_ => Scheduler.AddOnce(tryCreatePolygon));
repeatCountInput.Current.BindValueChanged(_ => Scheduler.AddOnce(tryCreatePolygon));
pointInput.Current.BindValueChanged(_ => Scheduler.AddOnce(tryCreatePolygon));
newComboState.BindValueChanged(_ => Scheduler.AddOnce(tryCreatePolygon));
tryCreatePolygon();
}

Expand All @@ -144,7 +150,6 @@ private void tryCreatePolygon()
insertedCircles.RemoveRange(totalPoints, insertedCircles.Count - totalPoints);
}

var selectionHandler = (EditorSelectionHandler)composer.BlueprintContainer.SelectionHandler;
bool first = true;

var newlyAdded = new List<HitCircle>();
Expand All @@ -162,7 +167,7 @@ private void tryCreatePolygon()

circle.Position = position;
circle.StartTime = startTime;
circle.NewCombo = first && selectionHandler.SelectionNewComboState.Value == TernaryState.True;
circle.NewCombo = first && newComboState.Value == TernaryState.True;

if (position.X < 0 || position.Y < 0 || position.X > OsuPlayfield.BASE_SIZE.X || position.Y > OsuPlayfield.BASE_SIZE.Y)
{
Expand All @@ -179,6 +184,10 @@ private void tryCreatePolygon()
// TODO: probably ensure samples also follow current ternary status (not trivial)
circle.Samples.Add(circle.CreateHitSampleInfo());
}
else
{
editorBeatmap.Update(circle);
}

startTime = beatSnapProvider.SnapTime(startTime + timeSpacing);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ private void createStateBindables()
/// </summary>
protected virtual void UpdateTernaryStates()
{
SelectionNewComboState.Value = GetStateFromSelection(SelectedItems.OfType<IHasComboInformation>(), h => h.NewCombo);
if (SelectedItems.Any())
SelectionNewComboState.Value = GetStateFromSelection(SelectedItems.OfType<IHasComboInformation>(), h => h.NewCombo);
Comment on lines +274 to +275
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that I proposed this originally but now I see that it's not correct in all instances. This change means that if you select an object that starts a combo, the new combo toggle will enable. Worse yet, if you select a combination of new-combo and non-new-combo objects, the toggle will enter indeterminate state and not even deselection will get rid of that state.

Not sure what the solution here is. Maybe the interaction of this popover with the new combo toggle should be removed completely. @peppy maybe you will have a UX opinion on this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdach correct me if i'm wrong, but it seems the only change here is that the check for selected items has been added. so the fail case would be that "new combo" may not be reset when the selection is empty?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - in the worst case it will stay in indeterminate state after selecting and deselecting a group of objects with mixed new combo state.

Copy link
Member

@peppy peppy Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay. The next toggle fixes the indeterminate state anyways (and in this state it will seemingly default to placement without new combo, which makes sense to me).

That said, @bdach if you're not happy with this interaction then I'd propose making the generate dialog not set new combo at all, and leave that up to the user to fix as a post operation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just made an alternative change to just revert the indeterminate state to full false on deselect (88aea70). Should hopefully be uncontroversial.

My only bother has ever been it visually looking like in the "indeterminate" state after a deselect, nothing more.


var samplesInSelection = SelectedItems.SelectMany(enumerateAllSamples).ToArray();

Expand Down