mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-01 20:40:28 +02:00
just check len(nbr_tiles) == 1
This commit is contained in:
@@ -114,15 +114,14 @@ function _coord_entropy_weights(coord_entropy_weights_lt, leng, m, i = 1) =
|
|||||||
let(cm = coord_entropy_weights_lt[i])
|
let(cm = coord_entropy_weights_lt[i])
|
||||||
_coord_entropy_weights(coord_entropy_weights_lt, leng, m[2][0] <= cm[2][0] ? m : cm, i + 1);
|
_coord_entropy_weights(coord_entropy_weights_lt, leng, m[2][0] <= cm[2][0] ? m : cm, i + 1);
|
||||||
|
|
||||||
function propagate(nbr_dirs, compatibilities, notCollaspedCoords, wf, coord) =
|
function propagate(nbr_dirs, compatibilities, wf, coord) =
|
||||||
_propagate(
|
_propagate(
|
||||||
nbr_dirs,
|
nbr_dirs,
|
||||||
compatibilities,
|
compatibilities,
|
||||||
notCollaspedCoords,
|
|
||||||
[wf, create_stack(coord)]
|
[wf, create_stack(coord)]
|
||||||
);
|
);
|
||||||
|
|
||||||
function _propagate(nbr_dirs, compatibilities, notCollaspedCoords, wf_stack) =
|
function _propagate(nbr_dirs, compatibilities, wf_stack) =
|
||||||
let(wf = wf_stack[0], stack = wf_stack[1])
|
let(wf = wf_stack[0], stack = wf_stack[1])
|
||||||
stack == [] ? wf :
|
stack == [] ? wf :
|
||||||
let(
|
let(
|
||||||
@@ -131,21 +130,21 @@ function _propagate(nbr_dirs, compatibilities, notCollaspedCoords, wf_stack) =
|
|||||||
cy = current_coord.y,
|
cy = current_coord.y,
|
||||||
current_tiles = wf_eigenstates(wf)[cy][cx],
|
current_tiles = wf_eigenstates(wf)[cy][cx],
|
||||||
dirs = nbr_dirs[cy][cx],
|
dirs = nbr_dirs[cy][cx],
|
||||||
nx_wf_stack = _doDirs(compatibilities, notCollaspedCoords, [wf, stack[1]], current_coord, current_tiles, dirs, len(dirs))
|
nx_wf_stack = _doDirs(compatibilities, [wf, stack[1]], current_coord, current_tiles, dirs, len(dirs))
|
||||||
)
|
)
|
||||||
_propagate(nbr_dirs, compatibilities, notCollaspedCoords, nx_wf_stack);
|
_propagate(nbr_dirs, compatibilities, nx_wf_stack);
|
||||||
|
|
||||||
contradiction_msg = "A contradiction happens. Tiles have all been ruled out by your previous choices. Please try again.";
|
contradiction_msg = "A contradiction happens. Tiles have all been ruled out by your previous choices. Please try again.";
|
||||||
function _doDirs(compatibilities, notCollaspedCoords, wf_stack, current_coord, current_tiles, dirs, leng, i = 0) =
|
function _doDirs(compatibilities, wf_stack, current_coord, current_tiles, dirs, leng, i = 0) =
|
||||||
i == leng ? wf_stack :
|
i == leng ? wf_stack :
|
||||||
let(
|
let(
|
||||||
dir = dirs[i],
|
dir = dirs[i],
|
||||||
nbr = dir + current_coord,
|
nbr = dir + current_coord,
|
||||||
mx_wf_stack =
|
mx_wf_stack =
|
||||||
contains(notCollaspedCoords, nbr) ?
|
|
||||||
(
|
(
|
||||||
|
let(nbr_tiles = wf_eigenstates(wf_stack[0])[nbr.y][nbr.x])
|
||||||
|
len(nbr_tiles) == 1 ? wf_stack :
|
||||||
let(
|
let(
|
||||||
nbr_tiles = wf_eigenstates(wf_stack[0])[nbr.y][nbr.x],
|
|
||||||
compatible_nbr_tiles = [
|
compatible_nbr_tiles = [
|
||||||
for(nbr_tile = nbr_tiles)
|
for(nbr_tile = nbr_tiles)
|
||||||
if(compatible_nbr_tile(compatibilities, current_tiles, nbr_tile, dir)) nbr_tile
|
if(compatible_nbr_tile(compatibilities, current_tiles, nbr_tile, dir)) nbr_tile
|
||||||
@@ -161,17 +160,15 @@ function _doDirs(compatibilities, notCollaspedCoords, wf_stack, current_coord, c
|
|||||||
stack_push(wf_stack[1], nbr)
|
stack_push(wf_stack[1], nbr)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
:
|
|
||||||
wf_stack
|
|
||||||
)
|
)
|
||||||
_doDirs(compatibilities, notCollaspedCoords, mx_wf_stack, current_coord, current_tiles, dirs, leng, i + 1);
|
_doDirs(compatibilities, mx_wf_stack, current_coord, current_tiles, dirs, leng, i + 1);
|
||||||
|
|
||||||
function generate(nbr_dirs, compatibilities, wf, notCollaspedCoords) =
|
function generate(nbr_dirs, compatibilities, wf, notCollaspedCoords) =
|
||||||
len(notCollaspedCoords) == 0 ? collapsed_tiles(wf) :
|
len(notCollaspedCoords) == 0 ? collapsed_tiles(wf) :
|
||||||
let(
|
let(
|
||||||
coord_weights = wf_coord_weights_min_entropy(wf, notCollaspedCoords),
|
coord_weights = wf_coord_weights_min_entropy(wf, notCollaspedCoords),
|
||||||
weights = coord_weights[2],
|
weights = coord_weights[2],
|
||||||
nwf = propagate(nbr_dirs, compatibilities, notCollaspedCoords, wf_collapse(wf, coord_weights.x, coord_weights.y, weights), coord_weights)
|
nwf = propagate(nbr_dirs, compatibilities, wf_collapse(wf, coord_weights.x, coord_weights.y, weights), coord_weights)
|
||||||
)
|
)
|
||||||
generate(nbr_dirs, compatibilities, nwf, wf_not_collapsed_coords(nwf));
|
generate(nbr_dirs, compatibilities, nwf, wf_not_collapsed_coords(nwf));
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@ function tile_wfc(size, sample) =
|
|||||||
first_collasped_propagated = propagate(
|
first_collasped_propagated = propagate(
|
||||||
nbr_dirs,
|
nbr_dirs,
|
||||||
compatibilities,
|
compatibilities,
|
||||||
[for(cy = [0:h - 1], cx = [0:w - 1]) [cx, cy]],
|
|
||||||
wf_collapse(wf, x, y, weights),
|
wf_collapse(wf, x, y, weights),
|
||||||
[x, y]
|
[x, y]
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user