Implement proper masking support for taiko hit objects.

This commit is contained in:
smoogipooo
2017-04-12 12:03:51 +09:00
parent ca1fb81ff5
commit 4e2ae72126

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.Primitives;
using System.Linq;
using osu.Game.Modes.Taiko.Objects.Drawables;
using System;
using osu.Framework.Graphics.OpenGL;
namespace osu.Game.Modes.Taiko.UI
{
@ -111,9 +112,11 @@ namespace osu.Game.Modes.Taiko.UI
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
},
hitObjectContainer = new Container
hitObjectContainer = new ExternalMaskingRectangleContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
MaskingReference = () => this
},
judgementContainer = new Container<DrawableTaikoJudgement>
{
@ -269,5 +272,36 @@ namespace osu.Game.Modes.Taiko.UI
}
}
}
private class ExternalMaskingRectangleContainer : Container
{
public Func<Drawable> MaskingReference;
protected override void ApplyDrawNode(DrawNode node)
{
base.ApplyDrawNode(node);
Drawable maskingReference = MaskingReference?.Invoke();
if (MaskingReference == null)
return;
var cn = node as ContainerDrawNode;
cn.MaskingInfo = !Masking
? (MaskingInfo?)null
: new MaskingInfo
{
ScreenSpaceAABB = maskingReference.ScreenSpaceDrawQuad.AABB,
MaskingRect = maskingReference.DrawRectangle,
ToMaskingSpace = cn.MaskingInfo.Value.ToMaskingSpace,
CornerRadius = cn.MaskingInfo.Value.CornerRadius,
BorderThickness = cn.MaskingInfo.Value.BorderThickness,
BorderColour = cn.MaskingInfo.Value.BorderColour,
BlendRange = cn.MaskingInfo.Value.BlendRange,
AlphaExponent = cn.MaskingInfo.Value.AlphaExponent
};
}
}
}
}