From b8e52677b3a51d2c9a045f1931c359625cb5c28a Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 1 Apr 2022 22:15:24 +0800 Subject: [PATCH] refactor: cal px, py directly --- examples/voronoi/ripples.scad | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/voronoi/ripples.scad b/examples/voronoi/ripples.scad index 562809dd..f92871d5 100644 --- a/examples/voronoi/ripples.scad +++ b/examples/voronoi/ripples.scad @@ -16,21 +16,18 @@ ripples(); module ripples() { point_size = size / mesh_w; - points = [for(y = [0:point_size.y - 1], x = [0:point_size.x - 1]) [x, y] * mesh_w]; - - noise = [for(p = points) nz_worley2(p.x, p.y, seed, grid_w, dist)[2]]; - sf = [ for(y = [0:point_size.y - 1]) - [for(x = [0:point_size.x - 1]) - let( - i = point_size.x * y + x, - nz = noise[i], - p = points[i], - n = amplitude * nz_perlin2(nz + p.x / wave_smoothness, nz + p.y / wave_smoothness, seed) - ) - [p.x, p.y, n] - ] + [ + for(x = [0:point_size.x - 1]) + let( + px = x * mesh_w, + py = y * mesh_w, + nz = nz_worley2(px, py, seed, grid_w, dist)[2], + n = amplitude * nz_perlin2(nz + px / wave_smoothness, nz + py / wave_smoothness, seed) + ) + [px, py, n] + ] ]; sf_thicken(sf, thickness);