From 6f9660a67da430aff280110da651afd95c719fa1 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 20 Mar 2022 12:47:24 +0800 Subject: [PATCH] refactor: just test threshold < state_weight[1] --- src/experimental/_impl/_tiles_wfc_impl.scad | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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]);