[Bf-blender-cvs] [3aee3bbac73] master: Math Lib: varied size vector multiply
Andrew Hale
noreply at git.blender.org
Thu Aug 9 00:14:33 CEST 2018
Commit: 3aee3bbac7317d205b611b9aa713791f17104556
Author: Andrew Hale
Date: Thu Aug 9 08:10:27 2018 +1000
Branches: master
https://developer.blender.org/rB3aee3bbac7317d205b611b9aa713791f17104556
Math Lib: varied size vector multiply
Needed for Python mathutils elementwise multiply.
===================================================================
M source/blender/blenlib/BLI_math_vector.h
M source/blender/blenlib/intern/math_vector.c
===================================================================
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 39625346756..59c9341f75c 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -354,6 +354,8 @@ void range_vn_u(unsigned int *array_tar, const int size, const unsigned int star
void range_vn_fl(float *array_tar, const int size, const float start, const float step);
void negate_vn(float *array_tar, const int size);
void negate_vn_vn(float *array_tar, const float *array_src, const int size);
+void mul_vn_vn(float *array_tar, const float *array_src, const int size);
+void mul_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size);
void mul_vn_fl(float *array_tar, const int size, const float f);
void mul_vn_vn_fl(float *array_tar, const float *array_src, const int size, const float f);
void add_vn_vn(float *array_tar, const float *array_src, const int size);
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index d6e48fa59e7..acb4ee87f69 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -1096,6 +1096,27 @@ void negate_vn_vn(float *array_tar, const float *array_src, const int size)
}
}
+void mul_vn_vn(float *array_tar, const float *array_src, const int size)
+{
+ float *tar = array_tar + (size - 1);
+ const float *src = array_src + (size - 1);
+ int i = size;
+ while (i--) {
+ *(tar--) *= *(src--);
+ }
+}
+
+void mul_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size)
+{
+ float *tar = array_tar + (size - 1);
+ const float *src_a = array_src_a + (size - 1);
+ const float *src_b = array_src_b + (size - 1);
+ int i = size;
+ while (i--) {
+ *(tar--) = *(src_a--) * *(src_b--);
+ }
+}
+
void mul_vn_fl(float *array_tar, const int size, const float f)
{
float *array_pt = array_tar + (size - 1);
More information about the Bf-blender-cvs
mailing list