mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Fix RandomPCG::rand_weighted incorrectly returning -1
This commit is contained in:
@@ -60,6 +60,11 @@ int64_t RandomPCG::rand_weighted(const Vector<float> &p_weights) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int64_t i = weights_size - 1; i >= 0; --i) {
|
||||
if (weights[i] > 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user