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

refactor: just test threshold < state_weight[1]

This commit is contained in:
Justin Lin
2022-03-20 12:47:24 +08:00
parent f0bc7e5dc2
commit 6f9660a67d

View File

@@ -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]);