diff --git a/engine/world_generation/src/lib.rs b/engine/world_generation/src/lib.rs index dc2fa4b..e2ee706 100644 --- a/engine/world_generation/src/lib.rs +++ b/engine/world_generation/src/lib.rs @@ -249,13 +249,13 @@ pub mod prelude { assert!(radius != 0, "Radius cannot be zero"); let width = self.width; - let mut chunks = self.hex_select_mut(pos, radius, true, |h, r| { + let mut chunks = self.hex_select_mut(pos, radius, true, |p, h, r| { let d = (r as f32) / (radius as f32); - let cur = h.clone(); + let cur = *h; let h2 = cur - depth; *h = h2.lerp(cur, d * d); - return pos.to_chunk_index(width); + return p.to_chunk_index(width); }); chunks.dedup(); @@ -263,21 +263,15 @@ pub mod prelude { return chunks; } - pub fn hex_select( - &mut self, - center: &HexCoord, - radius: usize, - include_center: bool, - op: OP, - ) -> Vec + pub fn hex_select(&self, center: &HexCoord, radius: usize, include_center: bool, op: OP) -> Vec where - OP: Fn(f32, usize) -> Ret + Sync + Send, + OP: Fn(&HexCoord, f32, usize) -> Ret + Sync + Send, { assert!(radius != 0, "Radius cannot be zero"); if include_center { - let h = self.sample_height(center); - (op)(h, 0); + let h = self.sample_height(¢er); + (op)(¢er, h, 0); } let mut result = Vec::with_capacity(get_tile_count(radius)); @@ -288,7 +282,7 @@ pub mod prelude { for _j in 0..k { p = p.get_neighbor(i); let h = self.sample_height(&p); - result.push((op)(h, k)); + result.push((op)(&p, h, k)); } } } @@ -304,13 +298,13 @@ pub mod prelude { op: OP, ) -> Vec where - OP: Fn(&mut f32, usize) -> Ret + Sync + Send, + OP: Fn(&HexCoord, &mut f32, usize) -> Ret + Sync + Send, { assert!(radius != 0, "Radius cannot be zero"); if include_center { - let h = self.sample_height_mut(center); - (op)(h, 0); + let h = self.sample_height_mut(¢er); + (op)(¢er, h, 0); } let mut result = Vec::with_capacity(get_tile_count(radius)); @@ -321,7 +315,7 @@ pub mod prelude { for _j in 0..k { p = p.get_neighbor(i); let h = self.sample_height_mut(&p); - result.push((op)(h, k)); + result.push((op)(&p, h, k)); } } } diff --git a/game/main/src/main.rs b/game/main/src/main.rs index e193a2e..1c4e35e 100644 --- a/game/main/src/main.rs +++ b/game/main/src/main.rs @@ -20,9 +20,9 @@ fn main() { primary_window: Some(Window { title: "Phos".into(), name: Some("phos".into()), - // resolution: (1920., 1080.).into(), + resolution: (1920., 1080.).into(), present_mode: PresentMode::AutoNoVsync, - mode: bevy::window::WindowMode::BorderlessFullscreen, + // mode: bevy::window::WindowMode::BorderlessFullscreen, ..default() }), ..default()