diff --git a/src/maze/mz_hex_walls.scad b/src/maze/mz_hex_walls.scad index 960d5730..be51f43d 100644 --- a/src/maze/mz_hex_walls.scad +++ b/src/maze/mz_hex_walls.scad @@ -11,40 +11,33 @@ use <_impl/_mz_hex_walls.scad>; function mz_hex_walls(cells, rows, columns, cell_radius, left_border = true, bottom_border = true) = - let( - walls = [for(cell = cells, wall = _build_cell(cell_radius, cell)) wall], - left_pair_walls = left_border ? [ + [ + each [for(cell = cells, wall = _build_cell(cell_radius, cell)) wall], + + if(left_border) each [ for(y = [0:rows - 1]) let( cell_p = _cell_position(cell_radius, 0, y), walls1 = _top_left(cell_radius), walls2 = _bottom_left(cell_radius) ) - [ - [walls1[0] + cell_p, walls1[1] + cell_p], - [walls2[0] + cell_p, walls2[1] + cell_p] + each [ + [walls1[0] + cell_p, walls1[1] + cell_p], + [walls2[0] + cell_p, walls2[1] + cell_p] ] - ] : [], - left_border_walls = [for(pair = left_pair_walls) each pair], - bottom_pair_walls = bottom_border ? [ + ], + + if(bottom_border) each [ for(x = [0:columns - 1]) let( cell_p = _cell_position(cell_radius, x, 0), - walls1 = _bottom(cell_radius), - walls2 = [ - for(pair = (x % 2 == 0 ? [_bottom_left(cell_radius), _bottom_right(cell_radius)] : [])) - each pair - ] + walls1 = _bottom(cell_radius) ) - walls2 == [] ? - [ - [walls1[0] + cell_p, walls1[1] + cell_p] - ] : - [ - [walls1[0] + cell_p, walls1[1] + cell_p], - [walls2[0] + cell_p, walls2[1] + cell_p] - ] - ] : [], - bottom_border_walls = [for(pair = bottom_pair_walls) each pair] - ) - concat(walls, left_border_walls, bottom_border_walls); \ No newline at end of file + each [ + [walls1[0] + cell_p, walls1[1] + cell_p], + if(x % 2 == 0) + let(walls2 = [each _bottom_left(cell_radius), each _bottom_right(cell_radius)]) + [walls2[0] + cell_p, walls2[1] + cell_p] + ] + ] + ]; diff --git a/src/maze/mz_square_walls.scad b/src/maze/mz_square_walls.scad index c3fdb1bc..bedf75d3 100644 --- a/src/maze/mz_square_walls.scad +++ b/src/maze/mz_square_walls.scad @@ -18,11 +18,9 @@ function mz_square_walls(cells, rows, columns, cell_width, left_border = true, b concat( [ for(cell = cells) - let( - wall_pts = _square_walls(cell, cell_width), - pts = len(wall_pts) == 4 ? [wall_pts[0], wall_pts[1], wall_pts[3]]: wall_pts - ) - if(pts != []) pts + let(wall_pts = _square_walls(cell, cell_width)) + if(wall_pts != []) + len(wall_pts) == 4 ? [wall_pts[0], wall_pts[1], wall_pts[3]]: wall_pts ] , left_walls, buttom_walls ); \ No newline at end of file