mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Only recalculate when display actually changes
This commit is contained in:
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Caching;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -32,6 +33,16 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly Cached tickCache = new Cached();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
beatDivisor.BindValueChanged(_ => tickCache.Invalidate());
|
||||||
|
}
|
||||||
|
|
||||||
|
private (float min, float max) visibleRange = (float.MinValue, float.MaxValue);
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private Timeline timeline { get; set; }
|
private Timeline timeline { get; set; }
|
||||||
|
|
||||||
@ -39,17 +50,26 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
int drawableIndex = 0;
|
|
||||||
|
|
||||||
double minVisibleTime = double.MinValue;
|
|
||||||
double maxVisibleTime = double.MaxValue;
|
|
||||||
|
|
||||||
if (timeline != null)
|
if (timeline != null)
|
||||||
{
|
{
|
||||||
minVisibleTime = ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopLeft).X / DrawWidth * Content.RelativeChildSize.X;
|
var newRange = (
|
||||||
maxVisibleTime = ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopRight).X / DrawWidth * Content.RelativeChildSize.X;
|
ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopLeft).X / DrawWidth * Content.RelativeChildSize.X,
|
||||||
|
ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopRight).X / DrawWidth * Content.RelativeChildSize.X);
|
||||||
|
|
||||||
|
if (visibleRange != newRange)
|
||||||
|
tickCache.Invalidate();
|
||||||
|
|
||||||
|
visibleRange = newRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tickCache.IsValid)
|
||||||
|
createTicks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTicks()
|
||||||
|
{
|
||||||
|
int drawableIndex = 0;
|
||||||
|
|
||||||
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
|
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
|
||||||
{
|
{
|
||||||
var point = beatmap.ControlPointInfo.TimingPoints[i];
|
var point = beatmap.ControlPointInfo.TimingPoints[i];
|
||||||
@ -59,7 +79,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
for (double t = point.Time; t < until; t += point.BeatLength / beatDivisor.Value)
|
for (double t = point.Time; t < until; t += point.BeatLength / beatDivisor.Value)
|
||||||
{
|
{
|
||||||
if (t >= minVisibleTime && t <= maxVisibleTime)
|
if (t >= visibleRange.min && t <= visibleRange.max)
|
||||||
{
|
{
|
||||||
var indexInBeat = beat % beatDivisor.Value;
|
var indexInBeat = beat % beatDivisor.Value;
|
||||||
|
|
||||||
@ -109,6 +129,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
while (drawableIndex < Count)
|
while (drawableIndex < Count)
|
||||||
Children[drawableIndex++].Expire();
|
Children[drawableIndex++].Expire();
|
||||||
|
|
||||||
|
tickCache.Validate();
|
||||||
|
|
||||||
Drawable getNextUsablePoint()
|
Drawable getNextUsablePoint()
|
||||||
{
|
{
|
||||||
PointVisualisation point;
|
PointVisualisation point;
|
||||||
|
Reference in New Issue
Block a user