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/chunk.rs | |
| parent | d577b97d4817762a1a77349ffbf08e4b7ce33902 (diff) | |
fix sleeping, disable sleeping
Diffstat (limited to 'src/sim/cell_manager/chunk.rs')
| -rw-r--r-- | src/sim/cell_manager/chunk.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/sim/cell_manager/chunk.rs b/src/sim/cell_manager/chunk.rs index 17e1551..48e9d16 100644 --- a/src/sim/cell_manager/chunk.rs +++ b/src/sim/cell_manager/chunk.rs @@ -1,7 +1,7 @@ use glam::IVec2; use crate::{ - config::{CELLS_IN_CHUNK, CHUNK_SIZE}, + config::{CELLS_IN_CHUNK, CHUNK_SIZE, SETTLED_THRESOHLD}, content::materials::{MaterialForm, MaterialId}, sim::{cell::Cell, lib::marching_squares::Marchable}, }; @@ -10,6 +10,7 @@ pub struct Chunk { pub cells: Box<[Cell; CELLS_IN_CHUNK]>, pub sleeping: bool, pub needs_texture_update: bool, + pub collider_dirty_seqno: Option<u64>, } impl Chunk { @@ -22,11 +23,18 @@ impl Chunk { self.cells[x as usize + y as usize * CHUNK_SIZE as usize] = cell; } + pub fn mark_collider_dirty(&mut self, seqno: u64) { + if self.collider_dirty_seqno.is_none() { + self.collider_dirty_seqno = Some(seqno); + } + } + pub fn void() -> Self { Chunk { cells: Box::new([Cell::void(); CELLS_IN_CHUNK]), sleeping: true, needs_texture_update: true, + collider_dirty_seqno: None, } } @@ -35,6 +43,7 @@ impl Chunk { cells: Box::new([Cell::void(); CELLS_IN_CHUNK]), sleeping: true, needs_texture_update: true, + collider_dirty_seqno: Some(0), }; for dy in 1..5 { @@ -60,7 +69,7 @@ impl Marchable for Chunk { let cell = self.get_cell_at_local_position(pos.x as u8, pos.y as u8); let material = cell.material.def(); material.form == MaterialForm::Solid - || material.form == MaterialForm::Powder && cell.settled() > 4 + || material.form == MaterialForm::Powder && cell.settled() >= SETTLED_THRESOHLD } } fn size(&self) -> IVec2 { |
