1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-12 01:34:12 +02:00

performance improved

This commit is contained in:
Justin Lin
2021-04-22 21:15:37 +08:00
parent e3b1e82cc8
commit 159c668e87

View File

@@ -79,14 +79,14 @@ function wf_collapse(wf, x, y) =
let( let(
weights = wf_weights(wf), weights = wf_weights(wf),
states_xy = wf_eigenstates_at(wf, x, y), states_xy = wf_eigenstates_at(wf, x, y),
weights_xy = hashmap([ weights_xy = [
for(state = hashmap_keys(weights)) for(state = hashmap_keys(weights))
if(has(states_xy, state)) if(has(states_xy, state))
[state, hashmap_get(weights, state)] [state, hashmap_get(weights, state)]
]), ],
totalWeights = sum(hashmap_values(weights_xy)), totalWeights = sum([for(w = weights_xy) w[1]]),
threshold = rand() * totalWeights, threshold = rand() * totalWeights,
states_weights = hashmap_entries(weights_xy) states_weights = weights_xy
) )
_wf_collapse(wf, x, y, states_weights, len(states_weights), threshold); _wf_collapse(wf, x, y, states_weights, len(states_weights), threshold);