From 0d16f01571ec8315f3979eae46981e559ade1cf9 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:45:27 -0600 Subject: Fluid physics (#199) * start implementing fluid physics * Initial implementation of fluid pushing * different travel function in water * bubble columns * jumping in water * cleanup * change ultrawarm to be required * fix for clippy --- azalea-core/src/math.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'azalea-core/src/math.rs') diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index 67ece5cc..a763fc49 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -86,6 +86,25 @@ pub fn to_degrees(radians: f64) -> f64 { radians * 57.29577951308232 } +/// Returns either -1, 0, or 1, depending on whether the number is negative, +/// zero, or positive. +/// +/// This function exists because f64::signum doesn't check for 0. +pub fn sign(num: f64) -> f64 { + if num == 0. { + 0. + } else { + num.signum() + } +} +pub fn sign_as_int(num: f64) -> i32 { + if num == 0. { + 0 + } else { + num.signum() as i32 + } +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3