Repository navigation
perf(keys_highway_3d): window updateScene to the visible note span - #141
Merged
Merged
Conversation
updateScene walked every note mesh twice per frame (camera framing, positions/labels/key glow) plus every bar-number sprite, so its cost grew with the length of the chart however little of it was on screen. Both t-sorted arrays are now windowed to the drawable span via advanceTWindow: entries that fall out are parked hidden exactly once, and the loops walk only [lo, hi). Bounds derive from the runway geometry and the chart's longest note (shared NOTE_LINGER / MARKER_LINGER constants with the in-loop hides), so nothing drawable is skipped.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 27 |
| Duplication | 2 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Overview
Files Reviewed (4 files)
Reviewed by free · Input: 755.1K · Output: 38.1K · Cached: 587.3K |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #95.
What
updateScene()ran three full-array passes every frame: camera pan/zoom framing over every note mesh, the positions/labels/key-glow pass over every note mesh again, and the floating bar numbers over every marker sprite. Per-frame cost therefore grew with the chart's total length no matter how little of it was on screen.Both t-sorted arrays are now windowed to the span that can actually be drawn:
scrollZ):noteWindowAheadS(highwayLen, hitZ)(front edge reaches the runway's far end),noteWindowBehindS(maxNoteLen)(max of the note-consumption exit and the label fade),MARKER_WIN_BEHIND_S,_tBound, andadvanceTWindow— a per-frame lower-bound search over[now - behind, now + ahead]that callsonHideonly for runs that just fell out of the previous window (fresh/rebuiltlo = -1hides nothing).updateSceneadvances both windows once, then the camera loop, note loop, and marker loop each walkfor (let i = win.lo; i < win.hi; i++)with their original bodies and per-entry geometry checks unchanged (kept: they remain exact for markers, conservative for notes between the shared bound and each note's own exit)._hideNoteWindow/_hideMarkerWindow); re-entering entries (backward seek) are fully re-derived on their first processed frame.buildNoteMeshes,buildMarkerSprites, andteardownalongside the array reassignments; markers are now explicitly t-sorted at build (windowing binary-searches them).NOTE_LINGER/MARKER_LINGER) so they can't drift apart.Bounds at stock geometry are ≈ [-0.62 s, +8.67 s], which contains every span
updateScenefilters on inside the window (camera band[-0.4, CAM_ZOOM_AHEAD], key glow[-0.05, KEY_GLOW_AHEAD]) — so framing, glow, labels, consumption, and miss-sweep behaviour are unchanged; only the iteration is bounded. No new per-frame allocations (binary search + stable keyOf/hide callbacks).Tests
data_layer.test.js: window-bound geometry tied back toscrollZ(the ahead bound is exactly the front-edge/runway crossing), behind-bound covers longest-note consumption and the label fade (with a tightness bound so it can't grow beyond the longest note + label), monotonicity, and theadvanceTWindowstate machine (fresh-window/no-hide, steady advance delta-hide, forward-seek vs rewind, same-onset chord runs as one run, marker keyOf, empty arrays).instance_invariants.test.js: source-scan pins theupdateScenewiring — bothadvanceTWindowcalls with correct behind-minus/ahead-plus pairing, windowedforloops, no remaining full-arrayofloops — and that all four array reassignments reset their window beside them (the pure helpers alone can't catch them being exported and never wired up).node --test(full CI-equivalent JS suite): 1449/1449 pass.npx eslint: 0 errors (pre-existingmax-lineswarning only).Out of scope
Per-note label sprite/material memory (the issue's second bullet) — unchanged here; this PR is the windowing fix the issue's suggested approach describes.
Self-review via reviewfrog: no blockers; its three findings (shared linger constants, band-containment pin, reset-adjacency pin) are addressed in this diff.
big-pickle(free) | 𝕏