Cleanup: Remove unused parts of BLI_rand.h C-API

This commit is contained in:
Hans Goudey
2024-12-04 11:29:23 -05:00
parent d260ba0cdb
commit 6836dca44d
2 changed files with 0 additions and 105 deletions

View File

@@ -32,7 +32,6 @@ struct RNG *BLI_rng_new(unsigned int seed);
* A version of #BLI_rng_new that hashes the seed.
*/
struct RNG *BLI_rng_new_srandom(unsigned int seed);
struct RNG *BLI_rng_copy(const struct RNG *rng) ATTR_NONNULL(1);
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1);
void BLI_rng_seed(struct RNG *rng, unsigned int seed) ATTR_NONNULL(1);
@@ -51,8 +50,6 @@ double BLI_rng_get_double(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(
* \return Random value (0..1), but never 1.0.
*/
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
void BLI_rng_get_float_unit_v2(struct RNG *rng, float v[2]) ATTR_NONNULL(1, 2);
void BLI_rng_get_float_unit_v3(struct RNG *rng, float v[3]) ATTR_NONNULL(1, 2);
/**
* Generate a random point inside given tri.
*/
@@ -61,11 +58,6 @@ void BLI_rng_get_tri_sample_float_v2(struct RNG *rng,
const float v2[2],
const float v3[2],
float r_pt[2]) ATTR_NONNULL();
void BLI_rng_get_tri_sample_float_v3(RNG *rng,
const float v1[3],
const float v2[3],
const float v3[3],
float r_pt[3]) ATTR_NONNULL();
void BLI_rng_shuffle_array(struct RNG *rng,
void *data,
@@ -83,11 +75,6 @@ void BLI_rng_shuffle_bitmap(struct RNG *rng, unsigned int *bitmap, unsigned int
*/
void BLI_rng_skip(struct RNG *rng, int n) ATTR_NONNULL(1);
/**
* Fill an array with random numbers.
*/
void BLI_array_frand(float *ar, int count, unsigned int seed);
/** Return a pseudo-random (hash) float from an integer value */
float BLI_hash_frand(unsigned int seed) ATTR_WARN_UNUSED_RESULT;
@@ -103,18 +90,6 @@ void BLI_array_randomize(void *data,
void BLI_bitmap_randomize(unsigned int *bitmap, unsigned int bits_num, unsigned int seed)
ATTR_NONNULL(1);
/** Better seed for the random number generator, using `noise.cc` hash[] */
/** Allows up to BLENDER_MAX_THREADS threads to address */
void BLI_thread_srandom(int thread, unsigned int seed);
/** Return a pseudo-random number N where 0<=N<(2^31) */
/** Allows up to BLENDER_MAX_THREADS threads to address */
int BLI_thread_rand(int thread) ATTR_WARN_UNUSED_RESULT;
/** Return a pseudo-random number N where 0.0f<=N<1.0f */
/** Allows up to BLENDER_MAX_THREADS threads to address */
float BLI_thread_frand(int thread) ATTR_WARN_UNUSED_RESULT;
/** array versions for thread safe random generation */
RNG_THREAD_ARRAY *BLI_rng_threaded_new(void);
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1);
@@ -128,10 +103,6 @@ void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double
void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r);
void BLI_hammersley_1d(unsigned int n, double *r);
/** Return the whole low-discrepancy sequence up to _n_. */
void BLI_halton_2d_sequence(const unsigned int prime[2], double offset[2], int n, double *r);
void BLI_hammersley_2d_sequence(unsigned int n, double *r);
#ifdef __cplusplus
}
#endif

View File

@@ -50,11 +50,6 @@ RNG *BLI_rng_new_srandom(uint seed)
return rng;
}
RNG *BLI_rng_copy(const RNG *rng)
{
return new RNG(*rng);
}
void BLI_rng_free(RNG *rng)
{
delete rng;
@@ -95,28 +90,12 @@ float BLI_rng_get_float(RNG *rng)
return rng->rng.get_float();
}
void BLI_rng_get_float_unit_v2(RNG *rng, float v[2])
{
copy_v2_v2(v, rng->rng.get_unit_float2());
}
void BLI_rng_get_float_unit_v3(RNG *rng, float v[3])
{
copy_v3_v3(v, rng->rng.get_unit_float3());
}
void BLI_rng_get_tri_sample_float_v2(
RNG *rng, const float v1[2], const float v2[2], const float v3[2], float r_pt[2])
{
copy_v2_v2(r_pt, rng->rng.get_triangle_sample(v1, v2, v3));
}
void BLI_rng_get_tri_sample_float_v3(
RNG *rng, const float v1[3], const float v2[3], const float v3[3], float r_pt[3])
{
copy_v3_v3(r_pt, rng->rng.get_triangle_sample_3d(v1, v2, v3));
}
void BLI_rng_shuffle_array(RNG *rng, void *data, uint elem_size_i, uint elem_num)
{
if (elem_num <= 1) {
@@ -166,17 +145,6 @@ void BLI_rng_skip(RNG *rng, int n)
/***/
void BLI_array_frand(float *ar, int count, uint seed)
{
RNG rng;
BLI_rng_srandom(&rng, seed);
for (int i = 0; i < count; i++) {
ar[i] = BLI_rng_get_float(&rng);
}
}
float BLI_hash_frand(uint seed)
{
RNG rng;
@@ -203,31 +171,6 @@ void BLI_bitmap_randomize(BLI_bitmap *bitmap, uint bits_num, uint seed)
/* ********* for threaded random ************** */
static RNG rng_tab[BLENDER_MAX_THREADS];
void BLI_thread_srandom(int thread, uint seed)
{
if (thread >= BLENDER_MAX_THREADS) {
thread = 0;
}
BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
seed = BLI_rng_get_uint(&rng_tab[thread]);
BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
seed = BLI_rng_get_uint(&rng_tab[thread]);
BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]);
}
int BLI_thread_rand(int thread)
{
return BLI_rng_get_int(&rng_tab[thread]);
}
float BLI_thread_frand(int thread)
{
return BLI_rng_get_float(&rng_tab[thread]);
}
struct RNG_THREAD_ARRAY {
RNG rng_tab[BLENDER_MAX_THREADS];
};
@@ -319,17 +262,6 @@ void BLI_halton_3d(const uint prime[3], double offset[3], int n, double *r)
}
}
void BLI_halton_2d_sequence(const uint prime[2], double offset[2], int n, double *r)
{
const double invprimes[2] = {1.0 / double(prime[0]), 1.0 / double(prime[1])};
for (int s = 0; s < n; s++) {
for (int i = 0; i < 2; i++) {
r[s * 2 + i] = halton_ex(invprimes[i], &offset[i]);
}
}
}
/* From "Sampling with Hammersley and Halton Points" TT Wong
* Appendix: Source Code 1 */
BLI_INLINE double radical_inverse(uint n)
@@ -352,14 +284,6 @@ void BLI_hammersley_1d(uint n, double *r)
*r = radical_inverse(n);
}
void BLI_hammersley_2d_sequence(uint n, double *r)
{
for (uint s = 0; s < n; s++) {
r[s * 2 + 0] = double(s + 0.5) / double(n);
r[s * 2 + 1] = radical_inverse(s);
}
}
namespace blender {
RandomNumberGenerator RandomNumberGenerator::from_random_seed()