From 516ad1c77250f6bcb90356391051b3ab99d90f42 Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Sun, 25 Jul 2021 12:28:25 -0400 Subject: [PATCH 1/2] Revert "Resolve all '#[allow(clippy::identity_op)]' error supressions" This reverts commit 63eff216f050e83404629dfd84ae3c8e38e8fe54. --- common/src/figure/mod.rs | 1 + voxygen/src/render/pipelines/fluid.rs | 3 ++- voxygen/src/render/pipelines/terrain.rs | 8 +++++--- world/src/block/mod.rs | 3 ++- world/src/index.rs | 3 ++- world/src/site/settlement/mod.rs | 3 ++- world/src/site2/plot/castle.rs | 5 +++-- world/src/util/structure.rs | 3 ++- 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/common/src/figure/mod.rs b/common/src/figure/mod.rs index 021f6076eb..b16d43730f 100644 --- a/common/src/figure/mod.rs +++ b/common/src/figure/mod.rs @@ -187,6 +187,7 @@ impl MatSegment { }) } + #[allow(clippy::identity_op)] pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool) -> Self { if let Some(model) = dot_vox_data.models.get(0) { let palette = dot_vox_data diff --git a/voxygen/src/render/pipelines/fluid.rs b/voxygen/src/render/pipelines/fluid.rs index 92a361c093..72d5923db5 100644 --- a/voxygen/src/render/pipelines/fluid.rs +++ b/voxygen/src/render/pipelines/fluid.rs @@ -23,7 +23,8 @@ impl Vertex { const EXTRA_NEG_Z: f32 = 65536.0; Self { - pos_norm: ((pos.x as u32) & 0x003F) + pos_norm: 0 + | ((pos.x as u32) & 0x003F) << 0 | ((pos.y as u32) & 0x003F) << 6 | (((pos.z + EXTRA_NEG_Z).max(0.0).min((1 << 17) as f32) as u32) & 0x1FFFF) << 12 | (norm_bits & 0x7) << 29, diff --git a/voxygen/src/render/pipelines/terrain.rs b/voxygen/src/render/pipelines/terrain.rs index d8164478ce..082abdbaad 100644 --- a/voxygen/src/render/pipelines/terrain.rs +++ b/voxygen/src/render/pipelines/terrain.rs @@ -11,6 +11,7 @@ pub struct Vertex { } impl Vertex { + #[allow(clippy::identity_op)] // TODO: Pending review in #587 /// NOTE: meta is true when the terrain vertex is touching water. pub fn new(atlas_pos: Vec2, pos: Vec3, norm: Vec3, meta: bool) -> Self { const EXTRA_NEG_Z: f32 = 32768.0; @@ -25,12 +26,12 @@ impl Vertex { 5 }; Self { - pos_norm: ((pos.x as u32) & 0x003F) + pos_norm: ((pos.x as u32) & 0x003F) << 0 | ((pos.y as u32) & 0x003F) << 6 | (((pos + EXTRA_NEG_Z).z.max(0.0).min((1 << 16) as f32) as u32) & 0xFFFF) << 12 | if meta { 1 } else { 0 } << 28 | (norm_bits & 0x7) << 29, - atlas_pos: ((atlas_pos.x as u32) & 0xFFFF) | ((atlas_pos.y as u32) & 0xFFFF) << 16, + atlas_pos: ((atlas_pos.x as u32) & 0xFFFF) << 0 | ((atlas_pos.y as u32) & 0xFFFF) << 16, } } @@ -96,6 +97,7 @@ impl Vertex { ] } + #[allow(clippy::identity_op)] pub fn make_col_light_figure( // 0 to 31 light: u8, @@ -103,7 +105,7 @@ impl Vertex { shiny: bool, col: Rgb, ) -> [u8; 4] { - let attr = (glowy as u8) | ((shiny as u8) << 1); + let attr = 0 | ((glowy as u8) << 0) | ((shiny as u8) << 1); [ (light.min(31) << 3) | ((col.r >> 1) & 0b111), (attr.min(31) << 3) | ((col.b >> 1) & 0b111), diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index f3db8f962d..a1284ac22e 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -168,7 +168,8 @@ impl<'a> BlockGen<'a> { .or_else(|| { // Rocks if (height + 2.5 - wposf.z as f32).div(7.5).abs().powi(2) < rock { - let field0 = RandomField::new(world.seed); + #[allow(clippy::identity_op)] + let field0 = RandomField::new(world.seed + 0); let field1 = RandomField::new(world.seed + 1); let field2 = RandomField::new(world.seed + 2); diff --git a/world/src/index.rs b/world/src/index.rs index 5050965e24..7d5d6e4685 100644 --- a/world/src/index.rs +++ b/world/src/index.rs @@ -128,9 +128,10 @@ pub struct Noise { } impl Noise { + #[allow(clippy::identity_op)] fn new(seed: u32) -> Self { Self { - cave_nz: SuperSimplex::new().set_seed(seed), + cave_nz: SuperSimplex::new().set_seed(seed + 0), scatter_nz: SuperSimplex::new().set_seed(seed + 1), } } diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 4a34117df7..5b2377de6c 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -561,6 +561,7 @@ impl Settlement { } } + #[allow(clippy::identity_op)] // TODO: Pending review in #587 pub fn apply_to<'a>( &'a self, index: IndexRef, @@ -674,7 +675,7 @@ impl Settlement { let in_furrow = (wpos2d * furrow_dir).sum().rem_euclid(5) < 2; let dirt = Rgb::::from(colors.plot_field_dirt).map(|e| { - e + (self.noise.get(Vec3::broadcast((seed % 4096) as i32)) % 32) + e + (self.noise.get(Vec3::broadcast((seed % 4096 + 0) as i32)) % 32) as u8 }); let mound = Rgb::::from(colors.plot_field_mound) diff --git a/world/src/site2/plot/castle.rs b/world/src/site2/plot/castle.rs index a1d4a2e9dd..038903f6d9 100644 --- a/world/src/site2/plot/castle.rs +++ b/world/src/site2/plot/castle.rs @@ -42,6 +42,7 @@ impl Castle { } impl Structure for Castle { + #[allow(clippy::identity_op)] fn render Id, G: FnMut(Id, Fill)>( &self, site: &Site, @@ -126,7 +127,7 @@ impl Structure for Castle { .with_z(self.alt + wall_height / 4 + 12), })); let window_bottom = prim(Primitive::Aabb(Aabb { - min: (wpos + dir).with_z(self.alt + wall_height / 4), + min: (wpos + 1 * dir).with_z(self.alt + wall_height / 4), max: (wpos + (ts - 1) * dir + dir.yx()) .with_z(self.alt + wall_height / 4 + 9), })); @@ -137,7 +138,7 @@ impl Structure for Castle { .with_z(self.alt + wall_height / 4 + 12), })); let window_bottom2 = prim(Primitive::Aabb(Aabb { - min: (wpos + dir + (ts - 1) * dir.yx()) + min: (wpos + 1 * dir + (ts - 1) * dir.yx()) .with_z(self.alt + wall_height / 4), max: (wpos + (ts - 1) * dir + ts * dir.yx()) .with_z(self.alt + wall_height / 4 + 9), diff --git a/world/src/util/structure.rs b/world/src/util/structure.rs index c4eb3cf1b0..b9a0a57cb2 100644 --- a/world/src/util/structure.rs +++ b/world/src/util/structure.rs @@ -13,11 +13,12 @@ pub struct StructureGen2d { pub type StructureField = (Vec2, u32); impl StructureGen2d { + #[allow(clippy::identity_op)] // TODO: Pending review in #587 pub fn new(seed: u32, freq: u32, spread: u32) -> Self { Self { freq, spread, - x_field: RandomField::new(seed), + x_field: RandomField::new(seed + 0), y_field: RandomField::new(seed + 1), seed_field: RandomField::new(seed + 2), } From edad38098f7c1e8e3a3e330230e6fb20ec0c2b87 Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Sun, 25 Jul 2021 12:29:21 -0400 Subject: [PATCH 2/2] Revert "Resolve all '#[allow(clippy::excessive_precision)]' error supressions" This reverts commit 0247ae2bf60dbc3713cba5dc9845f6a06e165c91. --- common/src/util/color.rs | 6 ++++-- world/src/util/fast_noise.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/util/color.rs b/common/src/util/color.rs index f3ae9ca9bc..c1e4c273d2 100644 --- a/common/src/util/color.rs +++ b/common/src/util/color.rs @@ -1,17 +1,19 @@ use vek::{Mat3, Rgb, Rgba, Vec3}; #[inline(always)] +#[allow(clippy::excessive_precision)] pub fn srgb_to_linear(col: Rgb) -> Rgb { col.map(|c| { if c <= 0.104 { c * 0.08677088 } else { - 0.012522878 * c + 0.682_171_1 * c * c + 0.305_306_02 * c * c * c + 0.012522878 * c + 0.682171111 * c * c + 0.305306011 * c * c * c } }) } #[inline(always)] +#[allow(clippy::excessive_precision)] pub fn linear_to_srgb(col: Rgb) -> Rgb { col.map(|c| { if c <= 0.0060 { @@ -20,7 +22,7 @@ pub fn linear_to_srgb(col: Rgb) -> Rgb { let s1 = c.sqrt(); let s2 = s1.sqrt(); let s3 = s2.sqrt(); - 0.585_122_4 * s1 + 0.783_140_36 * s2 - 0.368_262_74 * s3 + 0.585122381 * s1 + 0.783140355 * s2 - 0.368262736 * s3 } }) } diff --git a/world/src/util/fast_noise.rs b/world/src/util/fast_noise.rs index cf1c752b7a..84ac0dc87a 100644 --- a/world/src/util/fast_noise.rs +++ b/world/src/util/fast_noise.rs @@ -13,8 +13,9 @@ impl FastNoise { } } + #[allow(clippy::excessive_precision)] // TODO: Pending review in #587 fn noise_at(&self, pos: Vec3) -> f32 { - (self.noise.get(pos) & 4095) as f32 * 0.000_244_140_63 + (self.noise.get(pos) & 4095) as f32 * 0.000244140625 } } @@ -86,8 +87,9 @@ impl FastNoise2d { } } + #[allow(clippy::excessive_precision)] // TODO: Pending review in #587 fn noise_at(&self, pos: Vec2) -> f32 { - (self.noise.get(Vec3::new(pos.x, pos.y, 0)) & 4095) as f32 * 0.000_244_140_63 + (self.noise.get(Vec3::new(pos.x, pos.y, 0)) & 4095) as f32 * 0.000244140625 } }