瀏覽代碼

Merge pull request #89619 from AThousandShips/rand_fix

[Core] Fix `rand_weighted` not using the current state
Rémi Verschelde 1 年之前
父節點
當前提交
c258da378b
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      core/math/random_pcg.cpp

+ 1 - 1
core/math/random_pcg.cpp

@@ -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) {