Extract 'new_method5' from 'apply_paths_to'

This commit is contained in:
Dr. Dystopia
2021-06-01 23:38:05 +02:00
parent adbd582240
commit dea6ebfff0

View File

@ -37,21 +37,25 @@ const EMPTY_AIR: Block = Block::air(SpriteKind::Empty);
pub fn apply_paths_to(canvas: &mut Canvas) {
canvas.foreach_col(|canvas, wpos2d, col| {
if let Some((path_dist, path_nearest, path, _)) =
col.path.filter(|(dist, _, path, _)| *dist < path.width)
{
let info = canvas.info();
let (riverless_alt, alt, water_dist) = new_method(info, col, path_nearest);
let (bridge_offset, depth) = new_method1(riverless_alt, alt, water_dist);
let surface_z = (riverless_alt + bridge_offset).floor() as i32;
new_method4(canvas, wpos2d, col, path_dist, path, info, bridge_offset, depth, surface_z);
new_method3(canvas, wpos2d, path_dist, path, surface_z)
}
new_method5(canvas, wpos2d, col)
});
}
//TODO: Rename
fn new_method5(canvas: &mut Canvas, wpos2d: Vec2<i32>, col: &ColumnSample) {
if let Some((path_dist, path_nearest, path, _)) =
col.path.filter(|(dist, _, path, _)| *dist < path.width)
{
let info = canvas.info();
let (riverless_alt, alt, water_dist) = new_method(info, col, path_nearest);
let (bridge_offset, depth) = new_method1(riverless_alt, alt, water_dist);
let surface_z = (riverless_alt + bridge_offset).floor() as i32;
new_method4(canvas, wpos2d, col, path_dist, path, info, bridge_offset, depth, surface_z);
new_method3(canvas, wpos2d, path_dist, path, surface_z)
}
}
//TODO: Rename
fn new_method(info: CanvasInfo, col: &ColumnSample, path_nearest: Vec2<f32>) -> (f32, f32, f32) {
// Try to use the column at the centre of the path for sampling to make them