[Bf-blender-cvs] [8fa05efe0a1] master: Docs: note that normalize_v# functions zero out input containing nan

Campbell Barton noreply at git.blender.org
Fri Aug 13 07:16:53 CEST 2021


Commit: 8fa05efe0a19126b44cc283232e05e0e53d6db84
Author: Campbell Barton
Date:   Fri Aug 13 15:10:27 2021 +1000
Branches: master
https://developer.blender.org/rB8fa05efe0a19126b44cc283232e05e0e53d6db84

Docs: note that normalize_v# functions zero out input containing nan

===================================================================

M	source/blender/blenlib/intern/math_vector_inline.c

===================================================================

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;
   }



More information about the Bf-blender-cvs mailing list