[Bf-blender-cvs] [6ee6533] master: Math Lib: double versions of vector funcs

Campbell Barton noreply at git.blender.org
Thu May 21 13:10:56 CEST 2015


Commit: 6ee653352bbbc8e358969426186b540f98a9aca0
Author: Campbell Barton
Date:   Thu May 21 20:59:08 2015 +1000
Branches: master
https://developer.blender.org/rB6ee653352bbbc8e358969426186b540f98a9aca0

Math Lib: double versions of vector funcs

- add_vn_vn_d
- add_vn_vnvn_d
- mul_vn_db

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

M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_vector.c
M	source/blender/blenlib/intern/math_vector_inline.c

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

diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 04c2baa..9bc1121 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -158,6 +158,8 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESU
 MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
 
+MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+
 MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
 
@@ -335,6 +337,10 @@ void copy_vn_ushort(unsigned short *array_tar, const int size, const unsigned sh
 void copy_vn_uchar(unsigned char *array_tar, const int size, const unsigned char val);
 void copy_vn_fl(float *array_tar, const int size, const float val);
 
+void add_vn_vn_d(double *array_tar, const double *array_src, const int size);
+void add_vn_vnvn_d(double *array_tar, const double *array_src_a, const double *array_src_b, const int size);
+void mul_vn_db(double *array_tar, const int size, const double f);
+
 /**************************** Inline Definitions ******************************/
 
 #if BLI_MATH_DO_INLINE
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 88eccd6..6da0e87 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -1095,3 +1095,38 @@ void copy_vn_fl(float *array_tar, const int size, const float val)
 		*(tar--) = val;
 	}
 }
+
+/** \name Double precision versions 'db'.
+ * \{ */
+
+void add_vn_vn_d(double *array_tar, const double *array_src, const int size)
+{
+	double *tar = array_tar + (size - 1);
+	const double *src = array_src + (size - 1);
+	int i = size;
+	while (i--) {
+		*(tar--) += *(src--);
+	}
+}
+
+void add_vn_vnvn_d(double *array_tar, const double *array_src_a, const double *array_src_b, const int size)
+{
+	double *tar = array_tar + (size - 1);
+	const double *src_a = array_src_a + (size - 1);
+	const double *src_b = array_src_b + (size - 1);
+	int i = size;
+	while (i--) {
+		*(tar--) = *(src_a--) + *(src_b--);
+	}
+}
+
+void mul_vn_db(double *array_tar, const int size, const double f)
+{
+	double *array_pt = array_tar + (size - 1);
+	int i = size;
+	while (i--) {
+		*(array_pt--) *= f;
+	}
+}
+
+/** \} */
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 621d5fb..fb33fed 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -680,6 +680,11 @@ MINLINE float dot_v4v4(const float a[4], const float b[4])
 	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
 }
 
+MINLINE double dot_v3db_v3fl(const double a[3], const float b[3])
+{
+	return a[0] * (double)b[0] + a[1] * (double)b[1] + a[2] * (double)b[2];
+}
+
 MINLINE float cross_v2v2(const float a[2], const float b[2])
 {
 	return a[0] * b[1] - a[1] * b[0];




More information about the Bf-blender-cvs mailing list