Make renderer update more useful

This commit is contained in:
Jarrod Doyle 2024-04-06 09:40:37 +01:00
parent 8a4909dced
commit 96fe40108b
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
3 changed files with 11 additions and 9 deletions

View File

@ -109,8 +109,7 @@ impl<'window> App<'window> {
// !Hack: As far as I know I can't propagate errors out of here. So for now just ignore them
let _ = renderer.render(&self.render_ctx);
let _ = renderer.update(&dt, &self.render_ctx);
renderer.update_brickmap(&self.render_ctx, &mut world);
let _ = renderer.update(&dt, &self.render_ctx, &mut world);
// Simple framerate tracking
self.render_ctx.window.set_title(&format!(

View File

@ -185,11 +185,6 @@ impl BrickmapRenderer {
unpack_bind_group,
})
}
pub fn update_brickmap(&mut self, context: &gfx::Context, world: &mut WorldManager) {
self.brickmap_manager
.process_feedback_buffer(context, world);
}
}
impl VoxelRenderer for BrickmapRenderer {
@ -249,7 +244,14 @@ impl VoxelRenderer for BrickmapRenderer {
Ok(())
}
fn update(&mut self, _dt: &Duration, _context: &gfx::Context) -> Result<()> {
fn update(
&mut self,
_dt: &Duration,
context: &gfx::Context,
world: &mut WorldManager,
) -> Result<()> {
self.brickmap_manager
.process_feedback_buffer(context, world);
Ok(())
}
}

View File

@ -2,9 +2,10 @@ use std::time::Duration;
use anyhow::Result;
use super::world::WorldManager;
use crate::gfx::Context;
pub trait VoxelRenderer {
fn update(&mut self, dt: &Duration, context: &Context) -> Result<()>;
fn update(&mut self, dt: &Duration, context: &Context, world: &mut WorldManager) -> Result<()>;
fn render(&self, context: &Context) -> Result<()>;
}