diff --git a/core/shared/core/timeline.h b/core/shared/core/timeline.h index c0cb411..0372b5a 100644 --- a/core/shared/core/timeline.h +++ b/core/shared/core/timeline.h @@ -13,7 +13,6 @@ class Timeline { public: explicit Timeline() : - _visibility_offset(0), _current_offset(0) {} @@ -22,8 +21,6 @@ public: void recalculate(const microsec& offset) { _current_offset = offset; - expire(_first_visible_note); - expire(_last_visible_note); expire(_top_note); if (!_timeline.empty()) @@ -49,21 +46,16 @@ public: if (isExpired(_top_note)) _top_note = _timeline.begin(); } - - fetchVisibleNotes(); } - void setNotes(const std::set& notes, const microsec& visibility) + void setNotes(const std::set& notes) { - _visibility_offset = visibility; _timeline = std::move(notes); recalculate(_current_offset); if (isExpired(_top_note)) return; - - fetchVisibleNotes(); } void insertNote(TNote* note) @@ -93,58 +85,6 @@ public: { _current_offset = offset; updateTopNote(_current_offset); - updateVisibleSprites(_current_offset); - } - - std::pair getVisibleNotes() const - { - if (nothingToDraw()) - return std::pair(); - - return std::make_pair(_first_visible_note, _last_visible_note); - } - - void fetchVisibleNotes() - { - findLastVisibleNote(_current_offset); - findFirstVisibleNote(); - } - - void findLastVisibleNote(const microsec& music_offset) - { - Iterator note_iterator = _top_note; - while (!isExpired(note_iterator) && isVisiblyClose(note_iterator, music_offset)) - { - if (nothingToDraw()) - _first_visible_note = note_iterator; - - auto note = *note_iterator; - - if (!note->isInGame()) - note->putToGame(music_offset); - - ++note_iterator; - } - - _last_visible_note = note_iterator; - } - - void findFirstVisibleNote() - { - if (nothingToDraw()) - return; - - auto note_iterator = _first_visible_note; - while (note_iterator != _last_visible_note) - { - auto note = *note_iterator; - if (note->shouldRemove()) - { - ++_first_visible_note; - } - - ++note_iterator; - } } Iterator getActiveNote(const microsec& music_offset) noexcept @@ -190,42 +130,18 @@ public: private: std::set _timeline; - microsec _visibility_offset; microsec _current_offset; inline void updateTopNote(const microsec& music_offset) noexcept { - if ((*_top_note)->offset() < music_offset // - && _top_note == _first_visible_note // Maybe simplify - && !(*_top_note)->isActive(music_offset)) // - { - ++_top_note; - } - } - - void updateVisibleSprites(const microsec& music_offset) - { - if (nothingToDraw()) - return; - - std::for_each(_first_visible_note, _last_visible_note, - [&music_offset](const auto& note) - { - note->update(music_offset); - }); - } + const auto& top_note = *_top_note; - inline bool isVisiblyClose(const Iterator& iterator, const microsec& music_offset) const noexcept - { - return ((*iterator)->offset() - _visibility_offset) <= music_offset; - } + bool already_played = top_note->offset() < music_offset + && !top_note->isActive(music_offset); - inline bool nothingToDraw() const noexcept - { - return isExpired(_first_visible_note); + if (already_played) + ++_top_note; } Iterator _top_note; - Iterator _last_visible_note; - Iterator _first_visible_note; }; diff --git a/modes/classicmode/editor/classiceditor.cpp b/modes/classicmode/editor/classiceditor.cpp index e139245..f027ac7 100644 --- a/modes/classicmode/editor/classiceditor.cpp +++ b/modes/classicmode/editor/classiceditor.cpp @@ -10,7 +10,9 @@ ClassicEditor::ClassicEditor(std::shared_ptr&& manager) std::set set = {}; - _timeline.setNotes(set, 1648648); + // VISIBILITY 1648648 + + _timeline.setNotes(set); } microsec ClassicEditor::adjustOffset(microsec offset) const noexcept @@ -62,19 +64,10 @@ void ClassicEditor::input(PlayerInput&& inputdata) void ClassicEditor::update(UpdateData&& updatedata) { _timeline.update(updatedata.timestamp); - _timeline.fetchVisibleNotes(); } void ClassicEditor::draw() const { - const auto& graphics_manager = _graphics_manager; - auto notes = _timeline.getVisibleNotes(); - - std::for_each(notes.first, notes.second, - [graphics_manager](const auto& note) - { - note->draw(); - }); } void ClassicEditor::recalculate(const microsec& timestamp) diff --git a/modes/classicmode/game/classicgame.cpp b/modes/classicmode/game/classicgame.cpp index e5637d5..56fdb26 100644 --- a/modes/classicmode/game/classicgame.cpp +++ b/modes/classicmode/game/classicgame.cpp @@ -60,7 +60,7 @@ void ClassicGame::run() _context.graphics_manager = _graphics_manager; auto beatmap = classic::createBeatmap("aa", _context); - _timeline.setNotes(beatmap.notes, beatmap.visibility_offset); + _timeline.setNotes(beatmap.notes); } void ClassicGame::input(PlayerInput&& inputdata) @@ -96,17 +96,8 @@ void ClassicGame::input(PlayerInput&& inputdata) void ClassicGame::update(UpdateData&& updatedata) { _timeline.update(updatedata.timestamp); - _timeline.fetchVisibleNotes(); } void ClassicGame::draw() const { - const auto& graphics_manager = _graphics_manager; - auto notes = _timeline.getVisibleNotes(); - - std::for_each(notes.first, notes.second, - [graphics_manager](const auto& note) - { - note->draw(); - }); }