Skip to content

Commit 149d527

Browse files
committed
AlphaMask now affects all of its descendants
1 parent 6c92ff6 commit 149d527

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/NitroSharp/Graphics/RenderItem.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,17 @@ public override bool IsIdle
264264
protected virtual (Vector2, Vector2) GetTexCoords(RenderContext ctx)
265265
=> (Vector2.Zero, Vector2.One);
266266

267+
protected AlphaMask? TryGetAlphaMaskAscendant()
268+
{
269+
Entity? current = Parent;
270+
while (current is not (AlphaMask or null))
271+
{
272+
current = current.Parent;
273+
}
274+
275+
return current as AlphaMask;
276+
}
277+
267278
protected override void AdvanceAnimations(RenderContext ctx, float dt, bool assetsReady)
268279
{
269280
base.AdvanceAnimations(ctx, dt, assetsReady);

src/NitroSharp/Graphics/RenderItems/Sprite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ protected override void Render(RenderContext ctx, DrawBatch drawBatch)
229229
{
230230
Texture alphaMaskTex = ctx.WhiteTexture;
231231
Vector2 alphaMaskPos = Vector2.Zero;
232-
if (Parent is AlphaMask alphaMask)
232+
if (TryGetAlphaMaskAscendant() is { } alphaMask)
233233
{
234234
alphaMaskTex = ctx.Content.Get(alphaMask.Texture);
235235
alphaMaskPos = alphaMask.Transform.Position.XY();

0 commit comments

Comments
 (0)