From 21cee45cbb282c7acb24b574073421c4a9808aa5 Mon Sep 17 00:00:00 2001 From: lemz1 Date: Fri, 4 Oct 2024 22:04:26 +0200 Subject: [PATCH] Update NoteDataFilter.hx --- .../ui/debug/charting/util/NoteDataFilter.hx | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/source/funkin/ui/debug/charting/util/NoteDataFilter.hx b/source/funkin/ui/debug/charting/util/NoteDataFilter.hx index 5983e9133..80f6d668a 100644 --- a/source/funkin/ui/debug/charting/util/NoteDataFilter.hx +++ b/source/funkin/ui/debug/charting/util/NoteDataFilter.hx @@ -24,41 +24,44 @@ class NoteDataFilter for (note in notes) { - if (note == null) + // noticed a bug that displayedNoteData somehow can have duplicate notes + // thats why we need `chunks[chunks.length - 1].contains(note)` + if (note == null || chunks[chunks.length - 1].contains(note)) { continue; } - if (note.time >= chunkTime && note.time < chunkTime + CHUNK_INTERVAL_MS) + while (note.time >= chunkTime + CHUNK_INTERVAL_MS) { - chunks[chunks.length - 1].push(note); - } - else - { - chunks.push([]); chunkTime += CHUNK_INTERVAL_MS; + chunks.push([]); } + + chunks[chunks.length - 1].push(note); } for (chunk in chunks) { - for (i in 0...chunk.length - 1) + for (i in 0...(chunk.length - 1)) { - for (j in i...chunk.length) + for (j in (i + 1)...chunk.length) { var noteI:SongNoteData = chunk[i]; var noteJ:SongNoteData = chunk[j]; - if (Math.abs(noteJ.time - noteI.time) <= threshold) + if (noteI.getStrumlineIndex() == noteJ.getStrumlineIndex() && noteI.getDirection() == noteJ.getDirection()) { - if (!stackedNotes.contains(noteI)) + if (Math.abs(noteJ.time - noteI.time) <= threshold) { - stackedNotes.push(noteI); - } + if (!stackedNotes.contains(noteI)) + { + stackedNotes.push(noteI); + } - if (!stackedNotes.contains(noteJ)) - { - stackedNotes.push(noteJ); + if (!stackedNotes.contains(noteJ)) + { + stackedNotes.push(noteJ); + } } } }