Skip to content

Commit

Permalink
Merge pull request #89619 from AThousandShips/rand_fix
Browse files Browse the repository at this point in the history
[Core] Fix `rand_weighted` not using the current state
  • Loading branch information
akien-mga committed Mar 24, 2024
2 parents aa0e57e + 9c518d5 commit c258da3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/math/random_pcg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int64_t RandomPCG::rand_weighted(const Vector<float> &p_weights) {
weights_sum += weights[i];
}

float remaining_distance = Math::randf() * weights_sum;
float remaining_distance = randf() * weights_sum;
for (int64_t i = 0; i < weights_size; ++i) {
remaining_distance -= weights[i];
if (remaining_distance < 0) {
Expand Down

0 comments on commit c258da3

Please sign in to comment.