summaryrefslogtreecommitdiff
path: root/src/modules/meta2d/v3f.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-07-20 21:43:03 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-07-20 22:29:32 -0700
commit0aba23a14014d84a5ca1e3a2af45608cc9f23044 (patch)
treed1aedf256d0cc66804b602531b17f38ae65f804f /src/modules/meta2d/v3f.h
parentbdf33aae40f998b4cfbd94baf3050009266644c1 (diff)
modules/meta2d: more rand()->rand_r() conversions
Normalized all the randomizers to use til_module_context.seed while in here.
Diffstat (limited to 'src/modules/meta2d/v3f.h')
-rw-r--r--src/modules/meta2d/v3f.h12
1 files changed, 6 insertions, 6 deletions
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;
}
© All Rights Reserved