BLI: use less hacky source of randomness when generating random seed

This commit is contained in:
Jacques Lucke
2024-01-24 09:59:43 +01:00
parent 52a31ce31b
commit 0d420ee97a

View File

@@ -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)