From 45cb5823f50ece7af86804d4331bd7ba2f6c5917 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 5 Aug 2025 05:49:49 +0400 Subject: use same pi value as java --- azalea-core/src/math.rs | 2 +- azalea-entity/src/lib.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index d5fe5af9..4422c371 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -1,10 +1,10 @@ use std::{ - f64::consts::PI, ops::{Add, Div, Sub}, sync::LazyLock, }; pub const EPSILON: f64 = 1.0e-7; +pub const PI: f64 = 3.141592653589793; pub static SIN: LazyLock<[f32; 65536]> = LazyLock::new(|| std::array::from_fn(|i| f64::sin((i as f64) * PI * 2. / 65536.) as f32)); diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 984cce27..095098f1 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -12,7 +12,6 @@ mod plugin; pub mod vec_delta_codec; use std::{ - f64::consts::PI, fmt::{self, Debug}, hash::{Hash, Hasher}, }; @@ -60,8 +59,8 @@ pub fn input_vector(direction: LookDirection, speed: f32, acceleration: Vec3) -> acceleration } .scale(speed as f64); - let y_rot = math::sin(direction.y_rot * (PI / 180.) as f32); - let x_rot = math::cos(direction.y_rot * (PI / 180.) as f32); + let y_rot = math::sin(direction.y_rot * (3.141592653589793 / 180.) as f32); + let x_rot = math::cos(direction.y_rot * (3.141592653589793 / 180.) as f32); Vec3 { x: acceleration.x * (x_rot as f64) - acceleration.z * (y_rot as f64), y: acceleration.y, -- cgit v1.2.3