mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-01 20:40:28 +02:00
refactor
This commit is contained in:
@@ -16,5 +16,25 @@ function _nz_worley2(p, seed, grid_w, dist) =
|
|||||||
fcord = [floor(p.x / grid_w), floor(p.y / grid_w)],
|
fcord = [floor(p.x / grid_w), floor(p.y / grid_w)],
|
||||||
nbrs = _neighbors(fcord, seed, grid_w)
|
nbrs = _neighbors(fcord, seed, grid_w)
|
||||||
)
|
)
|
||||||
dist == "border" ? _nz_worley_border(p, nbrs) :
|
dist == "euclidean" ? _nz_worley_euclidean(p, nbrs) :
|
||||||
_nz_worley_classic(p, nbrs, dist);
|
dist == "manhattan" ? _nz_worley_manhattan(p, nbrs) :
|
||||||
|
dist == "chebyshev" ? _nz_worley_chebyshev(p, nbrs) :
|
||||||
|
dist == "border" ? _nz_worley_border(p, nbrs) :
|
||||||
|
assert("Unknown distance option");
|
||||||
|
|
||||||
|
function _nz_worley2s(points, seed, grid_w, dist) =
|
||||||
|
let(
|
||||||
|
noise = dist == "euclidean" ? function(p, nbrs) _nz_worley_euclidean(p, nbrs) :
|
||||||
|
dist == "manhattan" ? function(p, nbrs) _nz_worley_manhattan(p, nbrs) :
|
||||||
|
dist == "chebyshev" ? function(p, nbrs) _nz_worley_chebyshev(p, nbrs) :
|
||||||
|
dist == "border" ? function(p, nbrs) _nz_worley_border(p, nbrs) :
|
||||||
|
assert("Unknown distance option")
|
||||||
|
)
|
||||||
|
[
|
||||||
|
for(p = points)
|
||||||
|
let(
|
||||||
|
fcord = [floor(p.x / grid_w), floor(p.y / grid_w)],
|
||||||
|
nbrs = _neighbors(fcord, seed, grid_w)
|
||||||
|
)
|
||||||
|
noise(p, nbrs)
|
||||||
|
];
|
@@ -13,4 +13,4 @@ use <_impl/_nz_worley2_impl.scad>;
|
|||||||
|
|
||||||
function nz_worley2s(points, seed, grid_w = 10, dist = "euclidean") =
|
function nz_worley2s(points, seed, grid_w = 10, dist = "euclidean") =
|
||||||
let(sd = is_undef(seed) ? rand() : seed)
|
let(sd = is_undef(seed) ? rand() : seed)
|
||||||
[for(p = points) _nz_worley2(p, sd, grid_w, dist)];
|
_nz_worley2s(points, sd, grid_w, dist);
|
Reference in New Issue
Block a user