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