TrinityCore
|
#include <PrecomputedRandom.h>
Classes | |
class | HemiUniformData |
class | SphereBitsData |
Public Member Functions | |
PrecomputedRandom (const HemiUniformData *data1, const SphereBitsData *data2, int dataSize, uint32 seed=0xF018A4D2) | |
PrecomputedRandom (int dataSize, uint32 seed=0xF018A4D2) | |
~PrecomputedRandom () | |
virtual uint32 | bits () |
virtual float | uniform (float low, float high) |
virtual float | uniform () |
virtual void | cosHemi (float &x, float &y, float &z) |
virtual void | cosPowHemi (const float k, float &x, float &y, float &z) |
virtual void | sphere (float &x, float &y, float &z) |
Public Member Functions inherited from G3D::Random | |
Random (uint32 seed=0xF018A4D2, bool threadsafe=true) | |
virtual | ~Random () |
virtual void | reset (uint32 seed=0xF018A4D2, bool threadsafe=true) |
virtual int | integer (int min, int max) |
virtual float | gaussian (float mean, float stdev) |
virtual void | cosSphere (float &x, float &y, float &z) |
virtual void | hemi (float &x, float &y, float &z) |
Protected Attributes | |
const HemiUniformData * | m_hemiUniform |
const SphereBitsData * | m_sphereBits |
int | m_modMask |
int | m_index |
bool | m_freeData |
Protected Attributes inherited from G3D::Random | |
Spinlock | lock |
uint32 * | state |
int | index |
bool | m_threadsafe |
Additional Inherited Members | |
Static Public Member Functions inherited from G3D::Random | |
static Random & | common () |
Protected Types inherited from G3D::Random | |
enum | { N = 624, M = 397, R = 31, U = 11, S = 7, T = 15, L = 18, A = 0x9908B0DF, B = 0x9D2C5680, C = 0xEFC60000 } |
Protected Member Functions inherited from G3D::Random | |
virtual void | generate () |
Random (void *) | |
Fast random numbers using a precomputed data table.
e.g., generates cosHemi about 13x faster than Random. This is useful for quickly generating seeded random numbers for reproducibility. G3D::Random takes a long time to seed; this is instantaneous (providing the precomputed data is already available.)
Not threadsafe.
G3D::PrecomputedRandom::PrecomputedRandom | ( | const HemiUniformData * | data1, |
const SphereBitsData * | data2, | ||
int | dataSize, | ||
uint32 | seed = 0xF018A4D2 |
||
) |
G3D::PrecomputedRandom::PrecomputedRandom | ( | int | dataSize, |
uint32 | seed = 0xF018A4D2 |
||
) |
dataSize | Number of random numbers that can be requested before periodicity. Must be a power of 2. |
G3D::PrecomputedRandom::~PrecomputedRandom | ( | ) |
|
virtual |
Each bit is random. Subclasses can choose to override just this method and the other methods will all work automatically.
Reimplemented from G3D::Random.
|
virtual |
Returns 3D unit vectors distributed according to a cosine distribution about the z axis.
Reimplemented from G3D::Random.
|
virtual |
Returns 3D unit vectors distributed according to a cosine power distribution ( ) about the z-axis.
Reimplemented from G3D::Random.
|
virtual |
Returns 3D unit vectors uniformly distributed on the sphere
Reimplemented from G3D::Random.
|
virtual |
Uniform random float on the range [min, max]
Reimplemented from G3D::Random.
|
virtual |
Uniform random float on the range [0, 1]
Reimplemented from G3D::Random.
|
protected |
If true, free m_hemiUniform and m_sphereBits in destructor
|
protected |
Array of 2^n elements.
|
protected |
|
protected |
2^n - 1; the AND mask for computing a fast modulo
|
protected |