1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-11 17:24:20 +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(
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);