[Cogl] [PATCH 2/2] Add a note about [0, 0, 0] and cogl_vector3_normalize()

Damien Lespiau damien.lespiau at gmail.com
Thu May 31 03:41:19 PDT 2012


From: Damien Lespiau <damien.lespiau at intel.com>

When having the [0, 0, 0] vector, normalize() won't try to divide by 0
and thus it's always safe to use that funtion.
---
 cogl/cogl-vector.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/cogl/cogl-vector.h b/cogl/cogl-vector.h
index 01c6006..eaeba56 100644
--- a/cogl/cogl-vector.h
+++ b/cogl/cogl-vector.h
@@ -233,6 +233,10 @@ cogl_vector3_divide_scalar (float *vector,
  * Updates the vector so it is a "unit vector" such that the
  * @vector<!-- -->s magnitude or length is equal to 1.
  *
+ * <note>It's safe to use this function with the [0, 0, 0] vector, it will not
+ * try to divide components by 0 (its norm) and will leave the vector
+ * untouched.</note>
+ *
  * Since: 1.4
  * Stability: Unstable
  */
-- 
1.7.7.5



More information about the Cogl mailing list