diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-01-17 17:41:27 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-01-18 14:29:53 +0300 |
commit | cb5302f962185b827e8c8b40f7a10dceebe310f9 (patch) | |
tree | bc9d4428e37bb9711f29e2a499d7a44bd8b7871f /source/blender/blenlib/intern/math_vector_inline.c | |
parent | 91697b0fa0bbe494cbaf8cc501a90a435d24d41d (diff) |
Math: Make it possible to use vector for both input and output
Avoids nasty code all over where such math is required, and
compilers can easily deal with such situation.
Don't prefer questionable micro-optimization which comes with
a cost of nasty actual logic code.
Diffstat (limited to 'source/blender/blenlib/intern/math_vector_inline.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index fc3f11fd1be..78b3a5420ed 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -142,12 +142,6 @@ MINLINE void copy_v4_v4_char(char r[4], const char a[4]) } /* short */ -MINLINE void zero_v3_int(int r[3]) -{ - r[0] = 0; - r[1] = 0; - r[2] = 0; -} MINLINE void copy_v2_v2_short(short r[2], const short a[2]) { @@ -171,6 +165,13 @@ MINLINE void copy_v4_v4_short(short r[4], const short a[4]) } /* int */ +MINLINE void zero_v3_int(int r[3]) +{ + r[0] = 0; + r[1] = 0; + r[2] = 0; +} + MINLINE void copy_v2_v2_int(int r[2], const int a[2]) { r[0] = a[0]; @@ -192,6 +193,35 @@ MINLINE void copy_v4_v4_int(int r[4], const int a[4]) r[3] = a[3]; } +/* double */ +MINLINE void zero_v3_db(double r[3]) +{ + r[0] = 0.0; + r[1] = 0.0; + r[2] = 0.0; +} + +MINLINE void copy_v2_v2_db(double r[2], const double a[2]) +{ + r[0] = a[0]; + r[1] = a[1]; +} + +MINLINE void copy_v3_v3_db(double r[3], const double a[3]) +{ + r[0] = a[0]; + r[1] = a[1]; + r[2] = a[2]; +} + +MINLINE void copy_v4_v4_db(double r[4], const double a[4]) +{ + r[0] = a[0]; + r[1] = a[1]; + r[2] = a[2]; + r[3] = a[3]; +} + /* int <-> float */ MINLINE void round_v2i_v2fl(int r[2], const float a[2]) { |