1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Merge pull request #12650 from frenzibyte/selection-box-use-aabb

Compute selection box area using the bounding box of the blueprints instead
This commit is contained in:
Dean Herbert 2021-05-02 13:30:01 +09:00 committed by GitHub
commit a8db63498a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
@ -327,20 +328,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
return;
// Move the rectangle to cover the items
var topLeft = new Vector2(float.MaxValue, float.MaxValue);
var bottomRight = new Vector2(float.MinValue, float.MinValue);
RectangleF selectionRect = ToLocalSpace(selectedBlueprints[0].SelectionQuad).AABBFloat;
foreach (var blueprint in selectedBlueprints)
{
topLeft = Vector2.ComponentMin(topLeft, ToLocalSpace(blueprint.SelectionQuad.TopLeft));
bottomRight = Vector2.ComponentMax(bottomRight, ToLocalSpace(blueprint.SelectionQuad.BottomRight));
}
for (int i = 1; i < selectedBlueprints.Count; i++)
selectionRect = RectangleF.Union(selectionRect, ToLocalSpace(selectedBlueprints[i].SelectionQuad).AABBFloat);
topLeft -= new Vector2(5);
bottomRight += new Vector2(5);
selectionRect = selectionRect.Inflate(5f);
content.Size = bottomRight - topLeft;
content.Position = topLeft;
content.Position = selectionRect.Location;
content.Size = selectionRect.Size;
}
#endregion