clean map
This commit is contained in:
parent
9b4d9d74fc
commit
a181cbf7ad
23
src/map.rs
23
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;
|
||||
|
Loading…
Reference in New Issue
Block a user