Merge branch 'clippy-fixes-useless_conversion' into 'master'

Fixed suppressed clippy warnings for #587 - useless_conversion

See merge request veloren/veloren!1198
This commit is contained in:
Marcel 2020-07-13 20:54:42 +00:00
commit 011cfe4942
15 changed files with 207 additions and 220 deletions

View File

@ -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<AtomicU64>) -> Result<Self, Box<dyn Error>> {
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)

View File

@ -9,7 +9,7 @@ impl Animation for GlideWieldAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, 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,

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -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<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::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()

View File

@ -17,11 +17,10 @@ impl From<gfx::PipelineStateError<String>> for RenderError {
}
impl From<gfx::PipelineStateError<&str>> 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,
}

View File

@ -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 {

View File

@ -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,

View File

@ -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,