Skip to content

Commit 581d675

Browse files
committed
Core: Convert Math class to namespace
1 parent 2303ce8 commit 581d675

File tree

10 files changed

+832
-702
lines changed

10 files changed

+832
-702
lines changed

core/io/resource.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "core/io/resource_loader.h"
3434
#include "core/math/math_funcs.h"
35+
#include "core/math/random_pcg.h"
3536
#include "core/os/os.h"
3637
#include "scene/main/node.h" //only so casting works
3738

@@ -113,7 +114,7 @@ void Resource::set_path_cache(const String &p_path) {
113114
GDVIRTUAL_CALL(_set_path_cache, p_path);
114115
}
115116

116-
static thread_local RandomPCG unique_id_gen(0, RandomPCG::DEFAULT_INC);
117+
static thread_local RandomPCG unique_id_gen = RandomPCG(0);
117118

118119
void Resource::seed_scene_unique_id(uint32_t p_seed) {
119120
unique_id_gen.seed(p_seed);

core/math/math_funcs.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@
3131
#include "math_funcs.h"
3232

3333
#include "core/error/error_macros.h"
34+
#include "core/math/random_pcg.h"
3435

35-
RandomPCG Math::default_rand(RandomPCG::DEFAULT_SEED, RandomPCG::DEFAULT_INC);
36+
static RandomPCG default_rand;
3637

37-
uint32_t Math::rand_from_seed(uint64_t *seed) {
38-
RandomPCG rng = RandomPCG(*seed, RandomPCG::DEFAULT_INC);
38+
uint32_t Math::rand_from_seed(uint64_t *p_seed) {
39+
RandomPCG rng = RandomPCG(*p_seed);
3940
uint32_t r = rng.rand();
40-
*seed = rng.get_seed();
41+
*p_seed = rng.get_seed();
4142
return r;
4243
}
4344

44-
void Math::seed(uint64_t x) {
45-
default_rand.seed(x);
45+
void Math::seed(uint64_t p_value) {
46+
default_rand.seed(p_value);
4647
}
4748

4849
void Math::randomize() {
@@ -53,8 +54,8 @@ uint32_t Math::rand() {
5354
return default_rand.rand();
5455
}
5556

56-
double Math::randfn(double mean, double deviation) {
57-
return default_rand.randfn(mean, deviation);
57+
double Math::randfn(double p_mean, double p_deviation) {
58+
return default_rand.randfn(p_mean, p_deviation);
5859
}
5960

6061
int Math::step_decimals(double p_step) {
@@ -168,14 +169,14 @@ uint32_t Math::larger_prime(uint32_t p_val) {
168169
}
169170
}
170171

171-
double Math::random(double from, double to) {
172-
return default_rand.random(from, to);
172+
double Math::random(double p_from, double p_to) {
173+
return default_rand.random(p_from, p_to);
173174
}
174175

175-
float Math::random(float from, float to) {
176-
return default_rand.random(from, to);
176+
float Math::random(float p_from, float p_to) {
177+
return default_rand.random(p_from, p_to);
177178
}
178179

179-
int Math::random(int from, int to) {
180-
return default_rand.random(from, to);
180+
int Math::random(int p_from, int p_to) {
181+
return default_rand.random(p_from, p_to);
181182
}

0 commit comments

Comments
 (0)