diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-30 09:26:42 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-30 10:01:22 +0300 |
commit | a8ec7845e0bdb9e63e9d3dbd7f4cd7caad36b5a2 (patch) | |
tree | 4531232281ddc4cda4df3fb1ccc0822018fe5682 /source/blender/blenlib/intern/rand.cc | |
parent | af3aaf80344e745e6c207102941513cb631194c3 (diff) |
Cleanup: use "num" as a suffix in: source/blender/blenlib
Also replace "num" with:
- "number" when it's not used to denote the number of items.
- "digits" when digits in a string are being manipulated.
Diffstat (limited to 'source/blender/blenlib/intern/rand.cc')
-rw-r--r-- | source/blender/blenlib/intern/rand.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc index 17bf5585f3f..f6d91cdcc4f 100644 --- a/source/blender/blenlib/intern/rand.cc +++ b/source/blender/blenlib/intern/rand.cc @@ -117,18 +117,18 @@ void BLI_rng_get_tri_sample_float_v3( copy_v3_v3(r_pt, rng->rng.get_triangle_sample_3d(v1, v2, v3)); } -void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot) +void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_num) { - if (elem_tot <= 1) { + if (elem_num <= 1) { return; } const uint elem_size = elem_size_i; - unsigned int i = elem_tot; + unsigned int i = elem_num; void *temp = malloc(elem_size); while (i--) { - const unsigned int j = BLI_rng_get_uint(rng) % elem_tot; + const unsigned int j = BLI_rng_get_uint(rng) % elem_num; if (i != j) { void *iElem = (unsigned char *)data + i * elem_size_i; void *jElem = (unsigned char *)data + j * elem_size_i; @@ -141,15 +141,15 @@ void BLI_rng_shuffle_array(RNG *rng, void *data, unsigned int elem_size_i, unsig free(temp); } -void BLI_rng_shuffle_bitmap(struct RNG *rng, BLI_bitmap *bitmap, unsigned int bits_tot) +void BLI_rng_shuffle_bitmap(struct RNG *rng, BLI_bitmap *bitmap, unsigned int bits_num) { - if (bits_tot <= 1) { + if (bits_num <= 1) { return; } - unsigned int i = bits_tot; + unsigned int i = bits_num; while (i--) { - const unsigned int j = BLI_rng_get_uint(rng) % bits_tot; + const unsigned int j = BLI_rng_get_uint(rng) % bits_num; if (i != j) { const bool i_bit = BLI_BITMAP_TEST(bitmap, i); const bool j_bit = BLI_BITMAP_TEST(bitmap, j); @@ -187,21 +187,21 @@ float BLI_hash_frand(unsigned int seed) void BLI_array_randomize(void *data, unsigned int elem_size, - unsigned int elem_tot, + unsigned int elem_num, unsigned int seed) { RNG rng; BLI_rng_seed(&rng, seed); - BLI_rng_shuffle_array(&rng, data, elem_size, elem_tot); + BLI_rng_shuffle_array(&rng, data, elem_size, elem_num); } -void BLI_bitmap_randomize(BLI_bitmap *bitmap, unsigned int bits_tot, unsigned int seed) +void BLI_bitmap_randomize(BLI_bitmap *bitmap, unsigned int bits_num, unsigned int seed) { RNG rng; BLI_rng_seed(&rng, seed); - BLI_rng_shuffle_bitmap(&rng, bitmap, bits_tot); + BLI_rng_shuffle_bitmap(&rng, bitmap, bits_num); } /* ********* for threaded random ************** */ |