Skip to content

Commit

Permalink
Reduce map rerender interval to once every 16 frames at 60 FPS (#56)
Browse files Browse the repository at this point in the history
This changes the map editor's duration for automatically rerendering the
map editor when not being interacted with, from once every 16
milliseconds to once every 16/60 seconds to reduce idle-time GPU usage.
  • Loading branch information
white-axe authored Oct 22, 2023
1 parent 8df8758 commit 48fbbc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/tilepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ impl Tilepicker {
self.ani_time = Some(time);
}

ui.ctx().request_repaint_after(Duration::from_millis(16));
ui.ctx()
.request_repaint_after(Duration::from_secs_f64(16. / 60.));

let (canvas_rect, response) = ui.allocate_exact_size(
egui::vec2(256., self.resources.tiles.atlas.tileset_height as f32 + 32.),
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Map {

painter
.ctx()
.request_repaint_after(Duration::from_millis(16));
.request_repaint_after(Duration::from_secs_f64(16. / 60.));

let resources = self.resources.clone();
let resource_id = Arc::new(OnceCell::new());
Expand Down

0 comments on commit 48fbbc8

Please sign in to comment.