Class HostRandom

Class Documentation

class flamegpu::HostRandom

Utility for accessing random generation within host functions This is prefered over using std random, as it uses a common seed with the device random This should only be instantiated by HostAPI

Public Functions

template<typename T>
inline T uniform() const

Returns a float uniformly distributed between 0.0 and 1.0.

Note

It may return from 0.0 to 1.0, where 0.0 is included and 1.0 is excluded.

Note

Available as float or double

Template Parameters

T – return type (must be floating point)

template<typename T>
inline T normal() const

Returns a normally distributed float with mean 0.0 and standard deviation 1.0.

Note

This result can be scaled and shifted to produce normally distributed values with any mean/stddev.

Note

Available as float or double

Template Parameters

T – return type (must be floating point)

template<typename T>
inline T logNormal(const T &mean, const T &stddev) const

Returns a log-normally distributed float based on a normal distribution with the given mean and standard deviation.

Note

Available as float or double

Template Parameters

T – return type (must be floating point)

template<typename T>
inline T uniform(const T &min, const T &max) const

Returns an integer uniformly distributed in the inclusive range [lowerBound, max]

Note

Available as signed and unsigned: char, short, int, long long

Template Parameters

T – return type (must be integer)

void setSeed(const uint64_t &seed)

Change the seed used for random generation

Parameters

seed – New random seed

uint64_t getSeed() const

Returns the last value used to seed random generation

template<>
inline char uniform(const char &min, const char &max) const

Special cases, std::random doesn’t support char, emulate behaviour

template<>
inline unsigned char uniform(const unsigned char &min, const unsigned char &max) const
template<>
inline signed char uniform(const signed char &min, const signed char &max) const