/// Called when a render event occurs
Called when a render event occurs
Called when a render event occurs
pub fn render(
        &mut self,
        c: Context,
        g: &mut G,
        args: &RenderArgs,
        config: &Config,
        chart: &dyn chart::Chart,
        model: &Model,
        time: f64,
    ) {
        graphics::clear([0.0, 0.0, 0.0, 1.0], g);
        // manage self.current_timing_point_index
        //
        // from the future: this is bugged, the calc_pos function needs the most recent bpm change
        // timing point as well as the most recent sv timing point, this code only gives the most
        // recent timing point, whichever it is, which is wrong.
        //
        // TODO fix (we only need to check the timing points between current_timing_point_index
        // and the current time and take the minimum of the most recent bpm change and sv change
        //
        // while chart.timing_points()
        //     .get(self.current_timing_point_index + 2)
        //     .filter(|tp| time > tp.offset)
        //     .is_some()
        // {
        //     self.current_timing_point_index += 1;
        // }
        let mut add_next_note_index = 0;
        for (index, note) in chart.notes()[self.next_note_index..].iter().enumerate() {
            let note_pos = calc_pos(
                time,
                note.time,
                chart,
                config.game.scroll_speed,
                self.current_timing_point_index,
            );
            if note_pos > 1.0 {
                break;
            }
            self.notes_on_screen_indices
                .push(index + self.next_note_index);
            add_next_note_index += 1;
        }
        self.next_note_index += add_next_note_index;
        for (index, &note_index) in self.notes_on_screen_indices.iter().enumerate() {
            let note = &chart.notes()[note_index];
            if let Some(end_time) = note.end_time {
                if note.time - time < 0.0 && !self.long_notes_held[note.column] {
                    self.long_notes_held[note.column] = true;
                } else if end_time - time < 0.0 {
                    self.notes_below_screen_indices.push(index);
                    self.long_notes_held[note.column] = false;
                    continue;
                }
            } else if note.time - time < 0.0 {
                self.notes_below_screen_indices.push(index);
                continue;
            }
        }
        for &index in self.notes_below_screen_indices.iter().rev() {
            self.notes_on_screen_indices.swap_remove(index);
        }
        self.notes_below_screen_indices.clear();
        self.notes_pos.clear();
        let current_timing_point_index = self.current_timing_point_index; // rust pls fix closures
        self.notes_pos
            .extend(self.notes_on_screen_indices.iter().map(|&i| {
                let note = &chart.notes()[i];
                let pos = calc_pos(
                    time,
                    note.time,
                    chart,
                    config.game.scroll_speed,
                    current_timing_point_index,
                );
                let end_pos = note.end_time.map(|t| {
                    calc_pos(
                        time,
                        t,
                        chart,
                        config.game.scroll_speed,
                        current_timing_point_index,
                    )
                });
                (note.column, pos, end_pos)
            }));
        self.skin.draw_play_scene(
            c.transform,
            g,
            args.window_size[1],
            &model.keys_down,
            &*self.notes_pos,
        );
    }
pub fn render ( & mut self , c : Context , g : & mut G , args : & RenderArgs , config : & Config , chart : & dyn chart :: Chart , model : & Model , time : f64 , ) { graphics :: clear ( [ 0.0 , 0.0 , 0.0 , 1.0 ] , g ) ; // manage self.current_timing_point_index // // from the future: this is bugged, the calc_pos function needs the most recent bpm change // timing point as well as the most recent sv timing point, this code only gives the most // recent timing point, whichever it is, which is wrong. // // TODO fix (we only need to check the timing points between current_timing_point_index // and the current time and take the minimum of the most recent bpm change and sv change // // while chart.timing_points() //     .get(self.current_timing_point_index + 2) //     .filter(|tp| time > tp.offset) //     .is_some() // { //     self.current_timing_point_index += 1; // } let mut add_next_note_index = 0 ; for ( index , note ) in chart . notes ( ) [ self . next_note_index .. ] . iter ( ) . enumerate ( ) { let note_pos = calc_pos ( time , note . time , chart , config . game . scroll_speed , self . current_timing_point_index , ) ; if note_pos > 1.0 { break ; } self . notes_on_screen_indices . push ( index + self . next_note_index ) ; add_next_note_index += 1 ; } self . next_note_index += add_next_note_index ; for ( index , & note_index ) in self . notes_on_screen_indices . iter ( ) . enumerate ( ) { let note = & chart . notes ( ) [ note_index ] ; if let Some ( end_time ) = note . end_time { if note . time - time < 0.0 && ! self . long_notes_held [ note . column ] { self . long_notes_held [ note . column ] = true ; } else if end_time - time < 0.0 { self . notes_below_screen_indices . push ( index ) ; self . long_notes_held [ note . column ] = false ; continue ; } } else if note . time - time < 0.0 { self . notes_below_screen_indices . push ( index ) ; continue ; } } for & index in self . notes_below_screen_indices . iter ( ) . rev ( ) { self . notes_on_screen_indices . swap_remove ( index ) ; } self . notes_below_screen_indices . clear ( ) ; self . notes_pos . clear ( ) ; let current_timing_point_index = self . current_timing_point_index ; // rust pls fix closures self . notes_pos . extend ( self . notes_on_screen_indices . iter ( ) . map ( | & i | { let note = & chart . notes ( ) [ i ] ; let pos = calc_pos ( time , note . time , chart , config . game . scroll_speed , current_timing_point_index , ) ; let end_pos = note . end_time . map ( | t | { calc_pos ( time , t , chart , config . game . scroll_speed , current_timing_point_index , ) } ) ; ( note . column , pos , end_pos ) } ) ) ; self . skin . draw_play_scene ( c . transform , g , args . window_size [ 1 ] , & model . keys_down , & * self . notes_pos , ) ; }
Called when a render event occurs
Called when a render event occurs
&mut self
c
Context
g
&mut G
args
&RenderArgs
config
&Config
chart
&dyn chart::Chart
model
&Model
time
f64