mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix clippy errors
This commit is contained in:
parent
ba3747a3f0
commit
0ab7a2543e
@ -521,7 +521,7 @@ impl Client {
|
||||
Rgb::new(0.15, 0.15, 0.15)
|
||||
} else {
|
||||
// Color hill shading
|
||||
let lightness = (alt + 0.2).min(1.0) as f64;
|
||||
let lightness = (alt + 0.2).min(1.0);
|
||||
Rgb::new(lightness, 0.9 * lightness, 0.5 * lightness)
|
||||
}
|
||||
} else if is_stylized_topo {
|
||||
|
@ -300,7 +300,7 @@ where
|
||||
{
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
own: Box::new(T::default()),
|
||||
own: Box::<T>::default(),
|
||||
cpu_stats: CpuTimeline::default(),
|
||||
}
|
||||
}
|
||||
|
@ -849,9 +849,7 @@ impl Damage {
|
||||
|
||||
let penetration = if let Some(damage) = damage {
|
||||
if let DamageKind::Piercing = damage.kind {
|
||||
(damage.value * PIERCING_PENETRATION_FRACTION)
|
||||
.min(protection.unwrap_or(0.0))
|
||||
.max(0.0)
|
||||
(damage.value * PIERCING_PENETRATION_FRACTION).clamp(0.0, protection.unwrap_or(0.0))
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
@ -1170,7 +1168,7 @@ pub fn combat_rating(
|
||||
* compute_energy_reward_mod(Some(inventory), msm);
|
||||
|
||||
// Normalized with a standard max poise of 100
|
||||
let poise_rating = poise.base_max() as f32
|
||||
let poise_rating = poise.base_max()
|
||||
/ 100.0
|
||||
/ (1.0 - Poise::compute_poise_damage_reduction(Some(inventory), msm, None, None))
|
||||
.max(0.00001);
|
||||
|
@ -2147,7 +2147,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
|
||||
speed_increase: 1.0 - *speed_increase,
|
||||
max_speed_increase: *max_speed_increase,
|
||||
scales_from_combo: *scales_from_combo,
|
||||
ori_modifier: *ori_modifier as f32,
|
||||
ori_modifier: *ori_modifier,
|
||||
ability_info,
|
||||
},
|
||||
exhausted: false,
|
||||
|
@ -207,7 +207,7 @@ impl Ori {
|
||||
// NOTE: acos is very sensitive to errors at small angles
|
||||
// - https://www.researchgate.net/post/How_do_I_calculate_the_smallest_angle_between_two_quaternions
|
||||
// - see angle_between unit test epislons
|
||||
let angle = 2.0 * between.w.min(1.0).max(-1.0).acos();
|
||||
let angle = 2.0 * between.w.clamp(-1.0, 1.0).acos();
|
||||
if angle < PI { angle } else { TAU - angle }
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ fn rotation_2d(Vec2 { x, y }: Vec2<f32>, axis: Vec3<f32>) -> Quaternion<f32> {
|
||||
// cos(a) = x / |xy| => x (when normalized)
|
||||
|
||||
// Prevent NaNs from negative sqrt (float errors can put this slightly over 1.0)
|
||||
let x = x.min(1.0).max(-1.0);
|
||||
let x = x.clamp(-1.0, 1.0);
|
||||
|
||||
let scalar = ((1.0 + x) / 2.0).sqrt() * y.signum();
|
||||
let vector = axis * ((1.0 - x) / 2.0).sqrt();
|
||||
|
@ -131,7 +131,7 @@ impl SkillSetBuilder {
|
||||
for _ in 0..level {
|
||||
skill_set.add_skill_points(group, skill_set.skill_cost(skill));
|
||||
if let Err(err) = skill_set.unlock_skill(skill) {
|
||||
let err_msg = format!("Failed to add skill: {:?}. Error: {:?}", skill, err);
|
||||
let err_msg = format!("Failed to add skill: {skill:?}. Error: {err:?}");
|
||||
common_base::dev_panic!(err_msg);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ impl CharacterBehavior for Data {
|
||||
// Consumes energy if there's enough left and RMB is held down
|
||||
update
|
||||
.energy
|
||||
.change_by(-self.static_data.energy_drain as f32 * data.dt.0 / 5.0);
|
||||
.change_by(-self.static_data.energy_drain * data.dt.0 / 5.0);
|
||||
} else {
|
||||
// Transitions to swing
|
||||
update.character = CharacterState::ChargedMelee(Data {
|
||||
|
@ -99,8 +99,8 @@ impl CharacterBehavior for Data {
|
||||
if !self.static_data.ability_info.input.map_or(false, |input| input_is_pressed(data, input)) && !self.exhausted {
|
||||
let charge_frac = self.charge_frac();
|
||||
let arrow = ProjectileConstructor::Arrow {
|
||||
damage: self.static_data.initial_damage as f32
|
||||
+ charge_frac * self.static_data.scaled_damage as f32,
|
||||
damage: self.static_data.initial_damage
|
||||
+ charge_frac * self.static_data.scaled_damage,
|
||||
knockback: self.static_data.initial_knockback
|
||||
+ charge_frac * self.static_data.scaled_knockback,
|
||||
energy_regen: self.static_data.initial_regen
|
||||
|
@ -251,7 +251,7 @@ impl CharacterBehavior for Data {
|
||||
Damage {
|
||||
source: DamageSource::Melee,
|
||||
kind: self.static_data.stage_data[stage_index].damage_kind,
|
||||
value: damage as f32,
|
||||
value: damage,
|
||||
},
|
||||
Some(GroupTarget::OutOfGroup),
|
||||
rand::random(),
|
||||
|
@ -80,7 +80,7 @@ impl CharacterBehavior for Data {
|
||||
// Attack
|
||||
let poise = AttackEffect::new(
|
||||
Some(GroupTarget::OutOfGroup),
|
||||
CombatEffect::Poise(self.static_data.poise_damage as f32),
|
||||
CombatEffect::Poise(self.static_data.poise_damage),
|
||||
)
|
||||
.with_requirement(CombatRequirement::AnyDamage);
|
||||
let knockback = AttackEffect::new(
|
||||
@ -92,7 +92,7 @@ impl CharacterBehavior for Data {
|
||||
Damage {
|
||||
source: DamageSource::Shockwave,
|
||||
kind: self.static_data.damage_kind,
|
||||
value: self.static_data.damage as f32,
|
||||
value: self.static_data.damage,
|
||||
},
|
||||
Some(GroupTarget::OutOfGroup),
|
||||
rand::random(),
|
||||
|
@ -118,7 +118,7 @@ impl CharacterBehavior for Data {
|
||||
timer: tick_attack_or_default(data, self.timer, None),
|
||||
..*self
|
||||
});
|
||||
} else if update.energy.current() as f32 >= self.static_data.energy_cost
|
||||
} else if update.energy.current() >= self.static_data.energy_cost
|
||||
&& (self.consecutive_spins < self.static_data.num_spins
|
||||
|| (self.static_data.is_infinite
|
||||
&& self.static_data.ability_info.input.map_or(false, |input| input_is_pressed(data, input))))
|
||||
|
@ -116,7 +116,7 @@ impl CharacterBehavior for Data {
|
||||
|
||||
// Location sprite will be created
|
||||
let sprite_pos =
|
||||
Vec3::new(sprite_pos.x as i32, sprite_pos.y as i32, z);
|
||||
Vec3::new(sprite_pos.x, sprite_pos.y, z);
|
||||
// Layers of sprites
|
||||
let layers = match self.static_data.sprite {
|
||||
SpriteKind::SeaUrchin => 2,
|
||||
@ -125,7 +125,7 @@ impl CharacterBehavior for Data {
|
||||
for i in 0..layers {
|
||||
// Send server event to create sprite
|
||||
output_events.emit_server(ServerEvent::CreateSprite {
|
||||
pos: Vec3::new(sprite_pos.x as i32, sprite_pos.y, z + i),
|
||||
pos: Vec3::new(sprite_pos.x, sprite_pos.y, z + i),
|
||||
sprite: self.static_data.sprite,
|
||||
});
|
||||
}
|
||||
|
@ -494,8 +494,8 @@ impl<'a> MapConfig<'a> {
|
||||
let world_size = map_size_lg.chunks();
|
||||
|
||||
(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 i = chunk_idx % dimensions.x;
|
||||
let j = chunk_idx / dimensions.x;
|
||||
|
||||
let wposf = focus_rect + Vec2::new(i as f64, j as f64) * scale;
|
||||
let pos = wposf.map(|e: f64| e as i32);
|
||||
|
@ -71,7 +71,7 @@ impl<V, S: VolSize, M> Chunk<V, S, M> {
|
||||
Self::GROUP_VOLUME / (Self::GROUP_LONG_SIDE_LEN * Self::GROUP_LONG_SIDE_LEN),
|
||||
);
|
||||
const GROUP_VOLUME: u32 = [Self::VOLUME / 256, 1][(Self::VOLUME < 256) as usize];
|
||||
const VOLUME: u32 = (S::SIZE.x * S::SIZE.y * S::SIZE.z) as u32;
|
||||
const VOLUME: u32 = (S::SIZE.x * S::SIZE.y * S::SIZE.z);
|
||||
|
||||
/// Creates a new `Chunk` with the provided dimensions and all voxels filled
|
||||
/// with duplicates of the provided voxel.
|
||||
|
@ -370,7 +370,7 @@ fn execute_effect(
|
||||
{
|
||||
let amount = match *kind {
|
||||
ModifierKind::Additive => *accumulated,
|
||||
ModifierKind::Fractional => energy.maximum() as f32 * *accumulated,
|
||||
ModifierKind::Fractional => energy.maximum() * *accumulated,
|
||||
};
|
||||
server_emitter.emit(ServerEvent::EnergyChange {
|
||||
entity,
|
||||
@ -421,7 +421,7 @@ fn execute_effect(
|
||||
ModifierKind::Additive => {
|
||||
// `rate * dt` is amount of health, dividing by base max
|
||||
// creates fraction
|
||||
*rate * dt / health.base_max() as f32
|
||||
*rate * dt / health.base_max()
|
||||
},
|
||||
ModifierKind::Fractional => {
|
||||
// `rate * dt` is the fraction
|
||||
|
@ -131,14 +131,14 @@ impl NetworkMetrics {
|
||||
let opts = Opts::new("network_info", "Static Network information")
|
||||
.const_label(
|
||||
"version",
|
||||
&format!(
|
||||
format!(
|
||||
"{}.{}.{}",
|
||||
&network_protocol::VELOREN_NETWORK_VERSION[0],
|
||||
&network_protocol::VELOREN_NETWORK_VERSION[1],
|
||||
&network_protocol::VELOREN_NETWORK_VERSION[2]
|
||||
),
|
||||
)
|
||||
.const_label("local_pid", &format!("{}", &local_pid));
|
||||
.const_label("local_pid", format!("{}", &local_pid));
|
||||
let network_info = IntGauge::with_opts(opts)?;
|
||||
|
||||
Ok(Self {
|
||||
|
@ -2520,7 +2520,7 @@ impl<'a> AgentData<'a> {
|
||||
) {
|
||||
controller.inputs.look_dir = Dir::new(
|
||||
Quaternion::from_xyzw(self.ori.look_dir().x, self.ori.look_dir().y, 0.0, 0.0)
|
||||
.rotated_z(6.0 * read_data.dt.0 as f32)
|
||||
.rotated_z(6.0 * read_data.dt.0)
|
||||
.into_vec3()
|
||||
.try_normalized()
|
||||
.unwrap_or_default(),
|
||||
|
@ -211,7 +211,7 @@ pub(crate) fn establish_connection(
|
||||
ConnectionMode::ReadOnly => OpenFlags::SQLITE_OPEN_READ_ONLY,
|
||||
};
|
||||
|
||||
let connection = Connection::open_with_flags(&settings.db_dir.join("db.sqlite"), open_flags)
|
||||
let connection = Connection::open_with_flags(settings.db_dir.join("db.sqlite"), open_flags)
|
||||
.unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"Error connecting to {}, Error: {:?}",
|
||||
|
@ -80,7 +80,7 @@ impl ViewDistance {
|
||||
pub fn new(start_value: u32, now: Instant) -> Self {
|
||||
Self {
|
||||
direction: Direction::Up,
|
||||
last_direction_change_time: now - Self::TIME_PER_DIR_CHANGE,
|
||||
last_direction_change_time: now.checked_sub(Self::TIME_PER_DIR_CHANGE).unwrap(),
|
||||
target: None,
|
||||
current: start_value,
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ pub fn init(
|
||||
}
|
||||
|
||||
// guards
|
||||
for _ in 0..site2.plazas().len() as usize {
|
||||
for _ in 0..site2.plazas().len() {
|
||||
rtsim.entities.insert(Entity {
|
||||
is_loaded: false,
|
||||
pos: site2
|
||||
@ -252,7 +252,7 @@ pub fn init(
|
||||
}
|
||||
|
||||
// merchants
|
||||
for _ in 0..site2.plazas().len() as usize {
|
||||
for _ in 0..site2.plazas().len() {
|
||||
rtsim.entities.insert(Entity {
|
||||
is_loaded: false,
|
||||
pos: site2
|
||||
@ -350,7 +350,7 @@ pub fn init(
|
||||
}
|
||||
|
||||
// guards
|
||||
for _ in 0..site2.plazas().len() as usize {
|
||||
for _ in 0..site2.plazas().len() {
|
||||
rtsim.entities.insert(Entity {
|
||||
is_loaded: false,
|
||||
pos: site2
|
||||
@ -374,7 +374,7 @@ pub fn init(
|
||||
}
|
||||
|
||||
// merchants
|
||||
for _ in 0..site2.plazas().len() as usize {
|
||||
for _ in 0..site2.plazas().len() {
|
||||
rtsim.entities.insert(Entity {
|
||||
is_loaded: false,
|
||||
pos: site2
|
||||
|
@ -3,7 +3,7 @@ use core::{convert::TryInto, fmt};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use std::{
|
||||
fs,
|
||||
io::{Seek, SeekFrom, Write},
|
||||
io::{Seek, Write},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
use tracing::{error, info, warn};
|
||||
@ -80,7 +80,7 @@ pub trait EditableSetting: Clone + Default {
|
||||
match ron::de::from_reader(&mut file)
|
||||
.map(|setting: Self::Setting| setting.try_into())
|
||||
.or_else(|orig_err| {
|
||||
file.seek(SeekFrom::Start(0))?;
|
||||
file.rewind()?;
|
||||
ron::de::from_reader(file)
|
||||
.map(|legacy| Ok((Version::Old, Self::Legacy::into(legacy))))
|
||||
// When both legacy and non-legacy have parse errors, prioritize the
|
||||
|
@ -222,7 +222,7 @@ pub fn initialize_region_subscription(world: &World, entity: specs::Entity) {
|
||||
let chunk_size = TerrainChunkSize::RECT_SIZE.reduce_max() as f32;
|
||||
let regions = regions_in_vd(
|
||||
client_pos.0,
|
||||
(presence.entity_view_distance.current() as f32 * chunk_size) as f32
|
||||
(presence.entity_view_distance.current() as f32 * chunk_size)
|
||||
+ (presence::CHUNK_FUZZ as f32 + chunk_size) * 2.0f32.sqrt(),
|
||||
);
|
||||
|
||||
|
@ -617,7 +617,7 @@ fn prepare_for_vd_check(
|
||||
// world chunk coordinates are no greater than 1 << 14 - 1; since we verified that the
|
||||
// player is within world bounds modulo player_vd, which is guaranteed to never let us
|
||||
// overflow an i16 when added to a u14, safety of the cast follows.
|
||||
.then(|| ((player_chunk_pos.as_::<i16>(), player_vd.pow(2) as i32), entity, is_client))
|
||||
.then(|| ((player_chunk_pos.as_::<i16>(), player_vd.pow(2)), entity, is_client))
|
||||
}
|
||||
|
||||
pub fn prepare_player_presences<'a, P>(
|
||||
|
@ -115,21 +115,21 @@ impl WeatherSim {
|
||||
} else {
|
||||
let wpos = cell_to_wpos_center(point);
|
||||
|
||||
let pos = wpos.as_::<f64>() + time as f64 * 0.1;
|
||||
let pos = wpos.as_::<f64>() + time * 0.1;
|
||||
|
||||
let space_scale = 7_500.0;
|
||||
let time_scale = 100_000.0;
|
||||
let spos = (pos / space_scale).with_z(time as f64 / time_scale);
|
||||
let spos = (pos / space_scale).with_z(time / time_scale);
|
||||
|
||||
let avg_scale = 20_000.0;
|
||||
let avg_delay = 250_000.0;
|
||||
let pressure = ((base_nz.get(
|
||||
(pos / avg_scale)
|
||||
.with_z(time as f64 / avg_delay)
|
||||
.with_z(time / avg_delay)
|
||||
.into_array(),
|
||||
) + base_nz.get(
|
||||
(pos / (avg_scale * 0.25))
|
||||
.with_z(time as f64 / (avg_delay * 0.25))
|
||||
.with_z(time / (avg_delay * 0.25))
|
||||
.into_array(),
|
||||
) * 0.5)
|
||||
* 0.5
|
||||
|
@ -43,7 +43,7 @@ impl Animation for ShockwaveAnimation {
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let (move1, move1pow, move2, move3) = match stage_section {
|
||||
Some(StageSection::Buildup) => (anim_time, anim_time.powf(0.25) as f32, 0.0, 0.0),
|
||||
Some(StageSection::Buildup) => (anim_time, anim_time.powf(0.25), 0.0, 0.0),
|
||||
Some(StageSection::Action) => (1.0, 1.0, anim_time, 0.0),
|
||||
Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
|
||||
_ => (0.0, 0.0, 0.0, 0.0),
|
||||
|
@ -32,12 +32,12 @@ impl Animation for GlidingAnimation {
|
||||
let slow = (acc_vel * 0.5).sin();
|
||||
|
||||
let head_look = Vec2::new(
|
||||
((global_time + anim_time) as f32 / 4.0)
|
||||
((global_time + anim_time) / 4.0)
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.5,
|
||||
((global_time + anim_time) as f32 / 4.0)
|
||||
((global_time + anim_time) / 4.0)
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
|
@ -33,7 +33,7 @@ impl Animation for JumpAnimation {
|
||||
let mut next = (*skeleton).clone();
|
||||
let slow = (anim_time * 7.0).sin();
|
||||
|
||||
let subtract = global_time - anim_time as f32;
|
||||
let subtract = global_time - anim_time;
|
||||
let check = subtract - subtract.trunc();
|
||||
let switch = (check - 0.5).signum();
|
||||
|
||||
|
@ -368,7 +368,7 @@ impl MusicMgr {
|
||||
};
|
||||
}
|
||||
|
||||
let is_dark = (state.get_day_period().is_dark()) as bool;
|
||||
let is_dark = state.get_day_period().is_dark();
|
||||
let current_period_of_day = Self::get_current_day_period(is_dark);
|
||||
let current_weather = client.weather_at_player();
|
||||
let current_biome = client.current_biome();
|
||||
|
@ -395,7 +395,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.map(|scroll| scroll.y)
|
||||
.sum();
|
||||
if scrolled != 0.0 {
|
||||
let min_zoom = map_size.x as f64 / worldsize.reduce_partial_max() as f64 / 2.0;
|
||||
let min_zoom = map_size.x / worldsize.reduce_partial_max() as f64 / 2.0;
|
||||
let new_zoom_lvl: f64 = (f64::log2(zoom) - scrolled * 0.03)
|
||||
.exp2()
|
||||
.clamp(min_zoom, 16.0);
|
||||
@ -1204,7 +1204,7 @@ impl<'a> Widget for Map<'a> {
|
||||
let side_length = 20.0 * factor;
|
||||
|
||||
let (rpos, fade) = match wpos_to_rpos_fade(
|
||||
member_pos.0.xy().map(|e| e as f32),
|
||||
member_pos.0.xy().map(|e| e),
|
||||
Vec2::from(side_length / 2.0),
|
||||
side_length / 2.0,
|
||||
) {
|
||||
@ -1232,7 +1232,7 @@ impl<'a> Widget for Map<'a> {
|
||||
|
||||
handle_widget_mouse_events(
|
||||
state.ids.member_indicators[i],
|
||||
MarkerChange::Pos(member_pos.0.xy().map(|e| e as f32)),
|
||||
MarkerChange::Pos(member_pos.0.xy().map(|e| e)),
|
||||
ui,
|
||||
&mut events,
|
||||
state.ids.map_layers[0],
|
||||
|
@ -93,7 +93,7 @@ impl VoxelMinimap {
|
||||
.ok()
|
||||
.and_then(Self::block_color)
|
||||
.unwrap_or_else(Rgba::zero);
|
||||
rgba += color.as_() * weights[dz as usize] as f32;
|
||||
rgba += color.as_() * weights[dz] as f32;
|
||||
}
|
||||
let rgba: Rgba<u8> = (rgba / weights.iter().map(|x| *x as f32).sum::<f32>()).as_();
|
||||
(rgba, true)
|
||||
@ -769,7 +769,7 @@ impl<'a> Widget for MiniMap<'a> {
|
||||
let member_pos = entity.and_then(|entity| member_pos.get(entity));
|
||||
|
||||
if let Some(member_pos) = member_pos {
|
||||
let rpos = match wpos_to_rpos(member_pos.0.xy().map(|e| e as f32), false) {
|
||||
let rpos = match wpos_to_rpos(member_pos.0.xy().map(|e| e), false) {
|
||||
Some(rpos) => rpos,
|
||||
None => continue,
|
||||
};
|
||||
|
@ -224,12 +224,12 @@ impl<'a> Widget for Overhead<'a> {
|
||||
let health_cur_txt = match health_current as u32 {
|
||||
0..=999 => format!("{:.0}", health_current.max(1.0)),
|
||||
1000..=999999 => format!("{:.0}K", (health_current / 1000.0).max(1.0)),
|
||||
_ => format!("{:.0}M", (health_current as f64 / 1.0e6).max(1.0)),
|
||||
_ => format!("{:.0}M", (health_current / 1.0e6).max(1.0)),
|
||||
};
|
||||
let health_max_txt = match health_max as u32 {
|
||||
0..=999 => format!("{:.0}", health_max.max(1.0)),
|
||||
1000..=999999 => format!("{:.0}K", (health_max / 1000.0).max(1.0)),
|
||||
_ => format!("{:.0}M", (health_max as f64 / 1.0e6).max(1.0)),
|
||||
_ => format!("{:.0}M", (health_max / 1.0e6).max(1.0)),
|
||||
};
|
||||
// Buffs
|
||||
// Alignment
|
||||
|
@ -421,7 +421,7 @@ impl<'frame> Drawer<'frame> {
|
||||
let screen_descriptor = ScreenDescriptor {
|
||||
physical_width: self.borrow.sc_desc.width,
|
||||
physical_height: self.borrow.sc_desc.height,
|
||||
scale_factor: scale_factor as f32,
|
||||
scale_factor,
|
||||
};
|
||||
|
||||
self.borrow.egui_render_pass.update_texture(
|
||||
@ -737,7 +737,7 @@ impl<'pass_ref, 'pass: 'pass_ref> FigureShadowDrawer<'pass_ref, 'pass> {
|
||||
self.render_pass.set_bind_group(1, &locals.bind_group, &[]);
|
||||
self.render_pass.set_vertex_buffer(0, model.buf());
|
||||
self.render_pass
|
||||
.draw_indexed(0..model.len() as u32 / 4 * 6, 0, 0..1);
|
||||
.draw_indexed(0..model.len() / 4 * 6, 0, 0..1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -916,7 +916,7 @@ impl<'pass_ref, 'pass: 'pass_ref> FigureDrawer<'pass_ref, 'pass> {
|
||||
self.render_pass.set_bind_group(3, &locals.bind_group, &[]);
|
||||
self.render_pass.set_vertex_buffer(0, model.buf());
|
||||
self.render_pass
|
||||
.draw_indexed(0..model.len() as u32 / 4 * 6, 0, 0..1);
|
||||
.draw_indexed(0..model.len() / 4 * 6, 0, 0..1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ impl RainOcclusionMap {
|
||||
(diag_size as u32, diag_cross_size as u32)
|
||||
} else {
|
||||
// Limit to max texture resolution rather than error.
|
||||
(max_texture_size as u32, max_texture_size as u32)
|
||||
(max_texture_size, max_texture_size)
|
||||
};
|
||||
let diag_two_size = u32::checked_next_power_of_two(diag_size)
|
||||
.filter(|&e| e <= max_texture_size)
|
||||
|
@ -188,7 +188,7 @@ impl ShadowMap {
|
||||
(diag_size as u32, diag_cross_size as u32)
|
||||
} else {
|
||||
// Limit to max texture resolution rather than error.
|
||||
(max_texture_size as u32, max_texture_size as u32)
|
||||
(max_texture_size, max_texture_size)
|
||||
};
|
||||
let diag_two_size = u32::checked_next_power_of_two(diag_size)
|
||||
.filter(|&e| e <= max_texture_size)
|
||||
|
@ -824,7 +824,7 @@ impl FigureMgr {
|
||||
let vd_frac = anim::vek::Vec2::from(pos.0 - player_pos)
|
||||
.map2(
|
||||
anim::vek::Vec2::<u32>::from(TerrainChunk::RECT_SIZE),
|
||||
|d: f32, sz| d.abs() as f32 / sz as f32,
|
||||
|d: f32, sz| d.abs() / sz as f32,
|
||||
)
|
||||
.magnitude()
|
||||
/ view_distance as f32;
|
||||
|
@ -662,7 +662,7 @@ impl Scene {
|
||||
.filter(|(pos, _, light_anim, h)| {
|
||||
light_anim.col != Rgb::zero()
|
||||
&& light_anim.strength > 0.0
|
||||
&& (pos.0.distance_squared(viewpoint_pos) as f32)
|
||||
&& pos.0.distance_squared(viewpoint_pos)
|
||||
< loaded_distance.powi(2) + LIGHT_DIST_RADIUS
|
||||
&& h.map_or(true, |h| !h.is_dead)
|
||||
})
|
||||
@ -702,7 +702,7 @@ impl Scene {
|
||||
.join()
|
||||
.filter(|(_, _, _, _, health)| !health.is_dead)
|
||||
.filter(|(pos, _, _, _, _)| {
|
||||
(pos.0.distance_squared(viewpoint_pos) as f32)
|
||||
pos.0.distance_squared(viewpoint_pos)
|
||||
< (loaded_distance.min(SHADOW_MAX_DIST) + SHADOW_DIST_RADIUS).powi(2)
|
||||
})
|
||||
.map(|(pos, interpolated, scale, _, _)| {
|
||||
@ -777,7 +777,7 @@ impl Scene {
|
||||
self.last_lightning.unwrap_or((Vec3::zero(), -1000.0)),
|
||||
scene_data.ambiance,
|
||||
self.camera.get_mode(),
|
||||
scene_data.sprite_render_distance as f32 - 20.0,
|
||||
scene_data.sprite_render_distance - 20.0,
|
||||
)]);
|
||||
renderer.update_clouds_locals(CloudsLocals::new(proj_mat_inv, view_mat_inv));
|
||||
renderer.update_postprocess_locals(PostProcessLocals::new(proj_mat_inv, view_mat_inv));
|
||||
|
@ -1400,7 +1400,7 @@ impl ParticleMgr {
|
||||
dry_chance,
|
||||
});
|
||||
}
|
||||
let avg_particles = dt * sum as f32 * rate;
|
||||
let avg_particles = dt * sum * rate;
|
||||
|
||||
let particle_count = avg_particles.trunc() as usize
|
||||
+ (rng.gen::<f32>() < avg_particles.fract()) as usize;
|
||||
|
@ -18,8 +18,8 @@ pub struct EguiState {
|
||||
impl EguiState {
|
||||
pub fn new(window: &Window) -> Self {
|
||||
let platform = Platform::new(PlatformDescriptor {
|
||||
physical_width: window.window().inner_size().width as u32,
|
||||
physical_height: window.window().inner_size().height as u32,
|
||||
physical_width: window.window().inner_size().width,
|
||||
physical_height: window.window().inner_size().height,
|
||||
scale_factor: window.scale_factor(),
|
||||
font_definitions: FontDefinitions::default(),
|
||||
style: Default::default(),
|
||||
|
@ -252,12 +252,12 @@ impl IcedRenderer {
|
||||
let pixel_coords = vertex_data.pixel_coords;
|
||||
let rect = Aabr {
|
||||
min: Vec2::new(
|
||||
pixel_coords.min.x as f32 / half_res.x - 1.0,
|
||||
1.0 - pixel_coords.max.y as f32 / half_res.y,
|
||||
pixel_coords.min.x / half_res.x - 1.0,
|
||||
1.0 - pixel_coords.max.y / half_res.y,
|
||||
),
|
||||
max: Vec2::new(
|
||||
pixel_coords.max.x as f32 / half_res.x - 1.0,
|
||||
1.0 - pixel_coords.min.y as f32 / half_res.y,
|
||||
pixel_coords.max.x / half_res.x - 1.0,
|
||||
1.0 - pixel_coords.min.y / half_res.y,
|
||||
),
|
||||
};
|
||||
(uv, rect)
|
||||
@ -500,8 +500,8 @@ impl IcedRenderer {
|
||||
t / image_h as f32, /* * ratio_y */
|
||||
),
|
||||
Extent2::new(
|
||||
gl_size.w as f32 * ratio_x,
|
||||
gl_size.h as f32 * ratio_y,
|
||||
gl_size.w * ratio_x,
|
||||
gl_size.h * ratio_y,
|
||||
),
|
||||
))
|
||||
/* ((l / image_w as f32),
|
||||
|
@ -47,7 +47,7 @@ impl slider::Renderer for IcedRenderer {
|
||||
let (cursor_width, cursor_height) = style.cursor_size;
|
||||
let (cursor_width, cursor_height) = (f32::from(cursor_width), f32::from(cursor_height));
|
||||
let (min, max) = range.into_inner();
|
||||
let offset = bounds.width as f32 * (value - min) / (max - min);
|
||||
let offset = bounds.width * (value - min) / (max - min);
|
||||
let cursor_bounds = Rectangle {
|
||||
x: bounds.x + offset - cursor_width / 2.0,
|
||||
y: bounds.y
|
||||
|
@ -103,7 +103,7 @@ where
|
||||
// We need to figure out the max width/height of the limits
|
||||
// and then adjust one down to meet the aspect ratio
|
||||
let max_size = limits.max();
|
||||
let (max_width, max_height) = (max_size.width as f32, max_size.height as f32);
|
||||
let (max_width, max_height) = (max_size.width, max_size.height);
|
||||
let max_aspect_ratio = max_width / max_height;
|
||||
let limits = if max_aspect_ratio > aspect_ratio {
|
||||
limits.max_width((max_height * aspect_ratio) as u32)
|
||||
|
@ -183,7 +183,7 @@ where
|
||||
// To do this we need to figure out the max width/height of the limits
|
||||
// and then adjust one down to meet the aspect ratio
|
||||
let max_size = limits.max();
|
||||
let (max_width, max_height) = (max_size.width as f32, max_size.height as f32);
|
||||
let (max_width, max_height) = (max_size.width, max_size.height);
|
||||
let max_aspect_ratio = max_width / max_height;
|
||||
let limits = if max_aspect_ratio > aspect_ratio {
|
||||
limits.max_width((max_height * aspect_ratio) as u32)
|
||||
@ -213,7 +213,7 @@ where
|
||||
// space for padding because the available space can only increase)
|
||||
content_size.width /= 1.0 - horizontal_pad_frac;
|
||||
content_size.height /= 1.0 - vertical_pad_frac;
|
||||
let content_aspect_ratio = content_size.width as f32 / content_size.height as f32;
|
||||
let content_aspect_ratio = content_size.width / content_size.height;
|
||||
let size = if content_aspect_ratio > aspect_ratio {
|
||||
Size::new(content_size.width, content_size.width / aspect_ratio)
|
||||
} else {
|
||||
|
@ -609,8 +609,8 @@ impl Ui {
|
||||
tracing::debug!("Updating glyphs and clearing text cache.");
|
||||
|
||||
if let Err(err) = glyph_cache.cache_queued(|rect, data| {
|
||||
let offset = [rect.min.x as u32, rect.min.y as u32];
|
||||
let size = [rect.width() as u32, rect.height() as u32];
|
||||
let offset = [rect.min.x, rect.min.y];
|
||||
let size = [rect.width(), rect.height()];
|
||||
|
||||
let new_data = data
|
||||
.iter()
|
||||
|
@ -568,7 +568,7 @@ impl Window {
|
||||
// size
|
||||
let winit::dpi::PhysicalSize { width, height } = physical;
|
||||
self.events
|
||||
.push(Event::Resize(Vec2::new(width as u32, height as u32)));
|
||||
.push(Event::Resize(Vec2::new(width, height)));
|
||||
|
||||
// Emit event for the UI
|
||||
let logical_size = Vec2::from(Into::<(f64, f64)>::into(
|
||||
|
@ -168,7 +168,7 @@ impl<'a> Canvas<'a> {
|
||||
) {
|
||||
let chunk_aabr = Aabr {
|
||||
min: self.wpos(),
|
||||
max: self.wpos() + Vec2::from(self.area().size().map(|e| e as i32)),
|
||||
max: self.wpos() + Vec2::from(self.area().size().map(|e| e)),
|
||||
};
|
||||
|
||||
for y in chunk_aabr.min.y.max(aabr.min.y)..chunk_aabr.max.y.min(aabr.max.y) {
|
||||
|
@ -265,7 +265,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let lake_width_noise = sim
|
||||
.gen_ctx
|
||||
.small_nz
|
||||
.get((wposf.map(|e| e as f64).div(32.0)).into_array());
|
||||
.get((wposf.map(|e| e).div(32.0)).into_array());
|
||||
let water_aabr = Aabr {
|
||||
min: water_chunk * neighbor_coef + 4.0 - lake_width_noise * 8.0,
|
||||
max: (water_chunk + 1.0) * neighbor_coef - 4.0
|
||||
@ -316,7 +316,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let lake_width_noise = sim
|
||||
.gen_ctx
|
||||
.small_nz
|
||||
.get((wposf.map(|e| e as f64).div(32.0)).into_array());
|
||||
.get((wposf.map(|e| e).div(32.0)).into_array());
|
||||
let water_aabr = Aabr {
|
||||
min: water_chunk * neighbor_coef + 4.0 - lake_width_noise * 8.0,
|
||||
max: (water_chunk + 1.0) * neighbor_coef - 4.0 + lake_width_noise * 8.0,
|
||||
@ -350,7 +350,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
.max(-1.0)
|
||||
.min(1.0)
|
||||
.mul(0.5)
|
||||
.sub(0.5) as f64;
|
||||
.sub(0.5);
|
||||
let river_width = Lerp::lerp(
|
||||
river_width_min,
|
||||
river_width_max,
|
||||
@ -694,7 +694,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
river_t as f32,
|
||||
is_waterfall(river_chunk_idx, river_chunk, downhill_chunk),
|
||||
);
|
||||
Some((river_water_alt, cross_section.y as f32, None))
|
||||
Some((river_water_alt, cross_section.y, None))
|
||||
},
|
||||
RiverKind::Lake { .. } | RiverKind::Ocean => {
|
||||
let lake_water_alt = if matches!(kind, RiverKind::Ocean) {
|
||||
@ -780,7 +780,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
||||
let weight = Lerp::lerp(
|
||||
BANK_STRENGTH
|
||||
/ (1.0
|
||||
+ (river_edge_dist as f32 - 3.0).max(0.0) * BANK_STRENGTH
|
||||
+ (river_edge_dist - 3.0).max(0.0) * BANK_STRENGTH
|
||||
/ BANK_SCALE),
|
||||
0.0,
|
||||
power((river_edge_dist / BANK_SCALE).clamped(0.0, 1.0) as f64, 2.0)
|
||||
|
@ -47,7 +47,7 @@ fn node_at(cell: Vec2<i32>, level: u32, land: &Land) -> Option<Node> {
|
||||
let dx = RandomField::new(38 + level);
|
||||
let dy = RandomField::new(39 + level);
|
||||
let wpos = to_wpos(cell, level)
|
||||
+ CELL_SIZE as i32 / 4
|
||||
+ CELL_SIZE / 4
|
||||
+ (Vec2::new(dx.get(cell.with_z(0)), dy.get(cell.with_z(0))) % CELL_SIZE as u32 / 2)
|
||||
.map(|e| e as i32);
|
||||
land.get_chunk_wpos(wpos).and_then(|chunk| {
|
||||
@ -187,7 +187,7 @@ impl Tunnel {
|
||||
.mul(0.5)
|
||||
.add(0.5) as f32;
|
||||
|
||||
let underground = ((col.alt as f32 - wpos.z as f32) / 80.0 - 1.0).clamped(0.0, 1.0);
|
||||
let underground = ((col.alt - wpos.z as f32) / 80.0 - 1.0).clamped(0.0, 1.0);
|
||||
|
||||
let [barren, mushroom, fire, leafy, dusty, icy] = {
|
||||
let barren = 0.01;
|
||||
@ -228,7 +228,7 @@ fn tunnels_at<'a>(
|
||||
land: &'a Land,
|
||||
) -> impl Iterator<Item = Tunnel> + 'a {
|
||||
let rand = RandomField::new(37 + level);
|
||||
let col_cell = to_cell(wpos - CELL_SIZE as i32 / 4, level);
|
||||
let col_cell = to_cell(wpos - CELL_SIZE / 4, level);
|
||||
LOCALITY
|
||||
.into_iter()
|
||||
.filter_map(move |rpos| {
|
||||
@ -272,7 +272,7 @@ fn tunnel_below_from_cell(cell: Vec2<i32>, level: u32, land: &Land) -> Option<Tu
|
||||
Some(Tunnel {
|
||||
a: node_at(to_cell(wpos, level), level, land)?,
|
||||
b: node_at(
|
||||
to_cell(wpos + CELL_SIZE as i32 / 2, level + 1),
|
||||
to_cell(wpos + CELL_SIZE / 2, level + 1),
|
||||
level + 1,
|
||||
land,
|
||||
)?,
|
||||
@ -495,15 +495,15 @@ fn write_column<R: Rng>(
|
||||
let warp_amp = Vec3::new(12.0, 12.0, 12.0);
|
||||
let wposf_warped = wposf.map(|e| e as f32)
|
||||
+ Vec3::new(
|
||||
FastNoise::new(seed).get(wposf * warp_freq) as f32,
|
||||
FastNoise::new(seed + 1).get(wposf * warp_freq) as f32,
|
||||
FastNoise::new(seed + 2).get(wposf * warp_freq) as f32,
|
||||
FastNoise::new(seed).get(wposf * warp_freq),
|
||||
FastNoise::new(seed + 1).get(wposf * warp_freq),
|
||||
FastNoise::new(seed + 2).get(wposf * warp_freq),
|
||||
) * warp_amp
|
||||
* (wposf.z as f32 - mushroom.pos.z as f32)
|
||||
.mul(0.1)
|
||||
.clamped(0.0, 1.0);
|
||||
|
||||
let rpos = wposf_warped - mushroom.pos.map(|e| e as f32).map(|e| e as f32);
|
||||
let rpos = wposf_warped - mushroom.pos.map(|e| e as f32).map(|e| e);
|
||||
|
||||
let stalk_radius = 2.5f32;
|
||||
let head_radius = 12.0f32;
|
||||
|
@ -278,7 +278,7 @@ pub fn apply_caves_to(canvas: &mut Canvas, rng: &mut impl Rng) {
|
||||
let ridge_condition = cave_depth % 10.0 > 8.0 && cave_depth > 10.0;
|
||||
let pit_condition = cave_depth % 42.0 > 37.0 && cave_x > 0.6 && cave_depth > 200.0;
|
||||
let pit_depth = 30;
|
||||
let floor_dist = pit_condition as i32 * pit_depth as i32;
|
||||
let floor_dist = pit_condition as i32 * pit_depth;
|
||||
let vein_condition =
|
||||
cave_depth % 12.0 > 11.5 && cave_x > 0.1 && cave_x < 0.6 && cave_depth > 200.0;
|
||||
let stalactite_condition = cave_depth > 150.0;
|
||||
@ -617,7 +617,7 @@ pub fn apply_caves_supplement<'a>(
|
||||
})
|
||||
}) {
|
||||
if RandomField::new(index.seed).chance(wpos2d.into(), 0.0014)
|
||||
&& cave_base < surface_z as i32 - 40
|
||||
&& cave_base < surface_z - 40
|
||||
{
|
||||
let entity = EntityInfo::at(wpos2d.map(|e| e as f32).with_z(z as f32));
|
||||
let entity = {
|
||||
@ -831,7 +831,7 @@ pub fn apply_caverns_to<R: Rng>(canvas: &mut Canvas, dynamic_rng: &mut R) {
|
||||
cavern_avg_top,
|
||||
floor,
|
||||
stalactite,
|
||||
cavern_avg_bottom as i32 + 16, // Water level
|
||||
cavern_avg_bottom + 16, // Water level
|
||||
)
|
||||
};
|
||||
|
||||
@ -854,7 +854,7 @@ pub fn apply_caverns_to<R: Rng>(canvas: &mut Canvas, dynamic_rng: &mut R) {
|
||||
let pos = wpos2d.with_z(cavern_bottom + floor);
|
||||
if rng.gen_bool(0.15)
|
||||
&& cavern_top - cavern_bottom > 32
|
||||
&& pos.z as i32 > water_level - 2
|
||||
&& pos.z > water_level - 2
|
||||
{
|
||||
Some(Mushroom {
|
||||
pos,
|
||||
@ -879,15 +879,15 @@ pub fn apply_caverns_to<R: Rng>(canvas: &mut Canvas, dynamic_rng: &mut R) {
|
||||
let warp_amp = Vec3::new(12.0, 12.0, 12.0);
|
||||
let wposf_warped = wposf.map(|e| e as f32)
|
||||
+ Vec3::new(
|
||||
FastNoise::new(seed).get(wposf * warp_freq) as f32,
|
||||
FastNoise::new(seed + 1).get(wposf * warp_freq) as f32,
|
||||
FastNoise::new(seed + 2).get(wposf * warp_freq) as f32,
|
||||
FastNoise::new(seed).get(wposf * warp_freq),
|
||||
FastNoise::new(seed + 1).get(wposf * warp_freq),
|
||||
FastNoise::new(seed + 2).get(wposf * warp_freq),
|
||||
) * warp_amp
|
||||
* (wposf.z as f32 - mushroom.pos.z as f32)
|
||||
.mul(0.1)
|
||||
.clamped(0.0, 1.0);
|
||||
|
||||
let rpos = wposf_warped - mushroom.pos.map(|e| e as f32).map(|e| e as f32);
|
||||
let rpos = wposf_warped - mushroom.pos.map(|e| e as f32).map(|e| e);
|
||||
|
||||
let stalk_radius = 2.5f32;
|
||||
let head_radius = 18.0f32;
|
||||
@ -1036,7 +1036,7 @@ pub fn apply_caverns_to<R: Rng>(canvas: &mut Canvas, dynamic_rng: &mut R) {
|
||||
}
|
||||
};
|
||||
|
||||
let cavern_top = cavern_top as i32;
|
||||
let cavern_top = cavern_top;
|
||||
let mut last_kind = BlockKind::Rock;
|
||||
for z in cavern_bottom - 1..cavern_top {
|
||||
use SpriteKind::*;
|
||||
|
@ -1054,7 +1054,7 @@ impl Branch {
|
||||
let rpos = pos.xy() - p;
|
||||
let stretch = 32.0;
|
||||
let stair_section =
|
||||
((rpos.x as f32).atan2(rpos.y as f32) / (f32::consts::PI * 2.0) * stretch
|
||||
(rpos.x.atan2(rpos.y) / (f32::consts::PI * 2.0) * stretch
|
||||
+ pos.z)
|
||||
.rem_euclid(stretch);
|
||||
(
|
||||
|
@ -109,7 +109,7 @@ pub fn diffusion(
|
||||
for i in 0..nx {
|
||||
// ij = vec2_as_uniform_idx(i, j);
|
||||
ij = aij(i, j);
|
||||
zint[ij] = h[ij] as f64;
|
||||
zint[ij] = h[ij];
|
||||
kdint[ij] = kd(ij);
|
||||
if kdsed > 0.0 && (h[ij] - b[ij]) > 1.0e-6 {
|
||||
kdint[ij] = kdsed;
|
||||
|
@ -564,7 +564,7 @@ fn get_max_slope(
|
||||
let wposf = uniform_idx_as_vec2(map_size_lg, posi).map(|e| e as f64)
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
let height_scale = height_scale(posi);
|
||||
let wposz = z as f64 / height_scale as f64;
|
||||
let wposz = z / height_scale;
|
||||
// Normalized to be between 6 and and 54 degrees.
|
||||
let div_factor = (2.0 * TerrainChunkSize::RECT_SIZE.x as f64) / 8.0;
|
||||
let rock_strength = rock_strength_nz.get([wposf.x, wposf.y, wposz * div_factor]);
|
||||
@ -878,7 +878,7 @@ fn erode(
|
||||
k_tot
|
||||
} else {
|
||||
let old_b_i = b[posi];
|
||||
let sed = (h_t[posi] - old_b_i) as f64;
|
||||
let sed = h_t[posi] - old_b_i;
|
||||
let n = n_f(posi);
|
||||
// Higher rock strength tends to lead to higher erodibility?
|
||||
let kd_factor = 1.0;
|
||||
@ -901,9 +901,9 @@ fn erode(
|
||||
.map(|e| e as f64);
|
||||
let neighbor_distance = (neighbor_coef * dxy).magnitude();
|
||||
let knew = (k
|
||||
* (p as f64
|
||||
* (p
|
||||
* chunk_area
|
||||
* (area[posi] as f64 * mwrec_i[kk] as f64))
|
||||
* (area[posi] * mwrec_i[kk]))
|
||||
.powf(m)
|
||||
/ neighbor_distance.powf(n))
|
||||
as SimdType;
|
||||
@ -925,12 +925,12 @@ fn erode(
|
||||
// Egress with no outgoing flows, no stream power.
|
||||
k_tot
|
||||
} else {
|
||||
let area_i = area[posi] as f64;
|
||||
let area_i = area[posi];
|
||||
let max_slope = max_slopes[posi];
|
||||
let chunk_area_pow = chunk_area.powf(q);
|
||||
|
||||
let old_b_i = b[posi];
|
||||
let sed = (h_t[posi] - old_b_i) as f64;
|
||||
let sed = h_t[posi] - old_b_i;
|
||||
let n = n_f(posi);
|
||||
let g_i = if sed > sediment_thickness(n) {
|
||||
// Sediment
|
||||
@ -946,7 +946,7 @@ fn erode(
|
||||
|
||||
let mwrec_i = &mwrec[posi];
|
||||
mrec_downhill(map_size_lg, &mrec, posi).for_each(|(kk, posj)| {
|
||||
let mwrec_kk = mwrec_i[kk] as f64;
|
||||
let mwrec_kk = mwrec_i[kk];
|
||||
|
||||
#[rustfmt::skip]
|
||||
// Working equation:
|
||||
@ -988,7 +988,7 @@ fn erode(
|
||||
// (eliminating EΔt maintains the sign, but it's somewhat imprecise;
|
||||
// we can address this later, e.g. by assigning a debris flow / fluvial erosion ratio).
|
||||
let chunk_neutral_area = 0.1e6; // 1 km^2 * (1000 m / km)^2 = 1e6 m^2
|
||||
let k = (mwrec_kk * (uplift_i + max_uplift as f64 * g_i / p as f64))
|
||||
let k = (mwrec_kk * (uplift_i + max_uplift as f64 * g_i / p))
|
||||
/ (1.0 + k_da * (mwrec_kk * chunk_neutral_area).powf(q))
|
||||
/ max_slope.powf(q_);
|
||||
let dxy = (uniform_idx_as_vec2(map_size_lg, posi)
|
||||
@ -1201,7 +1201,7 @@ fn erode(
|
||||
let area_i = area_i as Compute;
|
||||
let uphill_silt_i = deltah_i - (old_h_after_uplift_i - h_p_i);
|
||||
let old_b_i = b_i;
|
||||
let sed = (h_t_i - old_b_i) as f64;
|
||||
let sed = h_t_i - old_b_i;
|
||||
let n = n_f(posi);
|
||||
let g_i = if sed > sediment_thickness(n) {
|
||||
(g_fs_mult_sed * g(posi)) as Compute
|
||||
@ -1243,10 +1243,10 @@ fn erode(
|
||||
.for_each(|(stacki, (&posi, &elev_i, &b_i, &h_t_i, &dh_i, &h_p_i))| {
|
||||
let iteration_error = 0.0;
|
||||
let posi = posi as usize;
|
||||
let old_elev_i = elev_i as f64;
|
||||
let old_elev_i = elev_i;
|
||||
let old_b_i = b_i;
|
||||
let old_ht_i = h_t_i;
|
||||
let sed = (old_ht_i - old_b_i) as f64;
|
||||
let sed = old_ht_i - old_b_i;
|
||||
|
||||
let posj = dh_i;
|
||||
if posj < 0 {
|
||||
@ -1272,8 +1272,8 @@ fn erode(
|
||||
// it's downhill from us. Therefore, we can rely on wh being
|
||||
// set to the water height for that node.
|
||||
// let h_j = h[posj_stack] as f64;
|
||||
let wh_j = wh[posj] as f64;
|
||||
let old_h_i = h_stack[stacki] as f64;
|
||||
let wh_j = wh[posj];
|
||||
let old_h_i = h_stack[stacki];
|
||||
let mut new_h_i = old_h_i;
|
||||
|
||||
// Only perform erosion if we are above the water level of the previous node.
|
||||
@ -1298,7 +1298,7 @@ fn erode(
|
||||
let mut df = 1.0;
|
||||
mrec_downhill(map_size_lg, &mrec, posi).for_each(|(kk, posj)| {
|
||||
let posj_stack = mstack_inv[posj];
|
||||
let h_j = h_stack[posj_stack] as f64;
|
||||
let h_j = h_stack[posj_stack];
|
||||
// This can happen in cases where receiver kk is neither uphill of
|
||||
// nor downhill from posi's direct receiver.
|
||||
// NOTE: Fastscape does h_t[posi] + uplift(posi) as f64 >= h_t[posj]
|
||||
@ -1328,7 +1328,7 @@ fn erode(
|
||||
// NOTE: Fastscape does h_t[posi] + uplift(posi) as f64 >= h_t[posj]
|
||||
// + uplift(posj) as f64
|
||||
// NOTE: We also considered using old_elev_i > wh[posj] here.
|
||||
if old_elev_i > h_j as f64 {
|
||||
if old_elev_i > h_j {
|
||||
mask[kk] = MaskType::new(true);
|
||||
rec_heights[kk] = h_j as SimdType;
|
||||
}
|
||||
@ -1499,7 +1499,7 @@ fn erode(
|
||||
// account for this, such as averaging, integrating, or doing things
|
||||
// by mass / volume instead of height, but for now we use the time-honored
|
||||
// technique of ignoring the problem.
|
||||
let vertical_sed = (h_i - new_b_i).max(0.0) as f64;
|
||||
let vertical_sed = (h_i - new_b_i).max(0.0);
|
||||
let h_normal = if posj < 0 {
|
||||
// Egress with no outgoing flows; for now, we assume this means normal and
|
||||
// vertical coincide.
|
||||
@ -1511,7 +1511,7 @@ fn erode(
|
||||
- uniform_idx_as_vec2(map_size_lg, posj))
|
||||
.map(|e| e as f64);
|
||||
let neighbor_distance_squared = (neighbor_coef * dxy).magnitude_squared();
|
||||
let dh = (h_i - h_j) as f64;
|
||||
let dh = h_i - h_j;
|
||||
// H_i_fact = (h_i - h_j) / (||p_i - p_j||^2 + (h_i - h_j)^2)
|
||||
let h_i_fact = dh / (neighbor_distance_squared + dh * dh);
|
||||
let h_i_vertical = 1.0 - h_i_fact * dh;
|
||||
@ -1598,9 +1598,9 @@ fn erode(
|
||||
prodscrit_therm = 0.0;
|
||||
newh.iter().for_each(|&posi| {
|
||||
let posi = posi as usize;
|
||||
let old_h_i = h[posi] as f64;
|
||||
let old_b_i = b[posi] as f64;
|
||||
let sed = (old_h_i - old_b_i) as f64;
|
||||
let old_h_i = h[posi];
|
||||
let old_b_i = b[posi];
|
||||
let sed = old_h_i - old_b_i;
|
||||
|
||||
let max_slope = max_slopes[posi];
|
||||
let n = n_f(posi);
|
||||
@ -1624,14 +1624,14 @@ fn erode(
|
||||
let posj = posj as usize;
|
||||
// Find the water height for this chunk's receiver; we only apply thermal
|
||||
// erosion for chunks above water.
|
||||
let wh_j = wh[posj] as f64;
|
||||
let wh_j = wh[posj];
|
||||
let mut new_h_i = old_h_i;
|
||||
if wh_j < old_h_i {
|
||||
// NOTE: Currently assuming that talus angle is not eroded once the substance is
|
||||
// totally submerged in water, and that talus angle if part of the substance is
|
||||
// in water is 0 (or the same as the dry part, if this is set to wh_j), but
|
||||
// actually that's probably not true.
|
||||
let old_h_j = h[posj] as f64;
|
||||
let old_h_j = h[posj];
|
||||
let h_j = old_h_j;
|
||||
// Test the slope.
|
||||
// Hacky version of thermal erosion: only consider lowest neighbor, don't
|
||||
@ -1887,7 +1887,7 @@ pub fn get_lakes<F: Float>(
|
||||
newh.push(chunk_idx as u32);
|
||||
let mut cur = start;
|
||||
while cur < newh.len() {
|
||||
let node = newh[cur as usize];
|
||||
let node = newh[cur];
|
||||
uphill(map_size_lg, downhill, node as usize).for_each(|child| {
|
||||
// lake_idx is the index of our lake root.
|
||||
indirection[child] = chunk_idx as i32;
|
||||
@ -1982,13 +1982,13 @@ pub fn get_lakes<F: Float>(
|
||||
let lake_chunk_idx = if indirection_idx >= 0 {
|
||||
indirection_idx as usize
|
||||
} else {
|
||||
chunk_idx as usize
|
||||
chunk_idx
|
||||
};
|
||||
let indirection_idx = indirection[neighbor_idx];
|
||||
let neighbor_lake_chunk_idx = if indirection_idx >= 0 {
|
||||
indirection_idx as usize
|
||||
} else {
|
||||
neighbor_idx as usize
|
||||
neighbor_idx
|
||||
};
|
||||
panic!(
|
||||
"For edge {:?} between lakes {:?}, couldn't find partner for pass \
|
||||
@ -1996,24 +1996,24 @@ pub fn get_lakes<F: Float>(
|
||||
(
|
||||
(
|
||||
chunk_idx,
|
||||
uniform_idx_as_vec2(map_size_lg, chunk_idx as usize)
|
||||
uniform_idx_as_vec2(map_size_lg, chunk_idx)
|
||||
),
|
||||
(
|
||||
neighbor_idx,
|
||||
uniform_idx_as_vec2(map_size_lg, neighbor_idx as usize)
|
||||
uniform_idx_as_vec2(map_size_lg, neighbor_idx)
|
||||
)
|
||||
),
|
||||
(
|
||||
(
|
||||
lake_chunk_idx,
|
||||
uniform_idx_as_vec2(map_size_lg, lake_chunk_idx as usize),
|
||||
uniform_idx_as_vec2(map_size_lg, lake_chunk_idx),
|
||||
lake_idx_
|
||||
),
|
||||
(
|
||||
neighbor_lake_chunk_idx,
|
||||
uniform_idx_as_vec2(
|
||||
map_size_lg,
|
||||
neighbor_lake_chunk_idx as usize
|
||||
neighbor_lake_chunk_idx
|
||||
),
|
||||
neighbor_lake_idx_
|
||||
)
|
||||
@ -2116,7 +2116,7 @@ pub fn get_lakes<F: Float>(
|
||||
pass_flows_sorted.push(lake_chunk_idx);
|
||||
// pass_flows_sorted.push((chunk_idx as u32, neighbor_idx as u32));
|
||||
for edge in &mut lakes[lake_idx..lake_idx + max_len] {
|
||||
if *edge == (chunk_idx as i32, neighbor_idx as u32) {
|
||||
if *edge == (chunk_idx as i32, neighbor_idx) {
|
||||
// Skip deleting this edge.
|
||||
continue;
|
||||
}
|
||||
@ -2284,7 +2284,7 @@ pub fn get_lakes<F: Float>(
|
||||
let mut cur = start;
|
||||
let mut node = first_idx;
|
||||
loop {
|
||||
uphill(map_size_lg, downhill, node as usize).for_each(|child| {
|
||||
uphill(map_size_lg, downhill, node).for_each(|child| {
|
||||
// lake_idx is the index of our lake root.
|
||||
// Check to make sure child (flowing into us) is in the same lake.
|
||||
if indirection[child] == chunk_idx as i32 || child == chunk_idx {
|
||||
@ -2318,7 +2318,7 @@ pub fn mrec_downhill(
|
||||
.map(move |(k, &(x, y))| {
|
||||
(
|
||||
k,
|
||||
vec2_as_uniform_idx(map_size_lg, Vec2::new(pos.x + x as i32, pos.y + y as i32)),
|
||||
vec2_as_uniform_idx(map_size_lg, Vec2::new(pos.x + x, pos.y + y)),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ pub fn sample_wpos(config: &MapConfig, sampler: &WorldSim, wpos: Vec2<i32>) -> f
|
||||
})
|
||||
.unwrap_or(CONFIG.sea_level)
|
||||
- focus.z as f32)
|
||||
/ gain as f32
|
||||
/ gain
|
||||
}
|
||||
|
||||
/// Samples a MapSample at a chunk.
|
||||
@ -150,14 +150,14 @@ pub fn sample_pos(
|
||||
Lerp::lerp(
|
||||
sample.sub_surface_color,
|
||||
sample.stone_col.map(|e| e as f32 / 255.0),
|
||||
(alt - grass_depth - wposz as f32) * 0.15,
|
||||
(alt - grass_depth - wposz) * 0.15,
|
||||
)
|
||||
.map(|e| e as f64)
|
||||
} else {
|
||||
Lerp::lerp(
|
||||
sample.sub_surface_color,
|
||||
sample.surface_color,
|
||||
((wposz as f32 - (alt - grass_depth)) / grass_depth).sqrt(),
|
||||
((wposz - (alt - grass_depth)) / grass_depth).sqrt(),
|
||||
)
|
||||
.map(|e| e as f64)
|
||||
};
|
||||
|
@ -697,7 +697,7 @@ impl WorldSim {
|
||||
hill_nz: SuperSimplex::new().set_seed(rng.gen()),
|
||||
alt_nz: util::HybridMulti::new()
|
||||
.set_octaves(8)
|
||||
.set_frequency((10_000.0 / continent_scale) as f64)
|
||||
.set_frequency(10_000.0 / continent_scale)
|
||||
// persistence = lacunarity^(-(1.0 - fractal increment))
|
||||
.set_lacunarity(util::HybridMulti::DEFAULT_LACUNARITY)
|
||||
.set_persistence(util::HybridMulti::DEFAULT_LACUNARITY.powi(-1))
|
||||
@ -811,9 +811,9 @@ impl WorldSim {
|
||||
let logistic_cdf = |x: f64| (x / logistic_2_base).tanh() * 0.5 + 0.5;
|
||||
|
||||
let map_size_chunks_len_f64 = map_size_lg.chunks().map(f64::from).product();
|
||||
let min_epsilon = 1.0 / map_size_chunks_len_f64.max(f64::EPSILON as f64 * 0.5);
|
||||
let min_epsilon = 1.0 / map_size_chunks_len_f64.max(f64::EPSILON * 0.5);
|
||||
let max_epsilon =
|
||||
(1.0 - 1.0 / map_size_chunks_len_f64).min(1.0 - f64::EPSILON as f64 * 0.5);
|
||||
(1.0 - 1.0 / map_size_chunks_len_f64).min(1.0 - f64::EPSILON * 0.5);
|
||||
|
||||
// No NaNs in these uniform vectors, since the original noise value always
|
||||
// returns Some.
|
||||
@ -1042,7 +1042,7 @@ impl WorldSim {
|
||||
let theta_func = |_posi| 0.4;
|
||||
let kf_func = {
|
||||
|posi| {
|
||||
let kf_scale_i = k_fs_scale(theta_func(posi), n_func(posi)) as f64;
|
||||
let kf_scale_i = k_fs_scale(theta_func(posi), n_func(posi));
|
||||
if is_ocean_fn(posi) {
|
||||
return 1.0e-4 * kf_scale_i;
|
||||
}
|
||||
@ -1213,8 +1213,8 @@ impl WorldSim {
|
||||
if is_ocean_fn(posi) {
|
||||
return 0.0;
|
||||
}
|
||||
let height = (uplift_uniform[posi].1 - alt_old_min_uniform) as f64
|
||||
/ (alt_old_max_uniform - alt_old_min_uniform) as f64;
|
||||
let height = (uplift_uniform[posi].1 - alt_old_min_uniform)
|
||||
/ (alt_old_max_uniform - alt_old_min_uniform);
|
||||
|
||||
let height = height.mul(max_epsilon - min_epsilon).add(min_epsilon);
|
||||
let height = erosion_factor(height);
|
||||
@ -1225,8 +1225,8 @@ impl WorldSim {
|
||||
// u = 5e-4: normal (mid example in Yuan, average mountain uplift)
|
||||
// u = 2e-4: low (low example in Yuan; known that lagoons etc. may have u ~
|
||||
// 0.05). u = 0: low (plateau [fan, altitude = 0.0])
|
||||
let height = height.mul(max_erosion_per_delta_t);
|
||||
height as f64
|
||||
|
||||
height.mul(max_erosion_per_delta_t)
|
||||
};
|
||||
let alt_func = |posi| {
|
||||
if is_ocean_fn(posi) {
|
||||
|
@ -189,7 +189,7 @@ impl Economy {
|
||||
.map(|(g, a)| {
|
||||
(
|
||||
Good::from(g),
|
||||
((*a) as f32) * self.natural_resources.average_yield_per_chunk[g],
|
||||
(*a) * self.natural_resources.average_yield_per_chunk[g],
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
|
@ -232,8 +232,8 @@ impl Settlement {
|
||||
let river_offs = Vec2::new(rng.gen_range(-3..4), rng.gen_range(-3..4));
|
||||
|
||||
for x in (0..100).map(|e| e as f32 / 100.0) {
|
||||
let theta0 = x as f32 * f32::consts::PI * 2.0;
|
||||
let theta1 = (x + 0.01) as f32 * f32::consts::PI * 2.0;
|
||||
let theta0 = x * f32::consts::PI * 2.0;
|
||||
let theta1 = (x + 0.01) * f32::consts::PI * 2.0;
|
||||
|
||||
let pos0 = (river_dir * radius + Vec2::new(theta0.sin(), theta0.cos()) * radius)
|
||||
.map(|e| e.floor() as i32)
|
||||
|
@ -362,14 +362,14 @@ impl Fill {
|
||||
.as_()
|
||||
.distance_squared(segment_2d.end.as_());
|
||||
if len_sq < 0.1 {
|
||||
segment.start.z as f32
|
||||
segment.start.z
|
||||
} else {
|
||||
let frac = ((projected_point_2d - segment_2d.start.as_())
|
||||
.dot(segment_2d.end.as_() - segment_2d.start.as_())
|
||||
/ len_sq)
|
||||
.clamp(0.0, 1.0);
|
||||
(segment.end.z as f32 - segment.start.z as f32) * frac
|
||||
+ segment.start.z as f32
|
||||
(segment.end.z - segment.start.z) * frac
|
||||
+ segment.start.z
|
||||
}
|
||||
};
|
||||
let z_check = (projected_z..=(projected_z + height)).contains(&(pos.z as f32));
|
||||
|
@ -88,7 +88,7 @@ impl Site {
|
||||
}
|
||||
})
|
||||
.min_by_key(|d2| *d2 as i32)
|
||||
.map(|d2| d2.sqrt() as f32 / TILE_SIZE as f32)
|
||||
.map(|d2| d2.sqrt() / TILE_SIZE as f32)
|
||||
.unwrap_or(1.0);
|
||||
let base_spawn_rules = SpawnRules {
|
||||
trees: max_warp == 1.0,
|
||||
|
@ -305,11 +305,11 @@ impl Structure for Castle {
|
||||
for i in 1..5 {
|
||||
painter.fill(
|
||||
painter.prim(Primitive::Aabb(Aabb {
|
||||
min: Vec3::new(gate_aabb.min.x + 2 + i, gate_aabb.min.y, height + i as i32),
|
||||
min: Vec3::new(gate_aabb.min.x + 2 + i, gate_aabb.min.y, height + i),
|
||||
max: Vec3::new(
|
||||
gate_aabb.max.x - 2 - i,
|
||||
gate_aabb.max.y,
|
||||
height + i as i32 + 1,
|
||||
height + i + 1,
|
||||
),
|
||||
})),
|
||||
Fill::Block(Block::empty()),
|
||||
|
@ -816,8 +816,8 @@ impl Structure for DesertCityMultiPlot {
|
||||
// stairway
|
||||
let stair_radius = tower.length + 1;
|
||||
let stairs_clear = painter.aabb(Aabb {
|
||||
min: (tower_center - stair_radius as i32).with_z(base),
|
||||
max: (tower_center + stair_radius as i32).with_z(base + tower.height + 2),
|
||||
min: (tower_center - stair_radius).with_z(base),
|
||||
max: (tower_center + stair_radius).with_z(base + tower.height + 2),
|
||||
});
|
||||
stairs_clear
|
||||
.sample(spiral_staircase(
|
||||
@ -1943,8 +1943,8 @@ impl Structure for DesertCityMultiPlot {
|
||||
// stairway
|
||||
let stair_radius = tower_length + 1;
|
||||
let stairs_clear = painter.aabb(Aabb {
|
||||
min: (bldg_a_center - stair_radius as i32).with_z(base),
|
||||
max: (bldg_a_center + stair_radius as i32)
|
||||
min: (bldg_a_center - stair_radius).with_z(base),
|
||||
max: (bldg_a_center + stair_radius)
|
||||
.with_z(base + tower_height + 2),
|
||||
});
|
||||
stairs_clear
|
||||
@ -2164,8 +2164,8 @@ impl Structure for DesertCityMultiPlot {
|
||||
// stairway
|
||||
let stair_radius = tower.length + 1;
|
||||
let stairs_clear = painter.aabb(Aabb {
|
||||
min: (subplot_center - stair_radius as i32).with_z(base),
|
||||
max: (subplot_center + stair_radius as i32)
|
||||
min: (subplot_center - stair_radius).with_z(base),
|
||||
max: (subplot_center + stair_radius)
|
||||
.with_z(base + tower.height + 2),
|
||||
});
|
||||
stairs_clear
|
||||
|
@ -142,7 +142,7 @@ impl Dungeon {
|
||||
};
|
||||
|
||||
// Add waypoint
|
||||
let pos = self.origin.map2(FLOOR_SIZE, |e, sz| e + sz as i32 / 2);
|
||||
let pos = self.origin.map2(FLOOR_SIZE, |e, sz| e + sz / 2);
|
||||
if area.contains_point(pos - self.origin) {
|
||||
supplement.add_entity(
|
||||
EntityInfo::at(Vec3::new(pos.x as f32, pos.y as f32, self.alt as f32) + 5.0)
|
||||
|
@ -2002,7 +2002,7 @@ impl Tunnels {
|
||||
&squared_euclidean,
|
||||
)
|
||||
.ok()?
|
||||
.1 as usize;
|
||||
.1;
|
||||
let nearest = nodes[nearest_index];
|
||||
let dist_sqrd = sampled_point.distance_squared(nearest);
|
||||
let new_point = if dist_sqrd > radius_sqrd {
|
||||
@ -2030,7 +2030,7 @@ impl Tunnels {
|
||||
let nearest_index = *kdtree
|
||||
.nearest_one(&[endf.x, endf.y, endf.z], &squared_euclidean)
|
||||
.ok()?
|
||||
.1 as usize;
|
||||
.1;
|
||||
kdtree.add(&[endf.x, endf.y, endf.z], node_index).ok()?;
|
||||
nodes.push(endf);
|
||||
parents.insert(node_index, nearest_index);
|
||||
|
@ -4684,7 +4684,7 @@ impl Structure for SeaChapel {
|
||||
let su_bldg_variant =
|
||||
((RandomField::new(0).get((center - dir).with_z(base))) % 10) as i32;
|
||||
let su_bldg_center = center + dir * (diameter + (3 * su_bldg_variant));
|
||||
let su_bldg_base = base - 2 + ((su_bldg_variant / 2) as i32);
|
||||
let su_bldg_base = base - 2 + (su_bldg_variant / 2);
|
||||
let su_bldg_diameter = diameter;
|
||||
|
||||
let foundling_bottom1 = Aabb {
|
||||
|
Loading…
Reference in New Issue
Block a user