From 159c668e8719de9b4b46e9c3fc689ac108e843bf Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 22 Apr 2021 21:15:37 +0800 Subject: [PATCH] performance improved --- src/experimental/_impl/_tiles_wfc_impl.scad | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/experimental/_impl/_tiles_wfc_impl.scad b/src/experimental/_impl/_tiles_wfc_impl.scad index 4ac5d2dd..f0c4ff99 100644 --- a/src/experimental/_impl/_tiles_wfc_impl.scad +++ b/src/experimental/_impl/_tiles_wfc_impl.scad @@ -79,14 +79,14 @@ function wf_collapse(wf, x, y) = let( weights = wf_weights(wf), states_xy = wf_eigenstates_at(wf, x, y), - weights_xy = hashmap([ - for(state = hashmap_keys(weights)) - if(has(states_xy, state)) - [state, hashmap_get(weights, state)] - ]), - totalWeights = sum(hashmap_values(weights_xy)), + weights_xy = [ + for(state = hashmap_keys(weights)) + if(has(states_xy, state)) + [state, hashmap_get(weights, state)] + ], + totalWeights = sum([for(w = weights_xy) w[1]]), threshold = rand() * totalWeights, - states_weights = hashmap_entries(weights_xy) + states_weights = weights_xy ) _wf_collapse(wf, x, y, states_weights, len(states_weights), threshold);