1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Lock smoke bounds to playfield

This commit is contained in:
Alden Wu 2022-09-20 12:03:07 -07:00
parent ddbd69dc67
commit 092e6cfa1d

View File

@ -39,36 +39,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
protected double SmokeEndTime { get; private set; } = double.MaxValue;
private Vector2 topLeft;
protected Vector2 TopLeft
{
get => topLeft;
set
{
if (topLeft == value)
return;
topLeft = value;
Invalidate(Invalidation.Layout);
}
}
private Vector2 bottomRight;
protected Vector2 BottomRight
{
get => bottomRight;
set
{
if (bottomRight == value)
return;
bottomRight = value;
Invalidate(Invalidation.Layout);
}
}
protected virtual float PointInterval => Radius * 7f / 8;
protected bool IsActive { get; private set; }
@ -79,24 +49,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
private const int max_point_count = 18_000;
public override float Height
{
get => base.Height = BottomRight.Y - TopLeft.Y;
set => throw new InvalidOperationException($"Cannot manually set {nameof(Height)} of {nameof(Smoke)}.");
}
public override float Width
{
get => base.Width = BottomRight.X - TopLeft.X;
set => throw new InvalidOperationException($"Cannot manually set {nameof(Width)} of {nameof(Smoke)}.");
}
public override Vector2 Size
{
get => base.Size = BottomRight - TopLeft;
set => throw new InvalidOperationException($"Cannot manually set {nameof(Size)} of {nameof(Smoke)}.");
}
[Resolved(CanBeNull = true)]
private SmokeContainer? smokeContainer { get; set; }
@ -111,8 +63,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
{
base.LoadComplete();
Anchor = Anchor.TopLeft;
Origin = Anchor.TopLeft;
RelativeSizeAxes = Axes.Both;
SmokeStartTime = Time.Current;
@ -157,7 +108,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
{
int index = ~SmokePoints.BinarySearch(new SmokePoint { Time = time }, new SmokePoint.UpperBoundComparer());
SmokePoints.RemoveRange(index, SmokePoints.Count - index);
recalculateBounds();
}
totalDistance %= PointInterval;
@ -175,7 +125,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
}
Invalidate(Invalidation.DrawNode);
adaptBounds(position);
}
lastPosition = position;
@ -184,27 +133,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
onSmokeEnded(time);
}
private void recalculateBounds()
{
TopLeft = BottomRight = Vector2.Zero;
foreach (var point in SmokePoints)
adaptBounds(point.Position);
}
private void adaptBounds(Vector2 position)
{
if (position.X < TopLeft.X)
TopLeft = new Vector2(position.X, TopLeft.Y);
else if (position.X > BottomRight.X)
BottomRight = new Vector2(position.X, BottomRight.Y);
if (position.Y < TopLeft.Y)
TopLeft = new Vector2(TopLeft.X, position.Y);
else if (position.Y > BottomRight.Y)
BottomRight = new Vector2(BottomRight.X, position.Y);
}
public abstract override double LifetimeEnd { get; }
private void onSmokeEnded(double time)
@ -222,8 +150,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
{
base.Update();
Position = TopLeft;
Invalidate(Invalidation.DrawNode);
}
@ -270,7 +196,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
private IVertexBatch<TexturedVertex2D>? quadBatch;
private float radius;
private Vector2 drawSize;
private Vector2 positionOffset;
private Texture? texture;
protected SmokeDrawNode(ITexturedShaderDrawable source)
@ -287,7 +212,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
radius = Source.Radius;
drawSize = Source.DrawSize;
positionOffset = Source.TopLeft;
texture = Source.Texture;
SmokeStartTime = Source.SmokeStartTime;
@ -343,10 +267,10 @@ namespace osu.Game.Rulesets.Osu.Skinning
if (colour.A == 0 || scale == 0)
return;
var localTopLeft = point.Position + (radius * scale * (-ortho - dir)) - positionOffset;
var localTopRight = point.Position + (radius * scale * (-ortho + dir)) - positionOffset;
var localBotLeft = point.Position + (radius * scale * (ortho - dir)) - positionOffset;
var localBotRight = point.Position + (radius * scale * (ortho + dir)) - positionOffset;
var localTopLeft = point.Position + (radius * scale * (-ortho - dir));
var localTopRight = point.Position + (radius * scale * (-ortho + dir));
var localBotLeft = point.Position + (radius * scale * (ortho - dir));
var localBotRight = point.Position + (radius * scale * (ortho + dir));
quadBatch.Add(new TexturedVertex2D
{