diff --git a/src/maze/_impl/_mz_hex_walls.scad b/src/maze/_impl/_mz_hex_walls.scad index 471a6ef5..03a7dc60 100644 --- a/src/maze/_impl/_mz_hex_walls.scad +++ b/src/maze/_impl/_mz_hex_walls.scad @@ -39,11 +39,10 @@ function _build_cell(cell_radius, cell) = _row_wall(cell_radius, x, y), [_is_top_wall(cell) || _is_top_right_wall(cell) ? _top(cell_radius) : []], [_is_right_wall(cell) || _is_top_right_wall(cell) ? _right_wall(cell_radius, x) : []] - ) + ), + cell_p = _cell_position(cell_radius, x, y) ) [ for(wall = walls) - if(wall != []) - [for(p = wall) - _cell_position(cell_radius, x, y) + p] + if(wall != []) [for(p = wall) cell_p + p] ]; diff --git a/src/maze/_impl/_mz_square_initialize.scad b/src/maze/_impl/_mz_square_initialize.scad index e86ff68c..3ae89dd8 100644 --- a/src/maze/_impl/_mz_square_initialize.scad +++ b/src/maze/_impl/_mz_square_initialize.scad @@ -2,15 +2,14 @@ use <_mz_square_comm.scad>; // create a starting maze for being visited later. function _rc_maze(rows, columns) = [ - for(y = [0:rows - 1]) - for(x = [0:columns - 1]) - cell( - x, y, - // all cells have top and right walls - 3, - // unvisited - false - ) + for(y = [0:rows - 1], x = [0:columns - 1]) + cell( + x, y, + // all cells have top and right walls + 3, + // unvisited + false + ) ]; function _mz_mask(mask) = diff --git a/src/noise/_impl/_nz_cell_impl.scad b/src/noise/_impl/_nz_cell_impl.scad index 89d05409..84a91dda 100644 --- a/src/noise/_impl/_nz_cell_impl.scad +++ b/src/noise/_impl/_nz_cell_impl.scad @@ -9,10 +9,10 @@ function _chebyshev(p1, p2) = function _nz_cell_classic(cells, p, dist) = let( dists = [ - for(i = [0:len(cells) - 1]) - dist == "euclidean" ? norm(cells[i] - p) : - dist == "manhattan" ? _manhattan(cells[i] - p) : - dist == "chebyshev" ? _chebyshev(cells[i], p) : + for(cell = cells) + dist == "euclidean" ? norm(cell - p) : + dist == "manhattan" ? _manhattan(cell - p) : + dist == "chebyshev" ? _chebyshev(cell, p) : assert("Unknown distance option") ] ) @@ -21,13 +21,15 @@ function _nz_cell_classic(cells, p, dist) = function _nz_cell_border(cells, p) = let( dists = [ - for(i = [0:len(cells) - 1]) - [each cells[i], norm(cells[i] - p)] + for(cell = cells) + [each cell, norm(cell - p)] ], idx = len(cells[0]), sorted = sort(dists, by = "idx", idx = idx), - a = [for(i = [0:idx - 1]) sorted[0][i]], - b = [for(i = [0:idx - 1]) sorted[1][i]], + sorted0 = sorted[0], + sorted1 = sorted[1], + a = [for(i = [0:idx - 1]) sorted0[i]], + b = [for(i = [0:idx - 1]) sorted1[i]], m = (a + b) / 2 ) (p - m) * (a - m); \ No newline at end of file diff --git a/src/noise/_impl/_nz_worley3_impl.scad b/src/noise/_impl/_nz_worley3_impl.scad index ca4c4fd9..1f9101d4 100644 --- a/src/noise/_impl/_nz_worley3_impl.scad +++ b/src/noise/_impl/_nz_worley3_impl.scad @@ -5,17 +5,17 @@ function _neighbors(fcord, seed, grid_w) = let(range = [-1:1]) [ for(z = range, y = range, x = range) - let( - nx = fcord.x + x, - ny = fcord.y + y, - nz = fcord.z + z, - sd_base = abs(nx + ny * grid_w + nz * grid_w * grid_w), - sd1 = _lookup_noise_table(seed + sd_base), - sd2 = _lookup_noise_table(sd1 * 255 + sd_base), - sd3 = _lookup_noise_table(sd2 * 255 + sd_base), - nbr = [(nx + sd1) * grid_w, (ny + sd2) * grid_w, (nz + sd3) * grid_w] - ) - nbr + let( + nx = fcord.x + x, + ny = fcord.y + y, + nz = fcord.z + z, + sd_base = abs(nx + ny * grid_w + nz * grid_w * grid_w), + sd1 = _lookup_noise_table(seed + sd_base), + sd2 = _lookup_noise_table(sd1 * 255 + sd_base), + sd3 = _lookup_noise_table(sd2 * 255 + sd_base), + nbr = [(nx + sd1) * grid_w, (ny + sd2) * grid_w, (nz + sd3) * grid_w] + ) + nbr ]; function _nz_worley3_classic(p, nbrs, dist) =