|
Blender V5.0
|
#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 () |
| uint64_t | get_uint64 () |
| int32_t | get_int32 (int32_t max_exclusive) |
| 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 () |
Definition at line 16 of file BLI_rand.hh.
|
inline |
Definition at line 21 of file BLI_rand.hh.
Referenced by from_random_seed().
|
static |
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.
References e, RandomNumberGenerator(), and seed().
Referenced by blender::ed::sculpt_paint::AddOperationExecutor::execute(), blender::ed::sculpt_paint::DensityAddOperationExecutor::execute(), blender::bke::get_next_auto_legacy_type(), blender::ed::greasepencil::grease_pencil_primitive_invoke(), blender::ed::sculpt_paint::greasepencil::PaintOperation::on_stroke_begin(), blender::ed::sculpt_paint::paint_brush_update(), seed_hsv_jitter(), blender::ed::sculpt_paint::greasepencil::RandomizeOperation::unique_seed(), and blender::ed::space_node::update_nested_node_refs_after_moving_nodes_into_group().
|
inline |
Compute uniformly distributed barycentric coordinates.
Definition at line 104 of file BLI_rand.hh.
References get_float().
Referenced by blender::nodes::node_geo_distribute_points_on_faces_cc::sample_mesh_surface(), and blender::bke::mesh_surface_sample::sample_surface_points_spherical().
| void blender::RandomNumberGenerator::get_bytes | ( | MutableSpan< char > | r_bytes | ) |
Definition at line 373 of file rand.cc.
References BLI_assert, i, blender::MutableSpan< T >::size(), and step.
Referenced by BLI_rng_get_char_n().
|
inline |
Definition at line 75 of file BLI_rand.hh.
References get_int32().
Referenced by BLI_rng_get_double().
|
inline |
Definition at line 83 of file BLI_rand.hh.
References get_int32().
Referenced by BLI_rng_get_float(), get_barycentric_coordinates(), get_triangle_sample(), get_triangle_sample_3d(), get_unit_float2(), get_unit_float3(), blender::ed::greasepencil::grease_pencil_primitive_invoke(), blender::ed::object::object_rand_transverts(), blender::ed::curves::primitive_random_sphere(), blender::index_mask::random_mask(), blender::ed::greasepencil::randomize_rotation(), round_probabilistic(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_projected_with_symmetry(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_spherical_with_symmetry(), blender::bke::mesh_surface_sample::sample_surface_points_projected(), blender::bke::mesh_surface_sample::sample_surface_points_spherical(), seed_hsv_jitter(), blender::ed::sculpt_paint::select_random::select_random_exec(), TEST(), TEST(), and TEST().
|
inline |
Definition at line 52 of file BLI_rand.hh.
References step.
Referenced by BKE_modifiers_persistent_uid_init(), BLI_rng_get_int(), blender::bke::generate_unique_instance_ids(), get_double(), get_float(), get_int32(), blender::bke::get_next_auto_legacy_type(), blender::seq::modifier_persistent_uid_init(), blender::bke::node_unique_id(), shuffle(), blender::index_mask::tests::TEST(), blender::index_mask::tests::TEST(), blender::index_mask::tests::TEST(), blender::index_mask::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), TEST(), and blender::ed::space_node::update_nested_node_refs_after_moving_nodes_into_group().
Definition at line 66 of file BLI_rand.hh.
References BLI_assert, and get_int32().
Generate a random point inside the given triangle.
Definition at line 335 of file rand.cc.
References get_float(), sample, v, and v2.
Referenced by BLI_rng_get_tri_sample_float_v2().
|
inline |
Definition at line 46 of file BLI_rand.hh.
References step.
Referenced by BLI_rng_get_uint(), get_uint64(), seed_random(), and blender::ed::sculpt_paint::greasepencil::RandomizeOperation::unique_seed().
|
inline |
Definition at line 58 of file BLI_rand.hh.
References get_uint32().
| float2 blender::RandomNumberGenerator::get_unit_float2 | ( | ) |
| float3 blender::RandomNumberGenerator::get_unit_float3 | ( | ) |
Definition at line 321 of file rand.cc.
References cosf, float, get_float(), M_PI, sinf, sqrtf, x, y, and z().
Referenced by blender::ed::object::object_rand_transverts(), and blender::tests::TEST().
| int blender::RandomNumberGenerator::round_probabilistic | ( | float | x | ) |
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.
References BLI_assert, fractf, get_float(), round_up(), and x.
Referenced by blender::nodes::node_geo_distribute_points_on_faces_cc::sample_mesh_surface(), and blender::bke::mesh_surface_sample::sample_surface_points_spherical().
|
inline |
Set the seed for future random numbers.
Definition at line 35 of file BLI_rand.hh.
References seed().
Referenced by BLI_rng_new(), BLI_rng_seed(), from_random_seed(), RandomNumberGenerator(), seed(), and seed_random().
| void blender::RandomNumberGenerator::seed_random | ( | uint32_t | seed | ) |
Set a randomized hash of the value as seed.
Definition at line 297 of file rand.cc.
References get_uint32(), hash, seed(), and seed.
Referenced by BLI_rng_new_srandom(), BLI_rng_srandom(), and blender::bke::generate_unique_instance_ids().
|
inline |
Definition at line 88 of file BLI_rand.hh.
References BLI_assert, get_int32(), i, INT32_MAX, and blender::MutableSpan< T >::size().
|
inline |
Simulate getting n random values.
Definition at line 135 of file BLI_rand.hh.
References step.
Referenced by BLI_rng_skip().