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:
authorCampbell Barton <ideasman42@gmail.com>2021-08-13 08:10:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-08-13 08:15:54 +0300
commit8fa05efe0a19126b44cc283232e05e0e53d6db84 (patch)
treedfb5ac8b935b457bc6797832f944a77093d646ec
parent92f4abc37f0febbce7bedfdc6284d282a26ca454 (diff)
Docs: note that normalize_v# functions zero out input containing nan
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index dddefd60b1b..ddfdaffb706 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -1145,6 +1145,9 @@ MINLINE float len_v3v3(const float a[3], const float b[3])
return len_v3(d);
}
+/**
+ * \note any vectors containing `nan` will be zeroed out.
+ */
MINLINE float normalize_v2_v2_length(float r[2], const float a[2], const float unit_length)
{
float d = dot_v2v2(a, a);
@@ -1154,6 +1157,7 @@ MINLINE float normalize_v2_v2_length(float r[2], const float a[2], const float u
mul_v2_v2fl(r, a, unit_length / d);
}
else {
+ /* Either the vector is small or one of it's values contained `nan`. */
zero_v2(r);
d = 0.0f;
}
@@ -1175,17 +1179,20 @@ MINLINE float normalize_v2_length(float n[2], const float unit_length)
return normalize_v2_v2_length(n, n, unit_length);
}
+/**
+ * \note any vectors containing `nan` will be zeroed out.
+ */
MINLINE float normalize_v3_v3_length(float r[3], const float a[3], const float unit_length)
{
float d = dot_v3v3(a, a);
- /* a larger value causes normalize errors in a
- * scaled down models with camera extreme close */
+ /* A larger value causes normalize errors in a scaled down models with camera extreme close. */
if (d > 1.0e-35f) {
d = sqrtf(d);
mul_v3_v3fl(r, a, unit_length / d);
}
else {
+ /* Either the vector is small or one of it's values contained `nan`. */
zero_v3(r);
d = 0.0f;
}