Blender V5.0
RandomNumberGenerator Class Reference

#include <BLI_rand.hh>

Public Member Functions

 RandomNumberGenerator (uint32_t seed=0)
void seed (uint32_t seed)
void seed_random (uint32_t seed)
uint32_t get_uint32 ()
int32_t get_int32 ()
int32_t get_int32 (int32_t max_exclusive)
uint64_t get_uint64 ()
double get_double ()
float get_float ()
template<typename T>
void shuffle (MutableSpan< T > values)
float3 get_barycentric_coordinates ()
int round_probabilistic (float x)
float2 get_unit_float2 ()
float3 get_unit_float3 ()
float2 get_triangle_sample (float2 v1, float2 v2, float2 v3)
float3 get_triangle_sample_3d (float3 v1, float3 v2, float3 v3)
void get_bytes (MutableSpan< char > r_bytes)
void skip (int64_t n)

Static Public Member Functions

static RandomNumberGenerator from_random_seed ()

Detailed Description

Definition at line 16 of file BLI_rand.hh.

Constructor & Destructor Documentation

◆ RandomNumberGenerator()

Definition at line 21 of file BLI_rand.hh.

Member Function Documentation

◆ from_random_seed()

Creates a random number generator with a somewhat random seed. This can be used when determinism is not necessary or not desired.

Definition at line 288 of file rand.cc.

Referenced by ED_region_do_draw().

◆ get_barycentric_coordinates()

Compute uniformly distributed barycentric coordinates.

Definition at line 104 of file BLI_rand.hh.

◆ get_bytes()

Definition at line 373 of file rand.cc.

◆ get_double()

Returns
Random value (0..1), but never 1.0.

Definition at line 75 of file BLI_rand.hh.

◆ get_float()

Returns
Random value (0..1), but never 1.0.

Definition at line 83 of file BLI_rand.hh.

Referenced by ED_region_do_draw().

◆ get_int32() [1/2]

Definition at line 52 of file BLI_rand.hh.

◆ get_int32() [2/2]

Returns
Random value (0..N), but never N.

Definition at line 66 of file BLI_rand.hh.

◆ get_triangle_sample()

Generate a random point inside the given triangle.

Definition at line 335 of file rand.cc.

◆ get_triangle_sample_3d()

◆ get_uint32()

Definition at line 46 of file BLI_rand.hh.

◆ get_uint64()

Definition at line 58 of file BLI_rand.hh.

◆ get_unit_float2()

◆ get_unit_float3()

◆ round_probabilistic()

Round value to the next integer randomly. 4.9f is more likely to round to 5 than 4.6f.

Definition at line 306 of file rand.cc.

◆ seed()

void blender::RandomNumberGenerator::seed ( uint32_t seed)
inline

Set the seed for future random numbers.

Definition at line 35 of file BLI_rand.hh.

◆ seed_random()

Set a randomized hash of the value as seed.

Definition at line 297 of file rand.cc.

◆ shuffle()

template<typename T>
void blender::RandomNumberGenerator::shuffle ( MutableSpan< T > values)
inline

Definition at line 88 of file BLI_rand.hh.

◆ skip()

Simulate getting n random values.

Definition at line 135 of file BLI_rand.hh.


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