Skip to content

Commit

Permalink
only consider hit objects which are visible in timeline for contracte…
Browse files Browse the repository at this point in the history
…d state
  • Loading branch information
OliBomby committed Oct 24, 2024
1 parent 22aef90 commit eb61da4
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ internal partial class TimelineBlueprintContainer : EditorBlueprintContainer
[Resolved(CanBeNull = true)]
private Timeline timeline { get; set; }

[Resolved(CanBeNull = true)]
private EditorClock editorClock { get; set; }

private Bindable<HitObject> placement;
private SelectionBlueprint<HitObject> placementBlueprint;

Expand Down Expand Up @@ -128,10 +131,11 @@ protected override void Update()

private void updateSamplePointContractedState()
{
// because only blueprints of objects which are alive (via pooling) are displayed in the timeline, it's feasible to do this every-update.

const double minimum_gap = 28;

if (timeline == null || editorClock == null)
return;

// Find the smallest time gap between any two sample point pieces
double smallestTimeGap = double.PositiveInfinity;
double lastTime = double.PositiveInfinity;
Expand All @@ -141,6 +145,14 @@ private void updateSamplePointContractedState()
{
var hitObject = selectionBlueprint.Item;

// Only check the hit objects which are visible in the timeline
// SelectionBlueprints can contain hit objects which are not visible in the timeline due to selection keeping them alive
if (hitObject.StartTime > editorClock.CurrentTime + timeline.VisibleRange / 2)
continue;

if (hitObject.GetEndTime() < editorClock.CurrentTime - timeline.VisibleRange / 2)
break;

if (hitObject is IHasRepeats hasRepeats)
smallestTimeGap = Math.Min(smallestTimeGap, hasRepeats.Duration / hasRepeats.SpanCount() / 2);

Expand Down

0 comments on commit eb61da4

Please sign in to comment.