Merge pull request #93893 from Togira123/fix-rand-weighted-return-value

Fix `rand_weighted` incorrectly returning -1
This commit is contained in:
Rémi Verschelde 2024-08-28 00:11:35 +02:00
commit 2fadd095a7
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 0 deletions

View File

@ -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; return -1;
} }