BLI: use less hacky source of randomness when generating random seed
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -366,8 +367,11 @@ namespace blender {
|
||||
|
||||
RandomNumberGenerator RandomNumberGenerator::from_random_seed()
|
||||
{
|
||||
const double time = BLI_check_seconds_timer() * 1000000.0;
|
||||
return RandomNumberGenerator(*reinterpret_cast<const uint32_t *>(&time));
|
||||
std::random_device rd;
|
||||
std::mt19937 e{rd()};
|
||||
std::uniform_int_distribution<uint32_t> dist;
|
||||
const uint32_t seed = dist(e);
|
||||
return RandomNumberGenerator(seed);
|
||||
}
|
||||
|
||||
void RandomNumberGenerator::seed_random(uint32_t seed)
|
||||
|
||||
Reference in New Issue
Block a user