mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 18:23:20 +08:00
Merge pull request #7968 from peppy/follow-point-performance
Improve gameplay performance via follow point renderer optimisations
This commit is contained in:
commit
ee5203f5bc
@ -20,6 +20,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
private const int spacing = 32;
|
private const int spacing = 32;
|
||||||
private const double preempt = 800;
|
private const double preempt = 800;
|
||||||
|
|
||||||
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The start time of <see cref="Start"/>.
|
/// The start time of <see cref="Start"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -79,27 +81,31 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
drawableObject.HitObject.DefaultsApplied += scheduleRefresh;
|
drawableObject.HitObject.DefaultsApplied += scheduleRefresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleRefresh() => Scheduler.AddOnce(refresh);
|
private void scheduleRefresh()
|
||||||
|
{
|
||||||
|
Scheduler.AddOnce(refresh);
|
||||||
|
}
|
||||||
|
|
||||||
private void refresh()
|
private void refresh()
|
||||||
{
|
{
|
||||||
ClearInternal();
|
ClearInternal();
|
||||||
|
|
||||||
if (End == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
OsuHitObject osuStart = Start.HitObject;
|
OsuHitObject osuStart = Start.HitObject;
|
||||||
OsuHitObject osuEnd = End.HitObject;
|
double startTime = osuStart.GetEndTime();
|
||||||
|
|
||||||
if (osuEnd.NewCombo)
|
LifetimeStart = startTime;
|
||||||
return;
|
|
||||||
|
|
||||||
if (osuStart is Spinner || osuEnd is Spinner)
|
OsuHitObject osuEnd = End?.HitObject;
|
||||||
|
|
||||||
|
if (osuEnd == null || osuEnd.NewCombo || osuStart is Spinner || osuEnd is Spinner)
|
||||||
|
{
|
||||||
|
// ensure we always set a lifetime for full LifetimeManagementContainer benefits
|
||||||
|
LifetimeEnd = LifetimeStart;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 startPosition = osuStart.EndPosition;
|
Vector2 startPosition = osuStart.EndPosition;
|
||||||
Vector2 endPosition = osuEnd.Position;
|
Vector2 endPosition = osuEnd.Position;
|
||||||
double startTime = osuStart.GetEndTime();
|
|
||||||
double endTime = osuEnd.StartTime;
|
double endTime = osuEnd.StartTime;
|
||||||
|
|
||||||
Vector2 distanceVector = endPosition - startPosition;
|
Vector2 distanceVector = endPosition - startPosition;
|
||||||
@ -107,6 +113,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
float rotation = (float)(Math.Atan2(distanceVector.Y, distanceVector.X) * (180 / Math.PI));
|
float rotation = (float)(Math.Atan2(distanceVector.Y, distanceVector.X) * (180 / Math.PI));
|
||||||
double duration = endTime - startTime;
|
double duration = endTime - startTime;
|
||||||
|
|
||||||
|
double? firstTransformStartTime = null;
|
||||||
|
double finalTransformEndTime = startTime;
|
||||||
|
|
||||||
for (int d = (int)(spacing * 1.5); d < distance - spacing; d += spacing)
|
for (int d = (int)(spacing * 1.5); d < distance - spacing; d += spacing)
|
||||||
{
|
{
|
||||||
float fraction = (float)d / distance;
|
float fraction = (float)d / distance;
|
||||||
@ -125,16 +134,23 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
Scale = new Vector2(1.5f * osuEnd.Scale),
|
Scale = new Vector2(1.5f * osuEnd.Scale),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (firstTransformStartTime == null)
|
||||||
|
firstTransformStartTime = fadeInTime;
|
||||||
|
|
||||||
using (fp.BeginAbsoluteSequence(fadeInTime))
|
using (fp.BeginAbsoluteSequence(fadeInTime))
|
||||||
{
|
{
|
||||||
fp.FadeIn(osuEnd.TimeFadeIn);
|
fp.FadeIn(osuEnd.TimeFadeIn);
|
||||||
fp.ScaleTo(osuEnd.Scale, osuEnd.TimeFadeIn, Easing.Out);
|
fp.ScaleTo(osuEnd.Scale, osuEnd.TimeFadeIn, Easing.Out);
|
||||||
fp.MoveTo(pointEndPosition, osuEnd.TimeFadeIn, Easing.Out);
|
fp.MoveTo(pointEndPosition, osuEnd.TimeFadeIn, Easing.Out);
|
||||||
fp.Delay(fadeOutTime - fadeInTime).FadeOut(osuEnd.TimeFadeIn);
|
fp.Delay(fadeOutTime - fadeInTime).FadeOut(osuEnd.TimeFadeIn);
|
||||||
}
|
|
||||||
|
|
||||||
fp.Expire(true);
|
finalTransformEndTime = fadeOutTime + osuEnd.TimeFadeIn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: use Expire() on FollowPoints and take lifetime from them when https://github.com/ppy/osu-framework/issues/3300 is fixed.
|
||||||
|
LifetimeStart = firstTransformStartTime ?? startTime;
|
||||||
|
LifetimeEnd = finalTransformEndTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Visualises connections between <see cref="DrawableOsuHitObject"/>s.
|
/// Visualises connections between <see cref="DrawableOsuHitObject"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FollowPointRenderer : CompositeDrawable
|
public class FollowPointRenderer : LifetimeManagementContainer
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All the <see cref="FollowPointConnection"/>s contained by this <see cref="FollowPointRenderer"/>.
|
/// All the <see cref="FollowPointConnection"/>s contained by this <see cref="FollowPointRenderer"/>.
|
||||||
@ -45,8 +45,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
/// <returns>The index of <paramref name="connection"/> in <see cref="connections"/>.</returns>
|
/// <returns>The index of <paramref name="connection"/> in <see cref="connections"/>.</returns>
|
||||||
private void addConnection(FollowPointConnection connection)
|
private void addConnection(FollowPointConnection connection)
|
||||||
{
|
{
|
||||||
AddInternal(connection);
|
|
||||||
|
|
||||||
// Groups are sorted by their start time when added such that the index can be used to post-process other surrounding connections
|
// Groups are sorted by their start time when added such that the index can be used to post-process other surrounding connections
|
||||||
int index = connections.AddInPlace(connection, Comparer<FollowPointConnection>.Create((g1, g2) => g1.StartTime.Value.CompareTo(g2.StartTime.Value)));
|
int index = connections.AddInPlace(connection, Comparer<FollowPointConnection>.Create((g1, g2) => g1.StartTime.Value.CompareTo(g2.StartTime.Value)));
|
||||||
|
|
||||||
@ -74,6 +72,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
|
|||||||
FollowPointConnection previousConnection = connections[index - 1];
|
FollowPointConnection previousConnection = connections[index - 1];
|
||||||
previousConnection.End = connection.Start;
|
previousConnection.End = connection.Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddInternal(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
MainContents.Size = new Vector2(Math.Min(100, Math.Min(DrawWidth, DrawHeight) * 0.25f));
|
MainContents.Size = new Vector2(Math.Clamp(Math.Min(DrawWidth, DrawHeight) * 0.25f, 30, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -93,7 +93,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private void rotate()
|
private void rotate()
|
||||||
{
|
{
|
||||||
spinner.Spin(spin_duration * 4, RotationDirection.Clockwise);
|
spinner.Spin(spin_duration * 3.5f, RotationDirection.Clockwise);
|
||||||
|
|
||||||
MainContents.RotateTo(0).Then()
|
MainContents.RotateTo(0).Then()
|
||||||
.RotateTo(90, spin_duration, Easing.InOutQuart).Then()
|
.RotateTo(90, spin_duration, Easing.InOutQuart).Then()
|
||||||
|
@ -15,7 +15,6 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -63,15 +62,9 @@ namespace osu.Game.Screens.Play
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
|
||||||
loading.Show();
|
loading.Show();
|
||||||
backgroundSprite.FadeColour(OsuColour.Gray(0.5f), 400, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
loading.Hide();
|
loading.Hide();
|
||||||
backgroundSprite.FadeColour(Color4.White, 400, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +131,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
},
|
},
|
||||||
loading = new LoadingSpinner { Scale = new Vector2(1.3f) }
|
loading = new LoadingLayer(backgroundSprite)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
|
Loading…
Reference in New Issue
Block a user