mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-23 08:05:32 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user