diff --git a/src/map.rs b/src/map.rs index ed38006..581d837 100644 --- a/src/map.rs +++ b/src/map.rs @@ -35,12 +35,12 @@ impl bevy::prelude::Plugin for Plugin { } } -pub const HEIGHT: f32 = 2.; -pub const WIDTH: f32 = 2.; -pub const REAL_HEIGHT: f32 = 2000.; -pub const REAL_WIDTH: f32 = 2000.; +pub const HEIGHT: f32 = 16.; +pub const WIDTH: f32 = 16.; +pub const REAL_HEIGHT: f32 = 8000.; +pub const REAL_WIDTH: f32 = 8000.; pub const CELL_AREA: f32 = REAL_HEIGHT * REAL_WIDTH / SIZE as f32; -pub const SIZE: usize = 10000; +pub const SIZE: usize = 100_000; #[derive(Resource)] struct Seed(u32); @@ -119,6 +119,14 @@ fn setup( cells[i].vertices.push(i); } for t in voronoi.triangulation().triangles.chunks_exact(3) { + let on_hull = t + .iter() + .filter(|v| voronoi.triangulation().hull.contains(v)) + .count(); + // Don't draw triangles on the hull that are often long and look glitchy + if on_hull > 0 { + continue; + } indices.extend_from_slice(&[t[2] as u32, t[1] as u32, t[0] as u32]); } // indices.extend(voronoi.triangulation().triangles.iter().map(|t| *t as u32)); @@ -158,9 +166,6 @@ fn setup( .with_inserted_indices(Indices::U32(indices)); mesh.compute_smooth_normals(); - mesh.generate_tangents(); - // mesh.duplicate_vertices(); - // mesh.compute_flat_normals(); let mut cells_entities = Vec::with_capacity(cells.len()); @@ -210,7 +215,9 @@ fn update_map_mesh( if needs_update.0 { if let Some(mesh) = meshes.get_mut(mesh) { let mut modified = false; + // let mut rng = thread_rng(); for (cell, wealth) in cells.iter() { + // let col: [f32; 4] = [rng.gen(), rng.gen(), rng.gen(), 1.]; let col = cell.color(wealth.map(|w| w.0).unwrap_or_default()); for id in cell.vertices.iter() { modified = modified || cols.0[*id] != col; diff --git a/src/ui.rs b/src/ui.rs index 62d4f02..8ee6e5d 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -202,7 +202,6 @@ fn zoom_with_scroll( let window = window.single(); let mut cam = cam.single_mut(); for ev in ev_scroll.read() { - dbg!(ev.y); let forward = cam.forward(); cam.translation += forward * (ev.y * 0.1); // cam.fov = cam.fov + (ev.y * 0.1);