You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
[Core] Fix rand_weighted not using the current state
The method incorrectly used `Math::randf` instead of `randf`
This commit is contained in:
@@ -52,7 +52,7 @@ int64_t RandomPCG::rand_weighted(const Vector<float> &p_weights) {
|
|||||||
weights_sum += weights[i];
|
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) {
|
for (int64_t i = 0; i < weights_size; ++i) {
|
||||||
remaining_distance -= weights[i];
|
remaining_distance -= weights[i];
|
||||||
if (remaining_distance < 0) {
|
if (remaining_distance < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user