diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-29 14:12:01 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-29 14:12:01 -0700 |
| commit | d7d17f777987047999d09d196417d3f8e8241ba5 (patch) | |
| tree | 8241ef82c7b5591d33a029e1f4b2c0ae9397a840 /src/sim/cell_manager/sim.rs | |
| parent | d577b97d4817762a1a77349ffbf08e4b7ce33902 (diff) | |
fix sleeping, disable sleeping
Diffstat (limited to 'src/sim/cell_manager/sim.rs')
| -rw-r--r-- | src/sim/cell_manager/sim.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sim/cell_manager/sim.rs b/src/sim/cell_manager/sim.rs index ffa253b..6b3a0de 100644 --- a/src/sim/cell_manager/sim.rs +++ b/src/sim/cell_manager/sim.rs @@ -128,7 +128,7 @@ fn adjacent_chunks(x: u8, y: u8) -> Vec<usize> { } } -fn internal_set_cell(chunks: &mut [Option<&mut Chunk>; 9], x: i32, y: i32, cell: Cell) { +fn internal_set_cell(chunks: &mut [Option<&mut Chunk>; 9], x: i32, y: i32, cell: Cell, seqno: u64) { let cx = x.div_euclid(CHUNK_SIZE); let cy = y.div_euclid(CHUNK_SIZE); let lx = x.rem_euclid(CHUNK_SIZE) as u8; @@ -139,10 +139,12 @@ fn internal_set_cell(chunks: &mut [Option<&mut Chunk>; 9], x: i32, y: i32, cell: chunk.set_cell_at_local_position(lx, ly, cell); chunk.needs_texture_update = true; chunk.sleeping = false; + chunk.mark_collider_dirty(seqno); // if we're at the boundaries of the chunk, wake the adjacent chunk(s) for idx in adjacent_chunks(lx, ly) { if let Some(chunk) = chunks[idx].as_mut() { chunk.sleeping = false; + chunk.mark_collider_dirty(seqno); } } } @@ -151,10 +153,12 @@ fn internal_set_cell(chunks: &mut [Option<&mut Chunk>; 9], x: i32, y: i32, cell: target.set_cell_at_local_position(x as u8, y as u8, cell); target.needs_texture_update = true; target.sleeping = false; + target.mark_collider_dirty(seqno); // if we're at the boundaries of the chunk, wake the adjacent chunk(s) for idx in adjacent_chunks(lx, ly) { if let Some(chunk) = chunks[idx].as_mut() { chunk.sleeping = false; + chunk.mark_collider_dirty(seqno); } } } @@ -200,7 +204,7 @@ impl UpdateCtx<'_, '_, '_> { debug_assert!(dy > -CHUNK_SIZE + 1 && dy < CHUNK_SIZE - 1); let x = self.x + dx; let y = self.y + dy; - internal_set_cell(self.chunks, x, y, cell); + internal_set_cell(self.chunks, x, y, cell, self.seqno); } pub fn swap_or_settle(&mut self, candidates: &[(i32, i32)]) -> PostUpdateAction { @@ -267,12 +271,12 @@ fn sim_tick_chunk(chunks: &mut [Option<&mut Chunk>; 9], seqno: u64) { if cell.settled() < SETTLED_THRESOHLD { cell.match_parity(seqno + 1); cell.increment_settled(); - internal_set_cell(chunks, x, y, cell); + internal_set_cell(chunks, x, y, cell, seqno); } } PostUpdateAction::Apply => { cell.match_parity(seqno + 1); - internal_set_cell(chunks, x, y, cell); + internal_set_cell(chunks, x, y, cell, seqno); } } } |
