Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/listbase.c3
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c13
-rw-r--r--source/blender/blenlib/intern/rand.c12
3 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c
index 568448327bd..80b8a8d041c 100644
--- a/source/blender/blenlib/intern/listbase.c
+++ b/source/blender/blenlib/intern/listbase.c
@@ -578,6 +578,9 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset)
Link *link = NULL;
const char *id_iter;
+ if (id == NULL)
+ return NULL;
+
for (link = listbase->first; link; link = link->next) {
id_iter = ((const char *)link) + offset;
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 189b94a6f13..c4535eacefa 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -192,6 +192,19 @@ MINLINE void copy_v4_v4_int(int r[4], const int a[4])
r[3] = a[3];
}
+/* int <-> float */
+MINLINE void round_v2i_v2fl(int r[2], const float a[2])
+{
+ r[0] = (int)roundf(a[0]);
+ r[1] = (int)roundf(a[1]);
+}
+
+MINLINE void copy_v2fl_v2i(float r[2], const int a[2])
+{
+ r[0] = (float)a[0];
+ r[1] = (float)a[1];
+}
+
/* double -> float */
MINLINE void copy_v2fl_v2db(float r[2], const double a[2])
{
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index 9e56ce6b2cf..8613a0ea6dd 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -265,6 +265,18 @@ void BLI_rng_skip(RNG *rng, int n)
/***/
+/* fill an array with random numbers */
+void BLI_array_frand(float *ar, int count, unsigned int 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(unsigned int seed)
{
RNG rng;