From 0aba23a14014d84a5ca1e3a2af45608cc9f23044 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 20 Jul 2022 21:43:03 -0700 Subject: modules/meta2d: more rand()->rand_r() conversions Normalized all the randomizers to use til_module_context.seed while in here. --- src/modules/meta2d/v3f.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/modules/meta2d/v3f.h') diff --git a/src/modules/meta2d/v3f.h b/src/modules/meta2d/v3f.h index 79aea72..d923ecc 100644 --- a/src/modules/meta2d/v3f.h +++ b/src/modules/meta2d/v3f.h @@ -297,20 +297,20 @@ static inline v3f_t * v3f_cross(v3f_t *res, const v3f_t *a, const v3f_t *b) } -static inline v3f_t _v3f_rand(const v3f_t *min, const v3f_t *max) +static inline v3f_t _v3f_rand(unsigned *seedp, const v3f_t *min, const v3f_t *max) { return (v3f_t){ - .x = min->x + (float)rand() * (1.f/RAND_MAX) * (max->x - min->x), - .y = min->y + (float)rand() * (1.f/RAND_MAX) * (max->y - min->y), - .z = min->z + (float)rand() * (1.f/RAND_MAX) * (max->z - min->z), + .x = min->x + (float)rand_r(seedp) * (1.f/RAND_MAX) * (max->x - min->x), + .y = min->y + (float)rand_r(seedp) * (1.f/RAND_MAX) * (max->y - min->y), + .z = min->z + (float)rand_r(seedp) * (1.f/RAND_MAX) * (max->z - min->z), }; } -static inline v3f_t * v3f_rand(v3f_t *res, const v3f_t *min, const v3f_t *max) +static inline v3f_t * v3f_rand(v3f_t *res, unsigned *seedp, const v3f_t *min, const v3f_t *max) { if (_v3f_allocated(&res)) - *res = _v3f_rand(min, max); + *res = _v3f_rand(seedp, min, max); return res; } -- cgit v1.2.3