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

fix sample nbrs error

This commit is contained in:
Justin Lin
2022-04-19 11:05:51 +08:00
parent 68e7b5d517
commit ac0e57f91b
2 changed files with 7 additions and 7 deletions

View File

@@ -124,10 +124,10 @@ function _coord_entropy_weights(coord_entropy_weights_lt, leng, m, i = 1) =
- tilemap_wf(tm)
*/
function tilemap(width, height, sample, nbr_dirs) = [
function tilemap(width, height, sample) = [
width,
height,
compatibilities_of_tiles(sample, nbr_dirs),
compatibilities_of_tiles(sample),
wave_function(width, height, weights_of_tiles(sample))
];
@@ -198,11 +198,11 @@ function neighbor_dirs(x, y, width, height) = [
if(y < height - 1) [ 0, 1] // bottom
];
function neighbor_compatibilities(sample, x, y, nbr_dirs) =
function neighbor_compatibilities(sample, x, y, width, height) =
let(me = sample[y][x])
[for(dir = nbr_dirs[y][x]) [me, sample[y + dir.y][x + dir.x], dir]];
[for(dir = neighbor_dirs(x, y, width, height)) [me, sample[y + dir.y][x + dir.x], dir]];
function compatibilities_of_tiles(sample, nbr_dirs) =
function compatibilities_of_tiles(sample) =
let(
width = len(sample[0]),
height = len(sample),
@@ -210,7 +210,7 @@ function compatibilities_of_tiles(sample, nbr_dirs) =
)
hashset_elems(hashset([
for(y = [0:height - 1], x = rx)
each neighbor_compatibilities(sample, x, y, nbr_dirs)
each neighbor_compatibilities(sample, x, y, width, height)
], number_of_buckets = width * height));
function collapsed_tiles(wf) =

View File

@@ -10,7 +10,7 @@ function tile_wfc(size, sample) =
for(y = [0:h - 1])
[for(x = [0:w - 1]) neighbor_dirs(x, y, w, h)]
],
tm = tilemap(w, h, sample, nbr_dirs),
tm = tilemap(w, h, sample),
// random start
x = floor(rand(w * 0.25, w * 0.75)),
y = floor(rand(h * 0.25, h * 0.75)),