refactor: replace Mth with GameMath, switch to stdlib math and std::numbers::pi

Inlined trivial wrappers, moved ranged random methods to Random, replaced M_PI with std::numbers::pi, unified DEGRAD/RAD_TO_GRAD as DEG_TO_RAD, fixed getInt/getDouble default fallback bug, and switched non-worldgen sin/cos to sinf/cosf.
This commit is contained in:
MatthewBeshay
2026-03-31 13:11:32 +11:00
parent 56dfb0badf
commit 8f0c2a3f26
233 changed files with 1662 additions and 1778 deletions

View File

@@ -82,6 +82,21 @@ int Random::nextInt(int n) {
float Random::nextFloat() { return next(24) / ((float)(1 << 24)); }
float Random::nextFloat(float min, float max) {
if (min >= max) return min;
return (nextFloat() * (max - min)) + min;
}
int Random::nextInt(int minInclusive, int maxInclusive) {
if (minInclusive >= maxInclusive) return minInclusive;
return nextInt(maxInclusive - minInclusive + 1) + minInclusive;
}
double Random::nextDouble(double min, double max) {
if (min >= max) return min;
return (nextDouble() * (max - min)) + min;
}
int64_t Random::nextLong() {
// 4jcraft added casts to unsigned
return (int64_t)((uint64_t)next(32) << 32) + next(32);