From 30fdb14b8db93b3b6415686565aec837a4b29928 Mon Sep 17 00:00:00 2001 From: kralverde Date: Sat, 12 Oct 2024 10:07:34 -0400 Subject: [PATCH] rename placeholder values --- .../noise/density/terrain_helpers.rs | 72 ++++---- pumpkin-world/src/world_gen/noise/router.rs | 156 ++++++++++-------- 2 files changed, 126 insertions(+), 102 deletions(-) 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 432052cb6..5e1fdec4d 100644 --- a/pumpkin-world/src/world_gen/noise/density/terrain_helpers.rs +++ b/pumpkin-world/src/world_gen/noise/density/terrain_helpers.rs @@ -24,7 +24,7 @@ fn get_offset_value(f: f32, g: f32, h: f32) -> f32 { } #[inline] -fn meth_42045(f: f32) -> f32 { +fn skew_map(f: f32) -> f32 { let k = 1f32 - (1f32 - f) * 0.5f32; let l = 0.5f32 * (1f32 - f); @@ -32,11 +32,11 @@ fn meth_42045(f: f32) -> f32 { } #[inline] -fn meth_42047(f: f32, g: f32, h: f32, i: f32) -> f32 { +fn diff_quot(f: f32, g: f32, h: f32, i: f32) -> f32 { (g - f) / (i - h) } -fn meth_42050( +fn create_ridges_spline( function: Arc, f: f32, bl: bool, @@ -47,25 +47,25 @@ fn meth_42050( let i = get_offset_value(-1f32, f, -0.7f32); let k = get_offset_value(1f32, f, -0.7f32); - let l = meth_42045(f); + let l = skew_map(f); let builder = if -0.65f32 < l && l < 1f32 { let n = get_offset_value(-0.65f32, f, -0.7f32); let p = get_offset_value(-0.75f32, f, -0.7f32); - let q = meth_42047(i, p, -1f32, -0.75f32); + let q = diff_quot(i, p, -1f32, -0.75f32); let builder = builder .add_value(-1f32, i, q) .add_value(-0.75f32, p, 0f32) .add_value(-0.65f32, n, 0f32); let r = get_offset_value(l, f, -0.7f32); - let s = meth_42047(r, k, l, 1f32); + let s = diff_quot(r, k, l, 1f32); builder .add_value(l - 0.01f32, r, 0f32) .add_value(l, r, s) .add_value(1f32, k, s) } else { - let n = meth_42047(i, k, -1f32, 1f32); + let n = diff_quot(i, k, -1f32, 1f32); let builder = if bl { builder .add_value(-1f32, 0.2f32.max(i), 0f32) @@ -81,7 +81,7 @@ fn meth_42050( } #[allow(clippy::too_many_arguments)] -fn meth_42048( +fn create_standard_spline( ridges: Arc, continental: f32, f: f32, @@ -102,7 +102,7 @@ fn meth_42048( .build() } -fn method_42054<'a>( +fn create_total_spline<'a>( erosion: Arc>, ridges: Arc>, ridges_folded: Arc>, @@ -179,7 +179,7 @@ fn method_42054<'a>( builder.build() } -fn method_42052<'a>( +fn create_folded_ridges_spline<'a>( ridges: Arc>, ridges_folded: Arc>, f: f32, @@ -196,7 +196,11 @@ fn method_42052<'a>( let builder = if g > 0f32 { builder.add_spline( j, - SplineValue::Spline(method_42049(ridges.clone(), f, amplifier.clone())), + SplineValue::Spline(create_ridges_part_spline( + ridges.clone(), + f, + amplifier.clone(), + )), 0f32, ) } else { @@ -206,7 +210,11 @@ fn method_42052<'a>( let builder = if f > 0f32 { builder.add_spline( 1f32, - SplineValue::Spline(method_42049(ridges.clone(), f, amplifier.clone())), + SplineValue::Spline(create_ridges_part_spline( + ridges.clone(), + f, + amplifier.clone(), + )), 0f32, ) } else { @@ -217,7 +225,11 @@ fn method_42052<'a>( } #[inline] -fn method_42049(ridges: Arc, f: f32, amplifier: FloatAmplifier) -> Spline { +fn create_ridges_part_spline( + ridges: Arc, + f: f32, + amplifier: FloatAmplifier, +) -> Spline { let g = 0.63f32 * f; let h = 0.3f32 * f; SplineBuilder::new(ridges, amplifier) @@ -228,7 +240,7 @@ fn method_42049(ridges: Arc, f: f32, amplifier: FloatAmplifier) #[allow(clippy::too_many_arguments)] #[inline] -fn method_42053<'a>( +fn create_eroded_ridges_spline<'a>( erosion: Arc>, ridges: Arc>, ridges_folded: Arc>, @@ -238,14 +250,14 @@ fn method_42053<'a>( i: f32, amplifier: FloatAmplifier, ) -> Spline<'a> { - let spline = method_42052( + let spline = create_folded_ridges_spline( ridges.clone(), ridges_folded.clone(), f, h, amplifier.clone(), ); - let spline2 = method_42052( + let spline2 = create_folded_ridges_spline( ridges.clone(), ridges_folded.clone(), g, @@ -275,20 +287,20 @@ fn create_continental_offset_spline<'a>( bl2: bool, amplifier: FloatAmplifier, ) -> Spline<'a> { - let spline = meth_42050( + let spline = create_ridges_spline( ridges.clone(), lerp(h, 0.6f32, 1.5f32), bl2, amplifier.clone(), ); - let spline2 = meth_42050( + let spline2 = create_ridges_spline( ridges.clone(), lerp(h, 0.6f32, 1f32), bl2, amplifier.clone(), ); - let spline3 = meth_42050(ridges.clone(), h, bl2, amplifier.clone()); - let spline4 = meth_42048( + let spline3 = create_ridges_spline(ridges.clone(), h, bl2, amplifier.clone()); + let spline4 = create_standard_spline( ridges.clone(), continental - 0.15f32, 0.5f32 * h, @@ -299,7 +311,7 @@ fn create_continental_offset_spline<'a>( amplifier.clone(), ); - let spline5 = meth_42048( + let spline5 = create_standard_spline( ridges.clone(), continental, i * h, @@ -309,7 +321,7 @@ fn create_continental_offset_spline<'a>( 0.5f32, amplifier.clone(), ); - let spline6 = meth_42048( + let spline6 = create_standard_spline( ridges.clone(), continental, i, @@ -319,7 +331,7 @@ fn create_continental_offset_spline<'a>( 0.5f32, amplifier.clone(), ); - let spline7 = meth_42048( + let spline7 = create_standard_spline( ridges.clone(), continental, i, @@ -335,7 +347,7 @@ fn create_continental_offset_spline<'a>( .add_spline(-0.4f32, SplineValue::Spline(spline6.clone()), 0f32) .add_value(0f32, g + 0.07f32, 0f32) .build(); - let spline9 = meth_42048( + let spline9 = create_standard_spline( ridges.clone(), -0.02f32, j, @@ -466,7 +478,7 @@ pub fn create_factor_spline<'a>( .add_value(-0.19f32, 3.95f32, 0f32) .add_spline( -0.15f32, - SplineValue::Spline(method_42054( + SplineValue::Spline(create_total_spline( erosion.clone(), ridges.clone(), ridges_folded.clone(), @@ -478,7 +490,7 @@ pub fn create_factor_spline<'a>( ) .add_spline( -0.1f32, - SplineValue::Spline(method_42054( + SplineValue::Spline(create_total_spline( erosion.clone(), ridges.clone(), ridges_folded.clone(), @@ -490,7 +502,7 @@ pub fn create_factor_spline<'a>( ) .add_spline( 0.03f32, - SplineValue::Spline(method_42054( + SplineValue::Spline(create_total_spline( erosion.clone(), ridges.clone(), ridges_folded.clone(), @@ -502,7 +514,7 @@ pub fn create_factor_spline<'a>( ) .add_spline( 0.06f32, - SplineValue::Spline(method_42054( + SplineValue::Spline(create_total_spline( erosion, ridges, ridges_folded, @@ -532,7 +544,7 @@ pub fn create_jaggedness_spline<'a>( .add_value(-0.11f32, 0f32, 0f32) .add_spline( 0.03f32, - SplineValue::Spline(method_42053( + SplineValue::Spline(create_eroded_ridges_spline( erosion.clone(), ridges.clone(), ridges_folded.clone(), @@ -546,7 +558,7 @@ pub fn create_jaggedness_spline<'a>( ) .add_spline( 0.65f32, - SplineValue::Spline(method_42053( + SplineValue::Spline(create_eroded_ridges_spline( erosion, ridges, ridges_folded, diff --git a/pumpkin-world/src/world_gen/noise/router.rs b/pumpkin-world/src/world_gen/noise/router.rs index d3307454f..92be5d555 100644 --- a/pumpkin-world/src/world_gen/noise/router.rs +++ b/pumpkin-world/src/world_gen/noise/router.rs @@ -59,7 +59,7 @@ impl<'a> NoiseRouter<'a> { large_biomes: bool, amplified: bool, ) -> Self { - let function = Arc::new(DensityFunction::Noise(NoiseFunction::new( + let aquifier_barrier = Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new( noise_params.aquifer_barrier().clone(), None, @@ -68,16 +68,17 @@ impl<'a> NoiseRouter<'a> { 0.5f64, ))); - let function2 = Arc::new(DensityFunction::Noise(NoiseFunction::new( - Arc::new(InternalNoise::new( - noise_params.aquifer_fluid_level_floodedness().clone(), - None, - )), - 1f64, - 0.67f64, - ))); + let aquifier_fluid_level_floodedness = + Arc::new(DensityFunction::Noise(NoiseFunction::new( + Arc::new(InternalNoise::new( + noise_params.aquifer_fluid_level_floodedness().clone(), + None, + )), + 1f64, + 0.67f64, + ))); - let function3 = Arc::new(DensityFunction::Noise(NoiseFunction::new( + let aquifer_fluid_level_spread = Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new( noise_params.aquifer_fluid_level_spread().clone(), None, @@ -86,7 +87,7 @@ impl<'a> NoiseRouter<'a> { 0.7142857142857143f64, ))); - let function4 = Arc::new(DensityFunction::Noise(NoiseFunction::new( + let aquifer_lava = Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new( noise_params.aquifer_lava().clone(), None, @@ -95,13 +96,13 @@ impl<'a> NoiseRouter<'a> { 1f64, ))); - let function5 = noise_funcs.shift_x().clone(); - let function6 = noise_funcs.shift_z().clone(); + let shift_x = noise_funcs.shift_x().clone(); + let shift_z = noise_funcs.shift_z().clone(); - let function7 = Arc::new(DensityFunction::ShiftedNoise(ShiftedNoiseFunction::new( - function5.clone(), + let temperature = Arc::new(DensityFunction::ShiftedNoise(ShiftedNoiseFunction::new( + shift_x.clone(), noise_funcs.zero().clone(), - function6.clone(), + shift_z.clone(), 0.25f64, 0f64, Arc::new(InternalNoise::new( @@ -114,10 +115,10 @@ impl<'a> NoiseRouter<'a> { )), ))); - let function8 = Arc::new(DensityFunction::ShiftedNoise(ShiftedNoiseFunction::new( - function5.clone(), + let vegetation = Arc::new(DensityFunction::ShiftedNoise(ShiftedNoiseFunction::new( + shift_x.clone(), noise_funcs.zero().clone(), - function6.clone(), + shift_z.clone(), 0.25f64, 0f64, Arc::new(InternalNoise::new( @@ -130,7 +131,7 @@ impl<'a> NoiseRouter<'a> { )), ))); - let function9 = if large_biomes { + let factor_overworld = if large_biomes { noise_funcs.factor_overworld_large_biome().clone() } else if amplified { noise_funcs.factor_overworld_amplified().clone() @@ -138,7 +139,7 @@ impl<'a> NoiseRouter<'a> { noise_funcs.factor_overworld().clone() }; - let function10 = if large_biomes { + let depth_overworld = if large_biomes { noise_funcs.depth_overworld_large_biome().clone() } else if amplified { noise_funcs.depth_overworld_amplified().clone() @@ -146,18 +147,18 @@ impl<'a> NoiseRouter<'a> { noise_funcs.depth_overworld().clone() }; - let function11 = Arc::new( + let mapped_depth_overworld = Arc::new( DensityFunction::Constant(ConstantFunction::new(4f64)).mul(Arc::new( - function10 + depth_overworld .mul(Arc::new(DensityFunction::Wrapper(WrapperFunction::new( - function9, + factor_overworld, WrapperType::Cache2D, )))) .quarter_negative(), )), ); - let function12 = if large_biomes { + let sloped_cheese_overworld = if large_biomes { noise_funcs.sloped_cheese_overworld_large_biome().clone() } else if amplified { noise_funcs.sloped_cheese_overworld_amplified().clone() @@ -165,31 +166,38 @@ impl<'a> NoiseRouter<'a> { noise_funcs.sloped_cheese_overworld().clone() }; - let function13 = Arc::new( - function12.binary_min(Arc::new( + let cave_entrances_overworld = Arc::new( + sloped_cheese_overworld.binary_min(Arc::new( DensityFunction::Constant(ConstantFunction::new(5f64)) .mul(noise_funcs.caves_entrances_overworld().clone()), )), ); - let function14 = Arc::new(DensityFunction::Range(RangeFunction::new( - function12.clone(), + let mapped_cave_entraces_overworld = Arc::new(DensityFunction::Range(RangeFunction::new( + sloped_cheese_overworld.clone(), -1000000f64, 1.5625f64, - function13, - Arc::new(create_caves(noise_funcs, noise_params, function12)), + cave_entrances_overworld, + Arc::new(create_caves( + noise_funcs, + noise_params, + sloped_cheese_overworld, + )), ))); - let function15 = Arc::new( - apply_blend_density(apply_surface_slides(amplified, function14)) - .binary_min(noise_funcs.caves_noodle_overworld().clone()), + let blended_cave_entrances_overworld = Arc::new( + apply_blend_density(apply_surface_slides( + amplified, + mapped_cave_entraces_overworld, + )) + .binary_min(noise_funcs.caves_noodle_overworld().clone()), ); - let function16 = noise_funcs.y().clone(); + let y = noise_funcs.y().clone(); let i = VeinType::overall_min_y(); let j = VeinType::overall_max_y(); - let function17 = Arc::new(veritcal_range_choice( - function16.clone(), + let ore_veininess = Arc::new(veritcal_range_choice( + y.clone(), Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new( noise_params.ore_veininess().clone(), @@ -203,9 +211,9 @@ impl<'a> NoiseRouter<'a> { 0, )); - let function18 = Arc::new( + let ore_vein_a = Arc::new( veritcal_range_choice( - function16.clone(), + y.clone(), Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new(noise_params.ore_vein_a().clone(), None)), 4f64, @@ -218,9 +226,9 @@ impl<'a> NoiseRouter<'a> { .abs(), ); - let function19 = Arc::new( + let ore_vein_b = Arc::new( veritcal_range_choice( - function16, + y, Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new(noise_params.ore_vein_b().clone(), None)), 4f64, @@ -233,24 +241,24 @@ impl<'a> NoiseRouter<'a> { .abs(), ); - let function20 = Arc::new( + let ore_vein = Arc::new( DensityFunction::Constant(ConstantFunction::new(-0.08f64)) - .add(Arc::new(function18.binary_max(function19))), + .add(Arc::new(ore_vein_a.binary_max(ore_vein_b))), ); - let function21 = Arc::new(DensityFunction::Noise(NoiseFunction::new( + let ore_gap = Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new(noise_params.ore_gap().clone(), None)), 1f64, 1f64, ))); Self { - barrier: function, - fluid_level_floodedness: function2, - fluid_level_spread: function3, - lava: function4, - temperature: function7, - vegetation: function8, + barrier: aquifier_barrier, + fluid_level_floodedness: aquifier_fluid_level_floodedness, + fluid_level_spread: aquifer_fluid_level_spread, + lava: aquifer_lava, + temperature, + vegetation, continents: if large_biomes { noise_funcs.continents_overworld_large_biome().clone() } else { @@ -261,16 +269,20 @@ impl<'a> NoiseRouter<'a> { } else { noise_funcs.erosion_overworld().clone() }, - depth: function10, + depth: depth_overworld, ridges: noise_funcs.ridges_overworld().clone(), internal_density: Arc::new(apply_surface_slides( amplified, - Arc::new(function11.add_const(-0.703125).clamp(-64f64, 64f64)), + Arc::new( + mapped_depth_overworld + .add_const(-0.703125) + .clamp(-64f64, 64f64), + ), )), - final_densitiy: function15, - vein_toggle: function17, - vein_ridged: function20, - vein_gap: function21, + final_densitiy: blended_cave_entrances_overworld, + vein_toggle: ore_veininess, + vein_ridged: ore_vein, + vein_gap: ore_gap, } } } @@ -322,26 +334,26 @@ fn create_caves<'a>( noise_params: &BuiltInNoiseParams<'a>, sloped_cheese: Arc>, ) -> DensityFunction<'a> { - let function = noise_funcs.caves_spaghetti_2d_overworld().clone(); - let function2 = noise_funcs + let caves_spaghetti_2d = noise_funcs.caves_spaghetti_2d_overworld().clone(); + let caves_spaghetti_roughness = noise_funcs .caves_spaghetti_roughness_function_overworld() .clone(); - let function3 = Arc::new(DensityFunction::Noise(NoiseFunction::new( + let cave_layer = Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new(noise_params.cave_layer().clone(), None)), 1f64, 8f64, ))); - let function4 = Arc::new( - DensityFunction::Constant(ConstantFunction::new(4f64)).mul(Arc::new(function3.square())), + let scaled_cave_layer = Arc::new( + DensityFunction::Constant(ConstantFunction::new(4f64)).mul(Arc::new(cave_layer.square())), ); - let function5 = Arc::new(DensityFunction::Noise(NoiseFunction::new( + let cave_cheese = Arc::new(DensityFunction::Noise(NoiseFunction::new( Arc::new(InternalNoise::new(noise_params.cave_cheese().clone(), None)), 1f64, 0.6666666666666666f64, ))); - let function6 = Arc::new( + let scaled_cave_cheese = Arc::new( DensityFunction::Constant(ConstantFunction::new(0.27f64)) - .add(function5) + .add(cave_cheese) .clamp(-1f64, 1f64) .add(Arc::new( DensityFunction::Constant(ConstantFunction::new(1.5f64)) @@ -352,19 +364,19 @@ fn create_caves<'a>( .clamp(0f64, 0.5f64), )), ); - let function7 = Arc::new(function4.add(function6)); - let function8 = function7 + let final_cave_layer = Arc::new(scaled_cave_layer.add(scaled_cave_cheese)); + let cave_entrances = final_cave_layer .binary_min(noise_funcs.caves_entrances_overworld().clone()) - .binary_min(Arc::new(function.add(function2))); - let function9 = noise_funcs.caves_pillars_overworld().clone(); - let function10 = Arc::new(DensityFunction::Range(RangeFunction::new( - function9.clone(), + .binary_min(Arc::new(caves_spaghetti_2d.add(caves_spaghetti_roughness))); + let pillars = noise_funcs.caves_pillars_overworld().clone(); + let scaled_pillars = Arc::new(DensityFunction::Range(RangeFunction::new( + pillars.clone(), -1000000f64, 0.03f64, Arc::new(DensityFunction::Constant(ConstantFunction::new( -1000000f64, ))), - function9, + pillars, ))); - function8.binary_max(function10) + cave_entrances.binary_max(scaled_pillars) }