diff --git a/pumpkin-world/src/generation/noise/aquifer_sampler.rs b/pumpkin-world/src/generation/noise/aquifer_sampler.rs index 4e0e26a48..feff6ca62 100644 --- a/pumpkin-world/src/generation/noise/aquifer_sampler.rs +++ b/pumpkin-world/src/generation/noise/aquifer_sampler.rs @@ -297,6 +297,7 @@ impl WorldAquiferSampler { let z = block_z + section_coords::section_to_block(offset_z as i32); let n = height_estimator.estimate_height(x, z); + println!("estimate_height({}, {}) = {}", x, z, n); let o = n + 8; let bl2 = offset_x == 0 && offset_z == 0; @@ -1504,7 +1505,7 @@ mod random_positions_and_hypot { &mut height_estimator, &env, ); - assert_eq!(level.max_y, y1); + assert_eq!(level.max_y, y1, "Failed at x={}, y={}, z={}", x, y, z); assert_eq!(level.block, &state); } } diff --git a/pumpkin-world/src/generation/noise/router/surface_height_sampler.rs b/pumpkin-world/src/generation/noise/router/surface_height_sampler.rs index 0e0ed5890..f4f42752b 100644 --- a/pumpkin-world/src/generation/noise/router/surface_height_sampler.rs +++ b/pumpkin-world/src/generation/noise/router/surface_height_sampler.rs @@ -93,9 +93,6 @@ impl<'a> SurfaceHeightEstimateSampler<'a> { &sample_options, ); - let mut low = self.minimum_y; - let mut high = upper.ceil() as i32; - // First find the coarse cell that contains the surface let cell_height = fts.cell_height(); let mut y = (upper / cell_height as f64).floor() as i32 * cell_height; @@ -106,32 +103,12 @@ impl<'a> SurfaceHeightEstimateSampler<'a> { &sample_options, ); if density > 0.0 { - low = y; - high = (y + cell_height).min(high); - break; + return y; } y -= cell_height; } - if y < self.minimum_y { - return self.minimum_y; - } - - // Binary search for precise surface - while high - low > 1 { - let mid = low + (high - low) / 2; - let density = ChunkNoiseFunctionComponent::sample_from_stack( - &mut self.component_stack[..=fts.density_index()], - &Vector3::new(aligned_x, mid, aligned_z), - &sample_options, - ); - if density > 0.0 { - low = mid; - } else { - high = mid; - } - } - return low + 1; + return self.minimum_y; } let surface_y = ChunkNoiseFunctionComponent::sample_from_stack( @@ -139,7 +116,7 @@ impl<'a> SurfaceHeightEstimateSampler<'a> { &pos, &sample_options, ); - surface_y.floor() as i32 + 1 + surface_y.floor() as i32 } #[must_use]