Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Sfmt Class Reference

Public Member Functions

 Sfmt ()
 By default we seed with Seed()
 
 Sfmt (const AZ::u32 *keys, int numKeys)
 Seed the generator with user defined seed Seed(AZ::u32* keys, int numKeys)
 
void Seed ()
 Seed the generator, with the best pseudo-random number the system can generate BetterPseudoRandom.
 
void Seed (const AZ::u32 *keys, int numKeys)
 Seed the generator with user defined seed.
 
AZ::u32 Rand32 ()
 Return u32 pseudo random integer.
 
AZ::u64 Rand64 ()
 Return u64 pseudo random integer. IMPORTANT: You can't call Rand64 after Rand32 (you need 2x Rand32).
 
void FillArray32 (AZ::u32 *array, int size)
 Fill an array with u32 pseudo random integers. array size MUST be > GetMinArray32Size() and a multiple of 4 (16 bytes since we use SIMD).
 
void FillArray64 (AZ::u64 *array, int size)
 Fill an array with u64 pseudo random integers. array size MUST be > GetMinArray64Size() and a multiple of 2 (16 bytes since we use SIMD).
 
double RandR32 ()
 returns [0,1]
 
double RandR32_1 ()
 returns [0,1)
 
double RandR32_2 ()
 returns (0,1)
 
int GetMinArray32Size () const
 Get the minimum array 32 size for FillArray32 function.
 
int GetMinArray64Size () const
 Get the minimum array 32 size for FillArray64 function.
 

Static Public Member Functions

static SfmtGetInstance ()
 
static void Create ()
 Creates a global instance of Smft using AZ::EnvironmentVariable.
 
static void Destroy ()
 Releases a global instance of Smft.
 

Protected Member Functions

void PeriodCertification ()
 

Protected Attributes

SfmtInternal::w128_t m_sfmt [SfmtInternal::N]
 
size_t m_index = 0
 
AZ::u32 * m_psfmt32 = nullptr
 Index into the pre-generated tables.
 
AZ::u64 * m_psfmt64 = nullptr
 Read only tables of pre-generated random numbers.
 
AZStd::mutex m_sfmtMutex
 

Member Function Documentation

◆ GetInstance()

static Sfmt & AZ::Sfmt::GetInstance ( )
static

Returns the default global instance of the Sfmt, initialized with time(NULL) as seed. We recommend creating your own instances when you need a big set of random numbers.


The documentation for this class was generated from the following file: