From fb7bdd8bf8b912d7067e1c44126ba40856bdd2c6 Mon Sep 17 00:00:00 2001 From: tygyh <32486062+tygyh@users.noreply.github.com> Date: Fri, 15 Jul 2022 16:17:19 +0200 Subject: [PATCH] Fix deprecated imports --- voxygen/src/scene/terrain.rs | 2 +- voxygen/src/ui/ice/widget/aspect_ratio_container.rs | 2 +- voxygen/src/ui/ice/widget/background_container.rs | 2 +- voxygen/src/ui/mod.rs | 2 +- world/src/block/mod.rs | 2 +- world/src/column/mod.rs | 9 +++------ world/src/sim/erosion.rs | 10 +++++----- world/src/sim/map.rs | 2 +- world/src/sim/mod.rs | 6 +++--- world/src/site2/mod.rs | 2 +- 10 files changed, 18 insertions(+), 21 deletions(-) diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index e9b6b3ce34..94d8375a1b 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -29,7 +29,7 @@ use common::{ volumes::vol_grid_2d::{VolGrid2d, VolGrid2dError}, }; use common_base::{prof_span, span}; -use core::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration}; +use core::{f32, fmt::Debug, marker::PhantomData, time::Duration}; use crossbeam_channel as channel; use enum_iterator::IntoEnumIterator; use guillotiere::AtlasAllocator; diff --git a/voxygen/src/ui/ice/widget/aspect_ratio_container.rs b/voxygen/src/ui/ice/widget/aspect_ratio_container.rs index a16884714b..767b973ea1 100644 --- a/voxygen/src/ui/ice/widget/aspect_ratio_container.rs +++ b/voxygen/src/ui/ice/widget/aspect_ratio_container.rs @@ -1,7 +1,7 @@ use iced::{ layout, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size, Widget, }; -use std::{hash::Hash, u32}; +use std::hash::Hash; // Note: it might be more efficient to make this generic over the content type? diff --git a/voxygen/src/ui/ice/widget/background_container.rs b/voxygen/src/ui/ice/widget/background_container.rs index 3b7c2b73b2..2ba246f681 100644 --- a/voxygen/src/ui/ice/widget/background_container.rs +++ b/voxygen/src/ui/ice/widget/background_container.rs @@ -1,7 +1,7 @@ use iced::{ layout, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size, Widget, }; -use std::{hash::Hash, u32}; +use std::hash::Hash; // TODO: decouple from image/compound graphic widgets (they could still use // common types, but the info we want here for the background is a subset of diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index 92b9a54cab..2eea3d5d80 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -50,7 +50,7 @@ use conrod_core::{ widget::{self, id::Generator}, Rect, Scalar, UiBuilder, UiCell, }; -use core::{convert::TryInto, f32, f64, ops::Range}; +use core::{convert::TryInto, f64, ops::Range}; use graphic::TexId; use hashbrown::hash_map::Entry; use std::time::Duration; diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 824a4bba81..f7390bbde1 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -189,7 +189,7 @@ pub fn block_from_structure( let field = RandomField::new(structure_seed); let lerp = ((field.get(Vec3::from(structure_pos)).rem_euclid(256)) as f32 / 255.0) * 0.8 - + ((field.get(pos + std::i32::MAX / 2).rem_euclid(256)) as f32 / 255.0) * 0.2; + + ((field.get(pos + i32::MAX / 2).rem_euclid(256)) as f32 / 255.0) * 0.2; match sblock { StructureBlock::None => None, diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index b1346a0e1f..ca34a9b94f 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -15,10 +15,7 @@ use common::{ }; use noise::NoiseFn; use serde::Deserialize; -use std::{ - f32, - ops::{Add, Div, Mul, Sub}, -}; +use std::ops::{Add, Div, Mul, Sub}; use tracing::error; use vek::*; @@ -535,7 +532,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { // 0.0 = not near river, 1.0 = in middle of river let near_center = ((river_dist / (river_width * 0.5)) as f32) .min(1.0) - .mul(f32::consts::PI) + .mul(std::f32::consts::PI) .cos() .add(1.0) .mul(0.5); @@ -743,7 +740,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { const MIN_DEPTH: f32 = 1.0; let near_center = ((river_dist / (river_width * 0.5)) as f32) .min(1.0) - .mul(f32::consts::PI) + .mul(std::f32::consts::PI) .cos() .add(1.0) .mul(0.5); diff --git a/world/src/sim/erosion.rs b/world/src/sim/erosion.rs index e94cd40fb1..c68c1d63fb 100644 --- a/world/src/sim/erosion.rs +++ b/world/src/sim/erosion.rs @@ -18,7 +18,7 @@ use rayon::prelude::*; use std::{ cmp::{Ordering, Reverse}, collections::BinaryHeap, - f32, f64, fmt, mem, + f32, fmt, mem, time::Instant, u32, }; @@ -555,8 +555,8 @@ fn get_max_slope( rock_strength_nz: &(impl NoiseFn<[f64; 3]> + Sync), height_scale: impl Fn(usize) -> Alt + Sync, ) -> Box<[f64]> { - let min_max_angle = (15.0 / 360.0 * 2.0 * f64::consts::PI).tan(); - let max_max_angle = (60.0 / 360.0 * 2.0 * f64::consts::PI).tan(); + let min_max_angle = (15.0 / 360.0 * 2.0 * std::f64::consts::PI).tan(); + let max_max_angle = (60.0 / 360.0 * 2.0 * std::f64::consts::PI).tan(); let max_angle_range = max_max_angle - min_max_angle; h.par_iter() .enumerate() @@ -572,7 +572,7 @@ fn get_max_slope( // Logistic regression. Make sure x ∈ (0, 1). let logit = |x: f64| x.ln() - (-x).ln_1p(); // 0.5 + 0.5 * tanh(ln(1 / (1 - 0.1) - 1) / (2 * (sqrt(3)/pi))) - let logistic_2_base = 3.0f64.sqrt() * f64::consts::FRAC_2_PI; + let logistic_2_base = 3.0f64.sqrt() * std::f64::consts::FRAC_2_PI; // Assumes μ = 0, σ = 1 let logistic_cdf = |x: f64| (x / logistic_2_base).tanh() * 0.5 + 0.5; @@ -860,7 +860,7 @@ fn erode( // max angle of slope depends on rock strength, which is computed from noise // function. TODO: Make more principled. - let mid_slope = (30.0 / 360.0 * 2.0 * f64::consts::PI).tan(); + let mid_slope = (30.0 / 360.0 * 2.0 * std::f64::consts::PI).tan(); type SimdType = f32; type MaskType = m32; diff --git a/world/src/sim/map.rs b/world/src/sim/map.rs index 5b5a0dc334..97568339d0 100644 --- a/world/src/sim/map.rs +++ b/world/src/sim/map.rs @@ -10,7 +10,7 @@ use common::{ }, vol::RectVolSize, }; -use std::{f32, f64}; +use std::f64; use vek::*; /// A sample function that grabs the connections at a chunk. diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 0dd84858b7..89f905c114 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -63,7 +63,7 @@ use rand_chacha::ChaChaRng; use rayon::prelude::*; use serde::{Deserialize, Serialize}; use std::{ - f32, f64, + f32, fs::File, io::{BufReader, BufWriter}, ops::{Add, Div, Mul, Neg, Sub}, @@ -652,7 +652,7 @@ impl WorldSim { // Logistic regression. Make sure x ∈ (0, 1). let logit = |x: f64| x.ln() - (-x).ln_1p(); // 0.5 + 0.5 * tanh(ln(1 / (1 - 0.1) - 1) / (2 * (sqrt(3)/pi))) - let logistic_2_base = 3.0f64.sqrt() * f64::consts::FRAC_2_PI; + let logistic_2_base = 3.0f64.sqrt() * std::f64::consts::FRAC_2_PI; // Assumes μ = 0, σ = 1 let logistic_cdf = |x: f64| (x / logistic_2_base).tanh() * 0.5 + 0.5; @@ -2281,7 +2281,7 @@ impl SimChunk { // Logistic regression. Make sure x ∈ (0, 1). let logit = |x: f64| x.ln() - x.neg().ln_1p(); // 0.5 + 0.5 * tanh(ln(1 / (1 - 0.1) - 1) / (2 * (sqrt(3)/pi))) - let logistic_2_base = 3.0f64.sqrt().mul(f64::consts::FRAC_2_PI); + let logistic_2_base = 3.0f64.sqrt().mul(std::f64::consts::FRAC_2_PI); // Assumes μ = 0, σ = 1 let logistic_cdf = |x: f64| x.div(logistic_2_base).tanh().mul(0.5).add(0.5); diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index a9052732a0..eb45e6f126 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -92,7 +92,7 @@ impl Site { let base_spawn_rules = SpawnRules { trees: max_warp == 1.0, max_warp, - paths: max_warp > std::f32::EPSILON, + paths: max_warp > f32::EPSILON, waypoints: true, }; self.plots