Skip to content

Commit

Permalink
Core: Convert Math class to namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Jul 27, 2024
1 parent 97b8ad1 commit 56158da
Show file tree
Hide file tree
Showing 8 changed files with 662 additions and 670 deletions.
29 changes: 15 additions & 14 deletions core/math/math_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(RandomPCG::DEFAULT_SEED, RandomPCG::DEFAULT_INC);

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, RandomPCG::DEFAULT_INC);
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() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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

0 comments on commit 56158da

Please sign in to comment.