Skip to content

Commit

Permalink
Fix slider tails sometimes not dimming correctly
Browse files Browse the repository at this point in the history
Originally noticed during review of another change:
ppy#27369 (comment).

`DrawableOsuHitObject` tries to solve the initial dimming of objects
by applying transform to a list of dimmable parts. For plain drawables
this is safe, but if one of the parts is a DHO, it is not safe,
because drawable transforms can be cleared at will.

In particular, on first use of a drawable slider,
`UpdateInitialTransforms()` would fire via `LoadComplete()` on the
`DrawableSlider`, but *then*, also via `LoadComplete()`,
the `DrawableSliderTail` would update its own state and by doing so
inadvertently clear the dim transform just added by the slider.

To fix, ensure dim transforms are applied to DHOs
via `ApplyCustomUpdateState`.
  • Loading branch information
bdach committed Feb 27, 2024
1 parent 087a2a7 commit bbdd850
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
Expand Up @@ -80,6 +80,17 @@ protected override void UpdateInitialTransforms()
base.UpdateInitialTransforms();

foreach (var piece in DimmablePieces)
{
// if the specified dimmable piece is a DHO, it is generally not safe to tack transforms onto it directly
// as they may be cleared via the `updateState()` DHO flow,
// so use `ApplyCustomUpdateState` instead. which does not have this pitfall.
if (piece is DrawableHitObject drawableObjectPiece)
drawableObjectPiece.ApplyCustomUpdateState += (dho, _) => applyDim(dho);
else
applyDim(piece);
}

void applyDim(Drawable piece)
{
piece.FadeColour(new Color4(195, 195, 195, 255));
using (piece.BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW))
Expand Down

0 comments on commit bbdd850

Please sign in to comment.