From f82cf7fa859f2bab8207662e74f49bad4999f8fd Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 16 Jun 2025 17:08:09 -0630 Subject: cleanup --- azalea-core/src/hit_result.rs | 2 +- azalea-core/src/math.rs | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'azalea-core/src') diff --git a/azalea-core/src/hit_result.rs b/azalea-core/src/hit_result.rs index 3b1e160d..fe759d43 100644 --- a/azalea-core/src/hit_result.rs +++ b/azalea-core/src/hit_result.rs @@ -18,7 +18,7 @@ impl HitResult { pub fn miss(&self) -> bool { match self { HitResult::Block(r) => r.miss, - HitResult::Entity(_) => false, + _ => false, } } pub fn location(&self) -> Vec3 { diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index c09bddda..a115927d 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -6,25 +6,20 @@ use std::{ pub const EPSILON: f64 = 1.0E-7; -pub static SIN: LazyLock<[f32; 65536]> = LazyLock::new(|| { - let mut sin = [0.0; 65536]; - for (i, item) in sin.iter_mut().enumerate() { - *item = f64::sin((i as f64) * PI * 2.0 / 65536.0) as f32; - } - sin -}); +pub static SIN: LazyLock<[f32; 65536]> = + LazyLock::new(|| std::array::from_fn(|i| f64::sin((i as f64) * PI * 2. / 65536.) as f32)); /// A sine function that uses a lookup table. pub fn sin(x: f32) -> f32 { let x = x * 10430.378; - let x = x as i32 as usize & 65535; + let x = x as i32 as usize & 0xFFFF; SIN[x] } /// A cosine function that uses a lookup table. pub fn cos(x: f32) -> f32 { - let x = x * 10430.378 + 16384.0; - let x = x as i32 as usize & 65535; + let x = x * 10430.378 + 16384.; + let x = x as i32 as usize & 0xFFFF; SIN[x] } -- cgit v1.2.3