Skip to content

Commit

Permalink
fix: Fix rendering bug (#50)
Browse files Browse the repository at this point in the history
* Fixed rendering bug
  • Loading branch information
Zac8668 authored Jan 10, 2024
1 parent ba5d885 commit 01598a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/chunk_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ pub fn chunk_manager_update(

// Spawn a task on the deferred scope for handling deferred dirty render rects.
deferred_scope.spawn(async move {
// Clear the previous render rects
*render_dirty_rects = HashMap::new();

//Update all rendering, used when debugging
/*
for x in 0..CHUNKS_WIDTH {
Expand Down Expand Up @@ -670,12 +667,17 @@ fn prepare_chunk_gpu_textures(
}
}

fn clear_render_rect(mut dirty_rects: ResMut<DirtyRects>) {
dirty_rects.render = HashMap::new();
}

pub struct ChunkManagerPlugin;
impl Plugin for ChunkManagerPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, manager_setup)
.add_systems(FixedUpdate, chunk_manager_update)
.add_systems(Update, update_manager_pos)
.add_systems(PreUpdate, clear_render_rect)
.init_resource::<ChunkManager>()
.init_resource::<DirtyRects>();

Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn main() {
ParticlesPlugin,
MaterialsPlugin,
))
.add_systems(Startup, setup_camera);
.add_systems(Startup, setup);

if args.contains(&"-d".to_string()) || args.contains(&"--debug".to_string()) {
app.add_plugins(DebugPlugin);
Expand All @@ -63,7 +63,9 @@ fn main() {
app.run();
}

fn setup_camera(mut commands: Commands) {
fn setup(mut commands: Commands, mut time: ResMut<Time<Fixed>>) {
time.set_timestep_hz(58.);

let mut camera = Camera2dBundle::default();
camera.camera.hdr = true;
camera.transform.scale.x = 0.23;
Expand Down

0 comments on commit 01598a5

Please sign in to comment.