2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// FastRandom.cpp
|
|
|
|
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "FastRandom.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-19 09:10:18 -04:00
|
|
|
|
2017-06-13 15:35:30 -04:00
|
|
|
MTRand & GetRandomProvider()
|
2014-04-07 13:52:35 -04:00
|
|
|
{
|
2020-05-10 12:16:49 -04:00
|
|
|
thread_local MTRand Random = []
|
|
|
|
{
|
|
|
|
cRandomDeviceSeeder Seeder;
|
|
|
|
return MTRand(Seeder);
|
|
|
|
}();
|
|
|
|
return Random;
|
2014-10-19 09:10:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-13 15:35:30 -04:00
|
|
|
UInt32 Detail::GetRandomSeed()
|
2014-10-19 09:10:18 -04:00
|
|
|
{
|
2020-05-10 12:16:49 -04:00
|
|
|
thread_local UInt32 SeedCounter = []
|
|
|
|
{
|
|
|
|
std::random_device rd;
|
|
|
|
std::uniform_int_distribution<UInt32> dist;
|
|
|
|
return dist(rd);
|
|
|
|
}();
|
2017-06-13 15:35:30 -04:00
|
|
|
return ++SeedCounter;
|
2014-04-07 13:52:35 -04:00
|
|
|
}
|