diff --git a/src/experimental/_impl/_tiles_wfc_impl.scad b/src/experimental/_impl/_tiles_wfc_impl.scad index 22aea3a9..4e07b743 100644 --- a/src/experimental/_impl/_tiles_wfc_impl.scad +++ b/src/experimental/_impl/_tiles_wfc_impl.scad @@ -84,11 +84,11 @@ function wf_collapse(wf, x, y) = function _wf_collapse(wf, x, y, states_weights, leng, threshold, i = 0) = threshold < 0 || i == leng ? wf : - let( - state_weight = states_weights[i], - t = threshold - state_weight[1] - ) - _wf_collapse(t < 0 ? _oneStateAt(wf, x, y, state_weight[0]) : wf, x, y, states_weights, leng, t, i + 1); + let(state_weight = states_weights[i]) + _wf_collapse( + threshold < state_weight[1] ? _oneStateAt(wf, x, y, state_weight[0]) : wf, + x, y, states_weights, leng, threshold - state_weight[1], i + 1 + ); function _oneStateAt(wf, x, y, state) = _replaceStatesAt(wf, x, y, [state]);