mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 06:01:14 +00:00
Core: Convert Math class to namespace
This commit is contained in:
parent
2303ce843a
commit
581d675eeb
10 changed files with 797 additions and 667 deletions
|
|
@ -31,18 +31,19 @@
|
|||
#include "math_funcs.h"
|
||||
|
||||
#include "core/error/error_macros.h"
|
||||
#include "core/math/random_pcg.h"
|
||||
|
||||
RandomPCG Math::default_rand(RandomPCG::DEFAULT_SEED, RandomPCG::DEFAULT_INC);
|
||||
static RandomPCG default_rand;
|
||||
|
||||
uint32_t Math::rand_from_seed(uint64_t *seed) {
|
||||
RandomPCG rng = RandomPCG(*seed, RandomPCG::DEFAULT_INC);
|
||||
uint32_t Math::rand_from_seed(uint64_t *p_seed) {
|
||||
RandomPCG rng = RandomPCG(*p_seed);
|
||||
uint32_t r = rng.rand();
|
||||
*seed = rng.get_seed();
|
||||
*p_seed = rng.get_seed();
|
||||
return r;
|
||||
}
|
||||
|
||||
void Math::seed(uint64_t x) {
|
||||
default_rand.seed(x);
|
||||
void Math::seed(uint64_t p_value) {
|
||||
default_rand.seed(p_value);
|
||||
}
|
||||
|
||||
void Math::randomize() {
|
||||
|
|
@ -53,8 +54,8 @@ uint32_t Math::rand() {
|
|||
return default_rand.rand();
|
||||
}
|
||||
|
||||
double Math::randfn(double mean, double deviation) {
|
||||
return default_rand.randfn(mean, deviation);
|
||||
double Math::randfn(double p_mean, double p_deviation) {
|
||||
return default_rand.randfn(p_mean, p_deviation);
|
||||
}
|
||||
|
||||
int Math::step_decimals(double p_step) {
|
||||
|
|
@ -168,14 +169,14 @@ uint32_t Math::larger_prime(uint32_t p_val) {
|
|||
}
|
||||
}
|
||||
|
||||
double Math::random(double from, double to) {
|
||||
return default_rand.random(from, to);
|
||||
double Math::random(double p_from, double p_to) {
|
||||
return default_rand.random(p_from, p_to);
|
||||
}
|
||||
|
||||
float Math::random(float from, float to) {
|
||||
return default_rand.random(from, to);
|
||||
float Math::random(float p_from, float p_to) {
|
||||
return default_rand.random(p_from, p_to);
|
||||
}
|
||||
|
||||
int Math::random(int from, int to) {
|
||||
return default_rand.random(from, to);
|
||||
int Math::random(int p_from, int p_to) {
|
||||
return default_rand.random(p_from, p_to);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue