mirror of https://github.com/axmolengine/axmol.git
fix getEngine
This commit is contained in:
parent
6722f8d546
commit
89cf0c1e8c
|
@ -37,18 +37,18 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T random_real(T min, T max) {
|
static inline T random_real(T min, T max) {
|
||||||
std::uniform_real_distribution<T> dist(min, max);
|
std::uniform_real_distribution<T> dist(min, max);
|
||||||
std::mt19937 mt = RandomHelper::getEngine();
|
auto &mt = RandomHelper::getEngine();
|
||||||
return dist(mt);
|
return dist(mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T random_int(T min, T max) {
|
static inline T random_int(T min, T max) {
|
||||||
std::uniform_int_distribution<> dist(min, max);
|
std::uniform_int_distribution<> dist(min, max);
|
||||||
std::mt19937 mt = RandomHelper::getEngine();
|
auto &mt = RandomHelper::getEngine();
|
||||||
return dist(mt);
|
return dist(mt);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static std::mt19937 getEngine() {
|
static std::mt19937 &getEngine() {
|
||||||
static std::random_device seed_gen;
|
static std::random_device seed_gen;
|
||||||
static std::mt19937 engine(seed_gen());
|
static std::mt19937 engine(seed_gen());
|
||||||
return engine;
|
return engine;
|
||||||
|
|
Loading…
Reference in New Issue