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 HEIGHT: f32 = 16.;
|
||||||
pub const WIDTH: f32 = 2.;
|
pub const WIDTH: f32 = 16.;
|
||||||
pub const REAL_HEIGHT: f32 = 2000.;
|
pub const REAL_HEIGHT: f32 = 8000.;
|
||||||
pub const REAL_WIDTH: f32 = 2000.;
|
pub const REAL_WIDTH: f32 = 8000.;
|
||||||
pub const CELL_AREA: f32 = REAL_HEIGHT * REAL_WIDTH / SIZE as f32;
|
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)]
|
#[derive(Resource)]
|
||||||
struct Seed(u32);
|
struct Seed(u32);
|
||||||
@ -119,6 +119,14 @@ fn setup(
|
|||||||
cells[i].vertices.push(i);
|
cells[i].vertices.push(i);
|
||||||
}
|
}
|
||||||
for t in voronoi.triangulation().triangles.chunks_exact(3) {
|
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_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));
|
// indices.extend(voronoi.triangulation().triangles.iter().map(|t| *t as u32));
|
||||||
@ -158,9 +166,6 @@ fn setup(
|
|||||||
.with_inserted_indices(Indices::U32(indices));
|
.with_inserted_indices(Indices::U32(indices));
|
||||||
|
|
||||||
mesh.compute_smooth_normals();
|
mesh.compute_smooth_normals();
|
||||||
mesh.generate_tangents();
|
|
||||||
// mesh.duplicate_vertices();
|
|
||||||
// mesh.compute_flat_normals();
|
|
||||||
|
|
||||||
let mut cells_entities = Vec::with_capacity(cells.len());
|
let mut cells_entities = Vec::with_capacity(cells.len());
|
||||||
|
|
||||||
@ -210,7 +215,9 @@ fn update_map_mesh(
|
|||||||
if needs_update.0 {
|
if needs_update.0 {
|
||||||
if let Some(mesh) = meshes.get_mut(mesh) {
|
if let Some(mesh) = meshes.get_mut(mesh) {
|
||||||
let mut modified = false;
|
let mut modified = false;
|
||||||
|
// let mut rng = thread_rng();
|
||||||
for (cell, wealth) in cells.iter() {
|
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());
|
let col = cell.color(wealth.map(|w| w.0).unwrap_or_default());
|
||||||
for id in cell.vertices.iter() {
|
for id in cell.vertices.iter() {
|
||||||
modified = modified || cols.0[*id] != col;
|
modified = modified || cols.0[*id] != col;
|
||||||
|
@ -202,7 +202,6 @@ fn zoom_with_scroll(
|
|||||||
let window = window.single();
|
let window = window.single();
|
||||||
let mut cam = cam.single_mut();
|
let mut cam = cam.single_mut();
|
||||||
for ev in ev_scroll.read() {
|
for ev in ev_scroll.read() {
|
||||||
dbg!(ev.y);
|
|
||||||
let forward = cam.forward();
|
let forward = cam.forward();
|
||||||
cam.translation += forward * (ev.y * 0.1);
|
cam.translation += forward * (ev.y * 0.1);
|
||||||
// cam.fov = cam.fov + (ev.y * 0.1);
|
// cam.fov = cam.fov + (ev.y * 0.1);
|
||||||
|
Loading…
Reference in New Issue
Block a user