1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-18 20:41:18 +02:00

refactor: use m_replace

This commit is contained in:
Justin Lin
2022-04-17 11:45:20 +08:00
parent 598f75dba8
commit 202e9dd17e

View File

@@ -1,23 +1,15 @@
use <_mz_cube_comm.scad>; use <_mz_cube_comm.scad>;
use <../../util/shuffle.scad>; use <../../util/shuffle.scad>;
use <../../matrix/m_replace.scad>;
function update(cells, cell) = function update(cells, cell) =
let( let(
x = cell.x, x = cell.x,
y = cell.y, y = cell.y,
z = cell.z, z = cell.z,
rowY = [for(c = cells[z][y]) if(c.x == x) cell else c], rowY = [for(c = cells[z][y]) if(c.x == x) cell else c]
layerZ = [
for(r = [0:len(cells[z]) - 1])
if(r == y) rowY
else cells[z][r]
]
) )
[ m_replace(cells, y, z, rowY);
for(layer = [0:len(cells) - 1])
if(layer == z) layerZ
else cells[layer]
];
// is (x, y) visited? // is (x, y) visited?
function visited(x, y, z, cells) = cells[z][y][x][4]; function visited(x, y, z, cells) = cells[z][y][x][4];