1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Use combined area of children as a mask instead

This commit is contained in:
Andrei Zavatski 2023-05-31 01:23:42 +03:00
parent d119447a10
commit 949fe32740

View File

@ -50,6 +50,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private readonly Container colouredComponents;
private readonly OsuSpriteText comboIndexText;
private readonly SamplePointPiece samplePointPiece;
private readonly DifficultyPointPiece difficultyPointPiece = null!;
[Resolved]
private ISkinSource skin { get; set; } = null!;
@ -101,7 +103,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
},
}
},
new SamplePointPiece(Item)
samplePointPiece = new SamplePointPiece(Item)
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopCentre
@ -118,7 +120,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
if (item is IHasSliderVelocity)
{
AddInternal(new DifficultyPointPiece(Item)
AddInternal(difficultyPointPiece = new DifficultyPointPiece(Item)
{
Anchor = Anchor.TopLeft,
Origin = Anchor.BottomCentre
@ -244,7 +246,23 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
public override Vector2 ScreenSpaceSelectionPoint => ScreenSpaceDrawQuad.TopLeft;
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds)
{
// Since children are exceeding the component size, we need to use a custom quad to compute whether it should be masked away.
// When component isn't masked away there's no need to apply custom logic.
if (!base.ComputeIsMaskedAway(maskingBounds))
return false;
// If component is considered masked away we'll use children to create an extended quad.
var rect = RectangleF.Union(ScreenSpaceDrawQuad.AABBFloat, circle.ScreenSpaceDrawQuad.AABBFloat);
rect = RectangleF.Union(rect, samplePointPiece.ScreenSpaceDrawQuad.AABBFloat);
if (difficultyPointPiece != null)
rect = RectangleF.Union(rect, difficultyPointPiece.ScreenSpaceDrawQuad.AABBFloat);
return !Precision.AlmostIntersects(maskingBounds, rect);
}
private partial class Tick : Circle
{