diff --git a/server/src/metrics.rs b/server/src/metrics.rs index 3fcf94cf4f..11913abd7a 100644 --- a/server/src/metrics.rs +++ b/server/src/metrics.rs @@ -33,7 +33,6 @@ pub struct ServerMetrics { } impl TickMetrics { - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 pub fn new(registry: &Registry, tick: Arc) -> Result> { let player_online = IntGauge::with_opts(Opts::new( "player_online", @@ -65,10 +64,10 @@ impl TickMetrics { "chunks_count", "number of all chunks currently active on the server", ))?; - let tick_time = IntGaugeVec::from(IntGaugeVec::new( + let tick_time = IntGaugeVec::new( Opts::new("tick_time", "time in ns requiered for a tick of the server"), &["period"], - )?); + )?; let since_the_epoch = SystemTime::now() .duration_since(UNIX_EPOCH) diff --git a/voxygen/src/anim/character/glidewield.rs b/voxygen/src/anim/character/glidewield.rs index 0b0985e64a..054dceda65 100644 --- a/voxygen/src/anim/character/glidewield.rs +++ b/voxygen/src/anim/character/glidewield.rs @@ -9,7 +9,7 @@ impl Animation for GlideWieldAnimation { type Dependency = (Option, Option, Vec3, Vec3, Vec3, f64); type Skeleton = CharacterSkeleton; - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton( skeleton: &Self::Skeleton, (_active_tool_kind, _second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency, diff --git a/voxygen/src/anim/src/character/charge.rs b/voxygen/src/anim/src/character/charge.rs index 0563243364..e2581c3e2b 100644 --- a/voxygen/src/anim/src/character/charge.rs +++ b/voxygen/src/anim/src/character/charge.rs @@ -21,7 +21,7 @@ impl Animation for ChargeAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "character_charge")] #[allow(clippy::approx_constant)] // TODO: Pending review in #587 - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, _global_time): Self::Dependency, @@ -60,10 +60,10 @@ impl Animation for ChargeAnimation { let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/glidewield.rs b/voxygen/src/anim/src/character/glidewield.rs index 70646f2f95..c60a985410 100644 --- a/voxygen/src/anim/src/character/glidewield.rs +++ b/voxygen/src/anim/src/character/glidewield.rs @@ -22,7 +22,7 @@ impl Animation for GlideWieldAnimation { const UPDATE_FN: &'static [u8] = b"character_glidewield\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_glidewield")] - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency, @@ -94,10 +94,10 @@ impl Animation for GlideWieldAnimation { * 0.1, ); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/gliding.rs b/voxygen/src/anim/src/character/gliding.rs index 704523b333..615d7d0a1d 100644 --- a/voxygen/src/anim/src/character/gliding.rs +++ b/voxygen/src/anim/src/character/gliding.rs @@ -22,7 +22,7 @@ impl Animation for GlidingAnimation { const UPDATE_FN: &'static [u8] = b"character_gliding\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_gliding")] - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency, @@ -54,10 +54,10 @@ impl Animation for GlidingAnimation { * 0.25, ); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.0001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/jump.rs b/voxygen/src/anim/src/character/jump.rs index 33730731c1..62cccf8941 100644 --- a/voxygen/src/anim/src/character/jump.rs +++ b/voxygen/src/anim/src/character/jump.rs @@ -18,7 +18,7 @@ impl Animation for JumpAnimation { const UPDATE_FN: &'static [u8] = b"character_jump\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_jump")] - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, orientation, last_ori, global_time): Self::Dependency, @@ -39,10 +39,10 @@ impl Animation for JumpAnimation { let switch = if random > 0.5 { 1.0 } else { -1.0 }; - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/roll.rs b/voxygen/src/anim/src/character/roll.rs index 7a31246219..5079d119c7 100644 --- a/voxygen/src/anim/src/character/roll.rs +++ b/voxygen/src/anim/src/character/roll.rs @@ -19,7 +19,7 @@ impl Animation for RollAnimation { const UPDATE_FN: &'static [u8] = b"character_roll\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_roll")] - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, orientation, last_ori, _global_time): Self::Dependency, @@ -31,10 +31,10 @@ impl Animation for RollAnimation { let mut next = (*skeleton).clone(); let spin = anim_time as f32; - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.0001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/run.rs b/voxygen/src/anim/src/character/run.rs index 35bd0cacdd..a2d24a2bd1 100644 --- a/voxygen/src/anim/src/character/run.rs +++ b/voxygen/src/anim/src/character/run.rs @@ -23,7 +23,7 @@ impl Animation for RunAnimation { const UPDATE_FN: &'static [u8] = b"character_run\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_run")] - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency, @@ -96,10 +96,10 @@ impl Animation for RunAnimation { * 0.1, ); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 12e9be25d3..cbabf7c081 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -22,7 +22,7 @@ impl Animation for SwimAnimation { const UPDATE_FN: &'static [u8] = b"character_swim\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_swim")] - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 + fn update_skeleton_inner( skeleton: &Self::Skeleton, (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency, @@ -57,10 +57,10 @@ impl Animation for SwimAnimation { .sin() * 0.1, ); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/quadruped_low/run.rs b/voxygen/src/anim/src/quadruped_low/run.rs index 0a69bbfc30..259d660929 100644 --- a/voxygen/src/anim/src/quadruped_low/run.rs +++ b/voxygen/src/anim/src/quadruped_low/run.rs @@ -11,7 +11,6 @@ impl Animation for RunAnimation { #[cfg(feature = "use-dyn-lib")] const UPDATE_FN: &'static [u8] = b"quadruped_low_run\0"; - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_run")] fn update_skeleton_inner( skeleton: &Self::Skeleton, @@ -71,10 +70,10 @@ impl Animation for RunAnimation { * ((anim_time as f32 * 16.0 * lab as f32 + PI * 0.05).sin()); let footvertrb = (anim_time as f32 * 16.0 * lab as f32 + PI * 0.6).sin(); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/quadruped_medium/run.rs b/voxygen/src/anim/src/quadruped_medium/run.rs index 5feef6b718..5dadddf37d 100644 --- a/voxygen/src/anim/src/quadruped_medium/run.rs +++ b/voxygen/src/anim/src/quadruped_medium/run.rs @@ -11,7 +11,6 @@ impl Animation for RunAnimation { #[cfg(feature = "use-dyn-lib")] const UPDATE_FN: &'static [u8] = b"quadruped_medium_run\0"; - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_run")] fn update_skeleton_inner( skeleton: &Self::Skeleton, @@ -58,10 +57,10 @@ impl Animation for RunAnimation { let footvertaltfslow = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 1.8).sin(); let footverttaltfslow = (anim_time as f32 * 16.0 * lab as f32 * speedmult + PI * 2.2).sin(); // - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/render/error.rs b/voxygen/src/render/error.rs index dcf74680d9..a0437c4794 100644 --- a/voxygen/src/render/error.rs +++ b/voxygen/src/render/error.rs @@ -17,11 +17,10 @@ impl From> for RenderError { } impl From> for RenderError { - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 fn from(err: gfx::PipelineStateError<&str>) -> Self { match err { gfx::PipelineStateError::DescriptorInit(err) => { - gfx::PipelineStateError::DescriptorInit(err.into()) + gfx::PipelineStateError::DescriptorInit(err) }, err => err, } diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index d75ca1f65a..326ec2b0ae 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -70,7 +70,6 @@ impl<'a, R: Rng> GenCtx<'a, R> { } impl Civs { - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 pub fn generate(seed: u32, sim: &mut WorldSim) -> Self { let mut this = Self::default(); let rng = ChaChaRng::from_seed(seed_expan::rng_state(seed)); @@ -120,7 +119,7 @@ impl Civs { for site in this.sites.iter() { let radius = 48i32; - let wpos = site.center * Vec2::from(TerrainChunkSize::RECT_SIZE).map(|e: u32| e as i32); + let wpos = site.center * TerrainChunkSize::RECT_SIZE.map(|e: u32| e as i32); let flatten_radius = match &site.kind { SiteKind::Settlement => 10.0, @@ -164,11 +163,9 @@ impl Civs { let mut cnt = 0; for site in this.sites.iter() { cnt += 1; - let wpos = site - .center - .map2(Vec2::from(TerrainChunkSize::RECT_SIZE), |e, sz: u32| { - e * sz as i32 + sz as i32 / 2 - }); + let wpos = site.center.map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| { + e * sz as i32 + sz as i32 / 2 + }); let mut rng = ctx.reseed().rng; let world_site = match &site.kind { diff --git a/world/src/lib.rs b/world/src/lib.rs index 38a5158fd2..12e6112947 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -64,7 +64,6 @@ impl World { pub fn sample_blocks(&self) -> BlockGen { BlockGen::new(ColumnGen::new(&self.sim)) } - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 #[allow(clippy::or_fun_call)] // TODO: Pending review in #587 pub fn generate_chunk( &self, @@ -74,7 +73,7 @@ impl World { ) -> Result<(TerrainChunk, ChunkSupplement), ()> { let mut sampler = self.sample_blocks(); - let chunk_wpos2d = Vec2::from(chunk_pos) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32); + let chunk_wpos2d = chunk_pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32); let grid_border = 4; let zcache_grid = Grid::populate_from( TerrainChunkSize::RECT_SIZE.map(|e| e as i32) + grid_border * 2, diff --git a/world/src/sim/map.rs b/world/src/sim/map.rs index 6dd4544d80..5365fba293 100644 --- a/world/src/sim/map.rs +++ b/world/src/sim/map.rs @@ -109,7 +109,6 @@ impl MapConfig { /// to the caller to provide a function that translates this information /// into the correct format for a buffer and writes to it. #[allow(clippy::if_same_then_else)] // TODO: Pending review in #587 - #[allow(clippy::useless_conversion)] // TODO: Pending review in #587 #[allow(clippy::unnested_or_patterns)] // TODO: Pending review in #587 #[allow(clippy::many_single_char_names)] pub fn generate( @@ -142,190 +141,186 @@ impl MapConfig { let focus_rect = Vec2::from(focus); let true_sea_level = (CONFIG.sea_level as f64 - focus.z) / gain as f64; - (0..dimensions.y * dimensions.x) - .into_iter() - .for_each(|chunk_idx| { - let i = chunk_idx % dimensions.x as usize; - let j = chunk_idx / dimensions.x as usize; + (0..dimensions.y * dimensions.x).for_each(|chunk_idx| { + let i = chunk_idx % dimensions.x as usize; + let j = chunk_idx / dimensions.x as usize; - let pos = - (focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32); + let pos = (focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32); - let ( - alt, - basement, - water_alt, - humidity, - temperature, - downhill, - river_kind, - is_path, - near_site, - ) = sampler - .get(pos) - .map(|sample| { - ( - sample.alt, - sample.basement, - sample.water_alt, - sample.humidity, - sample.temp, - sample.downhill, - sample.river.river_kind, - sample.path.is_path(), - sample.sites.iter().any(|site| { - site.get_origin() - .distance_squared(pos * TerrainChunkSize::RECT_SIZE.x as i32) - < 64i32.pow(2) - }), - ) - }) - .unwrap_or(( - CONFIG.sea_level, - CONFIG.sea_level, - CONFIG.sea_level, - 0.0, - 0.0, - None, - None, - false, - false, - )); - let humidity = humidity.min(1.0).max(0.0); - let temperature = temperature.min(1.0).max(-1.0) * 0.5 + 0.5; - let pos = pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32); - let downhill_pos = (downhill - .map(|downhill_pos| downhill_pos) - .unwrap_or(pos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32)) - - pos) - + pos; - let downhill_alt = sampler - .get_wpos(downhill_pos) - .map(|s| if is_basement { s.basement } else { s.alt }) - .unwrap_or(CONFIG.sea_level); - let alt = if is_basement { basement } else { alt }; - let cross_pos = pos - + ((downhill_pos - pos) - .map(|e| e as f32) - .rotated_z(f32::consts::FRAC_PI_2) - .map(|e| e as i32)); - let cross_alt = sampler - .get_wpos(cross_pos) - .map(|s| if is_basement { s.basement } else { s.alt }) - .unwrap_or(CONFIG.sea_level); - // Pointing downhill, forward - // (index--note that (0,0,1) is backward right-handed) - let forward_vec = Vec3::new( - (downhill_pos.x - pos.x) as f64, - (downhill_alt - alt) as f64 * lgain, - (downhill_pos.y - pos.y) as f64, - ); - // Pointing 90 degrees left (in horizontal xy) of downhill, up - // (middle--note that (1,0,0), 90 degrees CCW backward, is right right-handed) - let up_vec = Vec3::new( - (cross_pos.x - pos.x) as f64, - (cross_alt - alt) as f64 * lgain, - (cross_pos.y - pos.y) as f64, - ); - // Then cross points "to the right" (upwards) on a right-handed coordinate - // system. (right-handed coordinate system means (0, 0, 1.0) is - // "forward" into the screen). - let surface_normal = forward_vec.cross(up_vec).normalized(); - let light = (surface_normal.dot(light) + 1.0) / 2.0; - let light = (light * 0.9) + 0.1; + let ( + alt, + basement, + water_alt, + humidity, + temperature, + downhill, + river_kind, + is_path, + near_site, + ) = sampler + .get(pos) + .map(|sample| { + ( + sample.alt, + sample.basement, + sample.water_alt, + sample.humidity, + sample.temp, + sample.downhill, + sample.river.river_kind, + sample.path.is_path(), + sample.sites.iter().any(|site| { + site.get_origin() + .distance_squared(pos * TerrainChunkSize::RECT_SIZE.x as i32) + < 64i32.pow(2) + }), + ) + }) + .unwrap_or(( + CONFIG.sea_level, + CONFIG.sea_level, + CONFIG.sea_level, + 0.0, + 0.0, + None, + None, + false, + false, + )); + let humidity = humidity.min(1.0).max(0.0); + let temperature = temperature.min(1.0).max(-1.0) * 0.5 + 0.5; + let pos = pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32); + let downhill_pos = (downhill + .map(|downhill_pos| downhill_pos) + .unwrap_or(pos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32)) + - pos) + + pos; + let downhill_alt = sampler + .get_wpos(downhill_pos) + .map(|s| if is_basement { s.basement } else { s.alt }) + .unwrap_or(CONFIG.sea_level); + let alt = if is_basement { basement } else { alt }; + let cross_pos = pos + + ((downhill_pos - pos) + .map(|e| e as f32) + .rotated_z(f32::consts::FRAC_PI_2) + .map(|e| e as i32)); + let cross_alt = sampler + .get_wpos(cross_pos) + .map(|s| if is_basement { s.basement } else { s.alt }) + .unwrap_or(CONFIG.sea_level); + // Pointing downhill, forward + // (index--note that (0,0,1) is backward right-handed) + let forward_vec = Vec3::new( + (downhill_pos.x - pos.x) as f64, + (downhill_alt - alt) as f64 * lgain, + (downhill_pos.y - pos.y) as f64, + ); + // Pointing 90 degrees left (in horizontal xy) of downhill, up + // (middle--note that (1,0,0), 90 degrees CCW backward, is right right-handed) + let up_vec = Vec3::new( + (cross_pos.x - pos.x) as f64, + (cross_alt - alt) as f64 * lgain, + (cross_pos.y - pos.y) as f64, + ); + // Then cross points "to the right" (upwards) on a right-handed coordinate + // system. (right-handed coordinate system means (0, 0, 1.0) is + // "forward" into the screen). + let surface_normal = forward_vec.cross(up_vec).normalized(); + let light = (surface_normal.dot(light) + 1.0) / 2.0; + let light = (light * 0.9) + 0.1; - let true_water_alt = (alt.max(water_alt) as f64 - focus.z) / gain as f64; - let true_alt = (alt as f64 - focus.z) / gain as f64; - let water_depth = (true_water_alt - true_alt).min(1.0).max(0.0); - let water_alt = true_water_alt.min(1.0).max(0.0); - let alt = true_alt.min(1.0).max(0.0); - if is_debug { - let quad = |x: f32| { - ((x as f64 * QUADRANTS as f64).floor() as usize).min(QUADRANTS - 1) - }; - if river_kind.is_none() || humidity != 0.0 { - quads[quad(humidity)][quad(temperature)] += 1; - } - match river_kind { - Some(RiverKind::River { .. }) => { - rivers += 1; - }, - Some(RiverKind::Lake { .. }) => { - lakes += 1; - }, - Some(RiverKind::Ocean { .. }) => { - oceans += 1; - }, - None => {}, - } + let true_water_alt = (alt.max(water_alt) as f64 - focus.z) / gain as f64; + let true_alt = (alt as f64 - focus.z) / gain as f64; + let water_depth = (true_water_alt - true_alt).min(1.0).max(0.0); + let water_alt = true_water_alt.min(1.0).max(0.0); + let alt = true_alt.min(1.0).max(0.0); + if is_debug { + let quad = + |x: f32| ((x as f64 * QUADRANTS as f64).floor() as usize).min(QUADRANTS - 1); + if river_kind.is_none() || humidity != 0.0 { + quads[quad(humidity)][quad(temperature)] += 1; } - - let water_color_factor = 2.0; - let g_water = 32.0 * water_color_factor; - let b_water = 64.0 * water_color_factor; - let rgba = match (river_kind, (is_water, true_alt >= true_sea_level)) { - (_, (false, _)) | (None, (_, true)) => { - let (r, g, b) = ( - (if is_shaded { alt } else { alt } - * if is_temperature { - temperature as f64 - } else if is_shaded { - alt - } else { - 0.0 - }) - .sqrt(), - if is_shaded { 0.4 + (alt * 0.6) } else { alt }, - (if is_shaded { alt } else { alt } - * if is_humidity { - humidity as f64 - } else if is_shaded { - alt - } else { - 0.0 - }) - .sqrt(), - ); - let light = if is_shaded { light } else { 1.0 }; - ( - (r * light * 255.0) as u8, - (g * light * 255.0) as u8, - (b * light * 255.0) as u8, - 255, - ) + match river_kind { + Some(RiverKind::River { .. }) => { + rivers += 1; }, - (Some(RiverKind::Ocean), _) => ( - 0, - ((g_water - water_depth * g_water) * 1.0) as u8, - ((b_water - water_depth * b_water) * 1.0) as u8, - 255, - ), - (Some(RiverKind::River { .. }), _) => ( - 0, - g_water as u8 + (alt * (127.0 - g_water)) as u8, - b_water as u8 + (alt * (255.0 - b_water)) as u8, - 255, - ), - (None, _) | (Some(RiverKind::Lake { .. }), _) => ( - 0, - (((g_water + water_alt * (127.0 - 32.0)) + (-water_depth * g_water)) * 1.0) - as u8, - (((b_water + water_alt * (255.0 - b_water)) + (-water_depth * b_water)) - * 1.0) as u8, - 255, - ), - }; + Some(RiverKind::Lake { .. }) => { + lakes += 1; + }, + Some(RiverKind::Ocean { .. }) => { + oceans += 1; + }, + None => {}, + } + } - let rgba = if near_site { - (0x57, 0x39, 0x33, 0xFF) - } else if is_path { - (0x37, 0x29, 0x23, 0xFF) - } else { - rgba - }; + let water_color_factor = 2.0; + let g_water = 32.0 * water_color_factor; + let b_water = 64.0 * water_color_factor; + let rgba = match (river_kind, (is_water, true_alt >= true_sea_level)) { + (_, (false, _)) | (None, (_, true)) => { + let (r, g, b) = ( + (if is_shaded { alt } else { alt } + * if is_temperature { + temperature as f64 + } else if is_shaded { + alt + } else { + 0.0 + }) + .sqrt(), + if is_shaded { 0.4 + (alt * 0.6) } else { alt }, + (if is_shaded { alt } else { alt } + * if is_humidity { + humidity as f64 + } else if is_shaded { + alt + } else { + 0.0 + }) + .sqrt(), + ); + let light = if is_shaded { light } else { 1.0 }; + ( + (r * light * 255.0) as u8, + (g * light * 255.0) as u8, + (b * light * 255.0) as u8, + 255, + ) + }, + (Some(RiverKind::Ocean), _) => ( + 0, + ((g_water - water_depth * g_water) * 1.0) as u8, + ((b_water - water_depth * b_water) * 1.0) as u8, + 255, + ), + (Some(RiverKind::River { .. }), _) => ( + 0, + g_water as u8 + (alt * (127.0 - g_water)) as u8, + b_water as u8 + (alt * (255.0 - b_water)) as u8, + 255, + ), + (None, _) | (Some(RiverKind::Lake { .. }), _) => ( + 0, + (((g_water + water_alt * (127.0 - 32.0)) + (-water_depth * g_water)) * 1.0) + as u8, + (((b_water + water_alt * (255.0 - b_water)) + (-water_depth * b_water)) * 1.0) + as u8, + 255, + ), + }; - write_pixel(Vec2::new(i, j), rgba); - }); + let rgba = if near_site { + (0x57, 0x39, 0x33, 0xFF) + } else if is_path { + (0x37, 0x29, 0x23, 0xFF) + } else { + rgba + }; + + write_pixel(Vec2::new(i, j), rgba); + }); MapDebug { quads,