diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-18 00:21:44 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-18 00:21:44 -0700 |
| commit | 4d4f28f4d0e93541e92277f44451aacdc23b8227 (patch) | |
| tree | 612b38036a4f79f1d50637a061cf2f636f5d1ded /src/sim/cell_sim | |
| parent | 4ad69d966f0640daae34c677eead5b689cbfac2e (diff) | |
MVP of marching squares
Diffstat (limited to 'src/sim/cell_sim')
| -rw-r--r-- | src/sim/cell_sim/chunk.rs | 15 | ||||
| -rw-r--r-- | src/sim/cell_sim/mod.rs | 1 | ||||
| -rw-r--r-- | src/sim/cell_sim/overlay.rs | 50 |
3 files changed, 14 insertions, 52 deletions
diff --git a/src/sim/cell_sim/chunk.rs b/src/sim/cell_sim/chunk.rs index 116a38a..8c3acb4 100644 --- a/src/sim/cell_sim/chunk.rs +++ b/src/sim/cell_sim/chunk.rs @@ -1,6 +1,9 @@ use crate::{ config::{CELLS_IN_CHUNK, CHUNK_SIZE}, - sim::cell::cell::Cell, + sim::{ + cell::{cell::Cell, materials::MaterialId}, + lib::marching_squares::Marchable, + }, }; pub struct Chunk { @@ -27,3 +30,13 @@ impl Chunk { } } } + +impl Marchable for Chunk { + fn occupied(&self, x: i32, y: i32) -> bool { + if x < 0 || x >= CHUNK_SIZE || y < 0 || y >= CHUNK_SIZE { + false + } else { + self.get_cell_at_local_position(x as u8, y as u8).material != MaterialId::Void + } + } +} diff --git a/src/sim/cell_sim/mod.rs b/src/sim/cell_sim/mod.rs index a1db2a1..b7d0597 100644 --- a/src/sim/cell_sim/mod.rs +++ b/src/sim/cell_sim/mod.rs @@ -1,4 +1,3 @@ pub mod chunk; -pub mod overlay; pub mod sim; pub mod world; diff --git a/src/sim/cell_sim/overlay.rs b/src/sim/cell_sim/overlay.rs deleted file mode 100644 index ee494ae..0000000 --- a/src/sim/cell_sim/overlay.rs +++ /dev/null @@ -1,50 +0,0 @@ -use crate::{Config, Input, sim::cell_sim::world::World}; - -pub fn create_compute_combined_overlay_offset( - world: &World, - config: &Config, - input: &Input, -) -> impl Fn(i32, i32) -> (u8, u8, u8, u8) { - puffin::profile_function!(); - // TODO fix this move? - move |pixel_x: i32, pixel_y: i32| { - // could allow negative offsets too - let mut offset: (u8, u8, u8, u8) = (0x00, 0x00, 0x00, 0x00); - - // // bounds - // // left - // let xl = -((board.get_game_width() / 2 + 1) as i32); - // // right - // let xu = (board.get_game_width() / 2 + 1) as i32; - // // bottom - // let yl = -((board.get_game_height() / 2 + 1) as i32); - // // top - // let yu = (board.get_game_height() / 2 + 1) as i32; - - // if ((pixel_x == xl || pixel_x == xu) && (pixel_y <= yu && pixel_y >= yl)) - // || (pixel_y == yl || pixel_y == yu) && (pixel_x <= xu && pixel_x >= xl) - // { - // offset.0 = offset.0.saturating_add(0xFF); - // offset.1 = offset.1.saturating_add(0xFF); - // offset.2 = offset.2.saturating_add(0xFF); - // } - - // // grid - // if pixel_x % 30 == 0 || pixel_y % 30 == 0 { - // offset.0 = offset.0.saturating_add(0x10); - // offset.1 = offset.1.saturating_add(0x10); - // offset.2 = offset.2.saturating_add(0x10); - // } - - // // brush/selection - // if input.last_mouse_pos_on_board.is_some_and(|p| { - // ((pixel_x - p.0).pow(2) + (pixel_y - p.1).pow(2)) < (config.brush_radius as i32).pow(2) - // }) { - // offset.0 = offset.0.saturating_add(0x82); - // offset.1 = offset.1.saturating_add(0xA1); - // offset.2 = offset.2.saturating_add(0xAD); - // } - - return offset; - } -} |
