From d68cf09f7b8e5cb783dc495097c17eaf2a4d5427 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Mon, 31 Aug 2026 00:03:32 -0700 Subject: cleanup --- src/sim/lib/marching_squares.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/sim/lib') diff --git a/src/sim/lib/marching_squares.rs b/src/sim/lib/marching_squares.rs index ff48fd5..438b16c 100644 --- a/src/sim/lib/marching_squares.rs +++ b/src/sim/lib/marching_squares.rs @@ -43,15 +43,15 @@ fn derive_type(tl: bool, tr: bool, br: bool, bl: bool) -> usize { pub trait Marchable { fn occupied(&self, pos: IVec2) -> bool; - fn size(&self) -> IVec2; + fn marchable_size(&self) -> IVec2; } -pub fn compute_types(marchable: &impl Marchable, w: i32, h: i32) -> Vec { +pub fn compute_types(marchable: &impl Marchable) -> Vec { // TODO could pre-allocate size let mut types = Vec::new(); - for y in -1..h { + for y in -1..marchable.marchable_size().y { // TODO precompute per column - for x in -1..w { + for x in -1..marchable.marchable_size().x { let tl = marchable.occupied(IVec2::new(x, y)); let tr = marchable.occupied(IVec2::new(x + 1, y)); let br = marchable.occupied(IVec2::new(x + 1, y + 1)); @@ -133,11 +133,11 @@ fn toward_side(x: i32, y: i32, exit: Side) -> (i32, i32, Side) { // outer is cw, inner ccw pub fn marching_squares_vertex_trace(marchable: &impl Marchable) -> Vec> { - let [w, h] = marchable.size().to_array(); + let [w, h] = marchable.marchable_size().to_array(); let mut visited = vec![0u8; ((w + 1) * (h + 1)) as usize]; let idx = |cx: i32, cy: i32| (((cy + 1) * (w + 1)) + (cx + 1)) as usize; - let types = compute_types(marchable, w, h); + let types = compute_types(marchable); let mut polys = Vec::new(); for y in -1..h { -- cgit v1.3.1