diff --git a/pumpkin-core/src/math/mod.rs b/pumpkin-core/src/math/mod.rs index e1f7149f0..de67a8532 100644 --- a/pumpkin-core/src/math/mod.rs +++ b/pumpkin-core/src/math/mod.rs @@ -18,7 +18,7 @@ pub fn wrap_degrees(var: f32) -> f32 { } pub fn squared_magnitude(a: f64, b: f64, c: f64) -> f64 { - c.mul_add(c, a.mul_add(a, b * b)) + a * a + b * b + c * c } pub fn magnitude(a: f64, b: f64, c: f64) -> f64 { diff --git a/pumpkin-core/src/random/gaussian.rs b/pumpkin-core/src/random/gaussian.rs index 17cce2da9..35d4095cd 100644 --- a/pumpkin-core/src/random/gaussian.rs +++ b/pumpkin-core/src/random/gaussian.rs @@ -11,9 +11,9 @@ pub trait GaussianGenerator: RandomImpl { gaussian } else { loop { - let d = 2f64.mul_add(self.next_f64(), -1f64); - let e = 2f64.mul_add(self.next_f64(), -1f64); - let f = d.mul_add(d, e * e); + let d = 2f64 * self.next_f64() - 1f64; + let e = 2f64 * self.next_f64() - 1f64; + let f = d * d + e * e; if f < 1f64 && f != 0f64 { let g = (-2f64 * f.ln() / f).sqrt(); diff --git a/pumpkin-core/src/random/mod.rs b/pumpkin-core/src/random/mod.rs index ede61ca22..c87372130 100644 --- a/pumpkin-core/src/random/mod.rs +++ b/pumpkin-core/src/random/mod.rs @@ -109,7 +109,7 @@ impl RandomGenerator { #[inline] pub fn next_triangular(&mut self, mode: f64, deviation: f64) -> f64 { - deviation.mul_add(self.next_f64() - self.next_f64(), mode) + mode + deviation * (self.next_f64() - self.next_f64()) } #[inline] @@ -184,7 +184,7 @@ pub trait RandomImpl { fn next_gaussian(&mut self) -> f64; fn next_triangular(&mut self, mode: f64, deviation: f64) -> f64 { - deviation.mul_add(self.next_f64() - self.next_f64(), mode) + mode + deviation * (self.next_f64() - self.next_f64()) } fn skip(&mut self, count: i32) { diff --git a/pumpkin-world/src/world_gen/generic_generator.rs b/pumpkin-world/src/world_gen/generic_generator.rs index 4888e536a..1f0a17657 100644 --- a/pumpkin-world/src/world_gen/generic_generator.rs +++ b/pumpkin-world/src/world_gen/generic_generator.rs @@ -40,7 +40,7 @@ impl WorldGenerator for GenericGen let base_height = 64.0; let height_variation = 16.0; - let chunk_height = noise_value.mul_add(height_variation, base_height) as i32; + let chunk_height = (noise_value * height_variation + base_height) as i32; for x in 0..16u8 { for z in 0..16u8 { diff --git a/pumpkin-world/src/world_gen/noise/density/end.rs b/pumpkin-world/src/world_gen/noise/density/end.rs index f546701a4..fd22fb251 100644 --- a/pumpkin-world/src/world_gen/noise/density/end.rs +++ b/pumpkin-world/src/world_gen/noise/density/end.rs @@ -29,7 +29,7 @@ impl EndIslandFunction { let k = x % 2; let l = z % 2; - let f = ((x * x + z * z) as f32).sqrt().mul_add(-8f32, 100f32); + let f = 100f32 - ((x * x + z * z) as f32).sqrt() * 8f32; let mut f = f.clamp(-100f32, 80f32); for m in -12..=12 { @@ -40,11 +40,10 @@ impl EndIslandFunction { if (o * o + p * p) > 4096i64 && sampler.sample_2d(o as f64, p as f64) < -0.9f32 as f64 { - let g = - (o as f32).abs().mul_add(3439f32, (p as f32).abs() * 147f32) % 13f32 + 9f32; + let g = ((o as f32).abs() * 3439f32 + (p as f32).abs() * 147f32) % 13f32 + 9f32; let h = (k - m * 2) as f32; let q = (l - n * 2) as f32; - let r = h.hypot(q).mul_add(-g, 100f32); + let r = 100f32 - (h * h + q * q).sqrt() * g; let s = r.clamp(-100f32, 80f32); f = f.max(s); diff --git a/pumpkin-world/src/world_gen/noise/density/noise.rs b/pumpkin-world/src/world_gen/noise/density/noise.rs index 71843e58c..d4406bb2e 100644 --- a/pumpkin-world/src/world_gen/noise/density/noise.rs +++ b/pumpkin-world/src/world_gen/noise/density/noise.rs @@ -118,9 +118,9 @@ impl<'a> ShiftedNoiseFunction<'a> { impl<'a> DensityFunctionImpl<'a> for ShiftedNoiseFunction<'a> { fn sample(&self, pos: &NoisePos) -> f64 { - let d = (pos.x() as f64).mul_add(self.xz_scale, self.shift_x.sample(pos)); - let e = (pos.y() as f64).mul_add(self.y_scale, self.shift_y.sample(pos)); - let f = (pos.z() as f64).mul_add(self.xz_scale, self.shift_z.sample(pos)); + let d = pos.x() as f64 * self.xz_scale + self.shift_x.sample(pos); + let e = pos.y() as f64 * self.y_scale + self.shift_y.sample(pos); + let f = pos.z() as f64 * self.xz_scale + self.shift_z.sample(pos); self.noise.sample(d, e, f) } diff --git a/pumpkin-world/src/world_gen/noise/density/spline.rs b/pumpkin-world/src/world_gen/noise/density/spline.rs index aebffcfae..c2480d7cc 100644 --- a/pumpkin-world/src/world_gen/noise/density/spline.rs +++ b/pumpkin-world/src/world_gen/noise/density/spline.rs @@ -67,7 +67,7 @@ impl<'a> Spline<'a> { if f == 0f32 { value } else { - f.mul_add(point - points[i].location, value) + value + f * (point - points[i].location) } } @@ -154,8 +154,8 @@ impl<'a> Spline<'a> { let ad = z.min(ab); let ae = aa.max(ac); - f = f.min(0.25f32.mul_add(ad, x)); - g = g.max(0.25f32.mul_add(ae, y)); + f = f.min(x + 0.25f32 * ad); + g = g.max(y + 0.25f32 * ae); } } @@ -189,12 +189,9 @@ impl<'a> Spline<'a> { let n = point_1.value.apply(pos); let o = point_2.value.apply(pos); - let p = point_1 - .derivative - .mul_add(point_2.location - point_1.location, -(o - n)); - let q = - (-point_2.derivative).mul_add(point_2.location - point_1.location, o - n); - (k * (1f32 - k)).mul_add(lerp(k, p, q), lerp(k, n, o)) + let p = point_1.derivative * (point_2.location - point_1.location) - (o - n); + let q = -point_2.derivative * (point_2.location - point_1.location) + (o - n); + lerp(k, n, o) + k * (1f32 - k) * lerp(k, p, q) } } Range::Below => { diff --git a/pumpkin-world/src/world_gen/noise/density/terrain_helpers.rs b/pumpkin-world/src/world_gen/noise/density/terrain_helpers.rs index 2d478fb94..5e1fdec4d 100644 --- a/pumpkin-world/src/world_gen/noise/density/terrain_helpers.rs +++ b/pumpkin-world/src/world_gen/noise/density/terrain_helpers.rs @@ -10,11 +10,11 @@ use crate::world_gen::noise::lerp; #[inline] fn get_offset_value(f: f32, g: f32, h: f32) -> f32 { - let k = (1f32 - g).mul_add(-0.5f32, 1f32); + let k = 1f32 - (1f32 - g) * 0.5f32; let l = 0.5f32 * (1f32 - g); let m = (f + 1.17f32) * 0.46082947f32; - let n = m.mul_add(k, -l); + let n = m * k - l; if f < h { n.max(-0.2222f32) @@ -25,7 +25,7 @@ fn get_offset_value(f: f32, g: f32, h: f32) -> f32 { #[inline] fn skew_map(f: f32) -> f32 { - let k = (1f32 - f).mul_add(-0.5f32, 1f32); + let k = 1f32 - (1f32 - f) * 0.5f32; let l = 0.5f32 * (1f32 - f); l / (0.46082947f32 * k) - 1.17f32 diff --git a/pumpkin-world/src/world_gen/noise/mod.rs b/pumpkin-world/src/world_gen/noise/mod.rs index 72d009204..0f9de83f1 100644 --- a/pumpkin-world/src/world_gen/noise/mod.rs +++ b/pumpkin-world/src/world_gen/noise/mod.rs @@ -265,5 +265,5 @@ const GRADIENTS: [Gradient; 16] = [ ]; fn dot(gradient: &Gradient, x: f64, y: f64, z: f64) -> f64 { - (gradient.z as f64).mul_add(z, (gradient.x as f64).mul_add(x, gradient.y as f64 * y)) + gradient.x as f64 * x + gradient.y as f64 * y + gradient.z as f64 * z } diff --git a/pumpkin-world/src/world_gen/noise/perlin.rs b/pumpkin-world/src/world_gen/noise/perlin.rs index 555ebc907..74dcec723 100644 --- a/pumpkin-world/src/world_gen/noise/perlin.rs +++ b/pumpkin-world/src/world_gen/noise/perlin.rs @@ -73,7 +73,7 @@ impl PerlinNoiseSampler { } fn perlin_fade(value: f64) -> f64 { - value * value * value * value.mul_add(value.mul_add(6f64, -15f64), 10f64) + value * value * value * (value * (value * 6f64 - 15f64) + 10f64) } fn map(&self, input: i32) -> i32 { @@ -183,9 +183,7 @@ impl OctavePerlinNoiseSampler { } pub fn maintain_precision(value: f64) -> f64 { - (value / 3.3554432E7f64 + 0.5f64) - .floor() - .mul_add(-3.3554432E7f64, value) + value - (value / 3.3554432E7f64 + 0.5f64).floor() * 3.3554432E7f64 } pub fn calculate_amplitudes(octaves: &[i32]) -> (i32, Vec) { diff --git a/pumpkin-world/src/world_gen/noise/simplex.rs b/pumpkin-world/src/world_gen/noise/simplex.rs index 88caf6eaf..fc4d91536 100644 --- a/pumpkin-world/src/world_gen/noise/simplex.rs +++ b/pumpkin-world/src/world_gen/noise/simplex.rs @@ -46,7 +46,7 @@ impl SimplexNoiseSampler { } fn grad(gradient_index: usize, x: f64, y: f64, z: f64, distance: f64) -> f64 { - let d = z.mul_add(-z, y.mul_add(-y, x.mul_add(-x, distance))); + let d = distance - x * x - y * y - z * z; if d < 0f64 { 0f64 } else { @@ -71,8 +71,8 @@ impl SimplexNoiseSampler { let n = h - l as f64 + Self::UNSKEW_FACTOR_2D; let o = k - m as f64 + Self::UNSKEW_FACTOR_2D; - let p = 2f64.mul_add(Self::UNSKEW_FACTOR_2D, h - 1f64); - let q = 2f64.mul_add(Self::UNSKEW_FACTOR_2D, k - 1f64); + let p = h - 1f64 + 2f64 * Self::UNSKEW_FACTOR_2D; + let q = k - 1f64 + 2f64 * Self::UNSKEW_FACTOR_2D; let r = i & 0xFF; let s = j & 0xFF; @@ -236,8 +236,8 @@ impl OctaveSimplexNoiseSampler { for sampler in self.octave_samplers.iter() { if let Some(sampler) = sampler { d += sampler.sample_2d( - x.mul_add(e, if use_origin { sampler.x_origin } else { 0f64 }), - y.mul_add(e, if use_origin { sampler.y_origin } else { 0f64 }), + x * e + if use_origin { sampler.x_origin } else { 0f64 }, + y * e + if use_origin { sampler.y_origin } else { 0f64 }, ) * f; }