74cb74d3c9
- namespace refactor (example: wiGraphics:: -> wi::graphics) - provided namespace compatibility macro for old user code: WICKEDENGINE_BACKWARDS_COMPATIBILITY_0_59 - resource manager will return `Resource` instead of `shared_ptr<Resource>` objects - MAD shader optimizations - implemented alpha to coverage with alpha tested materials when MSAA is enabled - alpha testing fix with transparent shadow maps - TLAS and scene buffers will be recreated less frequently when things get added/removed from the scene
44 lines
920 B
C++
44 lines
920 B
C++
#include "wiRandom.h"
|
|
|
|
#include <random>
|
|
|
|
namespace wi::random
|
|
{
|
|
inline static std::mt19937 &generator()
|
|
{
|
|
static std::random_device rand_dev;
|
|
static std::mt19937 generator(rand_dev());
|
|
return generator;
|
|
}
|
|
|
|
int GetRandom(int minValue, int maxValue)
|
|
{
|
|
std::uniform_int_distribution<int> distr(minValue, maxValue);
|
|
return distr(generator());
|
|
}
|
|
int GetRandom(int maxValue)
|
|
{
|
|
return GetRandom(0, maxValue);
|
|
}
|
|
|
|
uint32_t GetRandom(uint32_t minValue, uint32_t maxValue)
|
|
{
|
|
std::uniform_int_distribution<uint32_t> distr(minValue, maxValue);
|
|
return distr(generator());
|
|
}
|
|
uint32_t GetRandom(uint32_t maxValue)
|
|
{
|
|
return GetRandom(0u, maxValue);
|
|
}
|
|
|
|
uint64_t GetRandom(uint64_t minValue, uint64_t maxValue)
|
|
{
|
|
std::uniform_int_distribution<uint64_t> distr(minValue, maxValue);
|
|
return distr(generator());
|
|
}
|
|
uint64_t GetRandom(uint64_t maxValue)
|
|
{
|
|
return GetRandom(0ull, maxValue);
|
|
}
|
|
}
|