diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-07-20 08:01:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-07-20 08:01:42 +0400 |
commit | 7c7b7302d33b9a43f5436589a726bc733be91a33 (patch) | |
tree | f7151512b3ba95ead50f991daf1ec29ca5b7f811 /source/blender/blenlib/intern/math_matrix.c | |
parent | 3ca78a40e8b9eb7fa7c01404590ca2592a0b390d (diff) |
Math Lib: use variable length args for mul_serie_m3,m4 (instead of trailing NULL's)
Diffstat (limited to 'source/blender/blenlib/intern/math_matrix.c')
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 207 |
1 files changed, 142 insertions, 65 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 7fc30e3112b..74b0df1c6c0 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -274,71 +274,148 @@ void mul_m4_m3m4(float m1[4][4], float m3_[3][3], float m2_[4][4]) m1[2][2] = m2[2][0] * m3[0][2] + m2[2][1] * m3[1][2] + m2[2][2] * m3[2][2]; } -void mul_serie_m3(float answ[3][3], - float m1[3][3], float m2[3][3], float m3[3][3], - float m4[3][3], float m5[3][3], float m6[3][3], - float m7[3][3], float m8[3][3]) -{ - float temp[3][3]; - - if (m1 == NULL || m2 == NULL) return; - - mul_m3_m3m3(answ, m2, m1); - if (m3) { - mul_m3_m3m3(temp, m3, answ); - if (m4) { - mul_m3_m3m3(answ, m4, temp); - if (m5) { - mul_m3_m3m3(temp, m5, answ); - if (m6) { - mul_m3_m3m3(answ, m6, temp); - if (m7) { - mul_m3_m3m3(temp, m7, answ); - if (m8) { - mul_m3_m3m3(answ, m8, temp); - } - else copy_m3_m3(answ, temp); - } - } - else copy_m3_m3(answ, temp); - } - } - else copy_m3_m3(answ, temp); - } -} -void mul_serie_m4(float answ[4][4], float m1[4][4], - float m2[4][4], float m3[4][4], float m4[4][4], - float m5[4][4], float m6[4][4], float m7[4][4], - float m8[4][4]) -{ - float temp[4][4]; - - if (m1 == NULL || m2 == NULL) return; - - mul_m4_m4m4(answ, m1, m2); - if (m3) { - mul_m4_m4m4(temp, answ, m3); - if (m4) { - mul_m4_m4m4(answ, temp, m4); - if (m5) { - mul_m4_m4m4(temp, answ, m5); - if (m6) { - mul_m4_m4m4(answ, temp, m6); - if (m7) { - mul_m4_m4m4(temp, answ, m7); - if (m8) { - mul_m4_m4m4(answ, temp, m8); - } - else copy_m4_m4(answ, temp); - } - } - else copy_m4_m4(answ, temp); - } - } - else copy_m4_m4(answ, temp); - } -} +/** \name Macro helpers for: mul_serie_m3 + * \{ */ +void _va_mul_serie_m3_3( + float r[3][3], + float m1[3][3], float m2[3][3]) +{ + mul_m3_m3m3(r, m2, m1); +} +void _va_mul_serie_m3_4( + float r[3][3], + float m1[3][3], float m2[3][3], float m3[3][3]) +{ + mul_m3_m3m3(r, m2, m1); + mul_m3_m3m3(r, m3, r); +} +void _va_mul_serie_m3_5( + float r[3][3], + float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3]) +{ + mul_m3_m3m3(r, m2, m1); + mul_m3_m3m3(r, m3, r); + mul_m3_m3m3(r, m4, r); +} +void _va_mul_serie_m3_6( + float r[3][3], + float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3], + float m5[3][3]) +{ + mul_m3_m3m3(r, m2, m1); + mul_m3_m3m3(r, m3, r); + mul_m3_m3m3(r, m4, r); + mul_m3_m3m3(r, m5, r); +} +void _va_mul_serie_m3_7( + float r[3][3], + float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3], + float m5[3][3], float m6[3][3]) +{ + mul_m3_m3m3(r, m2, m1); + mul_m3_m3m3(r, m3, r); + mul_m3_m3m3(r, m4, r); + mul_m3_m3m3(r, m5, r); + mul_m3_m3m3(r, m6, r); +} +void _va_mul_serie_m3_8( + float r[3][3], + float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3], + float m5[3][3], float m6[3][3], float m7[3][3]) +{ + mul_m3_m3m3(r, m2, m1); + mul_m3_m3m3(r, m3, r); + mul_m3_m3m3(r, m4, r); + mul_m3_m3m3(r, m5, r); + mul_m3_m3m3(r, m6, r); + mul_m3_m3m3(r, m7, r); +} +void _va_mul_serie_m3_9( + float r[3][3], + float m1[3][3], float m2[3][3], float m3[3][3], float m4[3][3], + float m5[3][3], float m6[3][3], float m7[3][3], float m8[3][3]) +{ + mul_m3_m3m3(r, m2, m1); + mul_m3_m3m3(r, m3, r); + mul_m3_m3m3(r, m4, r); + mul_m3_m3m3(r, m5, r); + mul_m3_m3m3(r, m6, r); + mul_m3_m3m3(r, m7, r); + mul_m3_m3m3(r, m8, r); +} +/** \} */ + +/** \name Macro helpers for: mul_serie_m4 + * \{ */ +void _va_mul_serie_m4_3( + float r[4][4], + float m1[4][4], float m2[4][4]) +{ + mul_m4_m4m4(r, m2, m1); +} +void _va_mul_serie_m4_4( + float r[4][4], + float m1[4][4], float m2[4][4], float m3[4][4]) +{ + mul_m4_m4m4(r, m2, m1); + mul_m4_m4m4(r, m3, r); +} +void _va_mul_serie_m4_5( + float r[4][4], + float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4]) +{ + mul_m4_m4m4(r, m2, m1); + mul_m4_m4m4(r, m3, r); + mul_m4_m4m4(r, m4, r); +} +void _va_mul_serie_m4_6( + float r[4][4], + float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4], + float m5[4][4]) +{ + mul_m4_m4m4(r, m2, m1); + mul_m4_m4m4(r, m3, r); + mul_m4_m4m4(r, m4, r); + mul_m4_m4m4(r, m5, r); +} +void _va_mul_serie_m4_7( + float r[4][4], + float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4], + float m5[4][4], float m6[4][4]) +{ + mul_m4_m4m4(r, m2, m1); + mul_m4_m4m4(r, m3, r); + mul_m4_m4m4(r, m4, r); + mul_m4_m4m4(r, m5, r); + mul_m4_m4m4(r, m6, r); +} +void _va_mul_serie_m4_8( + float r[4][4], + float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4], + float m5[4][4], float m6[4][4], float m7[4][4]) +{ + mul_m4_m4m4(r, m2, m1); + mul_m4_m4m4(r, m3, r); + mul_m4_m4m4(r, m4, r); + mul_m4_m4m4(r, m5, r); + mul_m4_m4m4(r, m6, r); + mul_m4_m4m4(r, m7, r); +} +void _va_mul_serie_m4_9( + float r[4][4], + float m1[4][4], float m2[4][4], float m3[4][4], float m4[4][4], + float m5[4][4], float m6[4][4], float m7[4][4], float m8[4][4]) +{ + mul_m4_m4m4(r, m2, m1); + mul_m4_m4m4(r, m3, r); + mul_m4_m4m4(r, m4, r); + mul_m4_m4m4(r, m5, r); + mul_m4_m4m4(r, m6, r); + mul_m4_m4m4(r, m7, r); + mul_m4_m4m4(r, m8, r); +} +/** \} */ void mul_v2_m3v2(float r[2], float m[3][3], float v[2]) { @@ -2115,7 +2192,7 @@ void pseudoinverse_m4_m4(float Ainv[4][4], float A[4][4], float epsilon) transpose_m4(V); - mul_serie_m4(Ainv, U, Wm, V, NULL, NULL, NULL, NULL, NULL); + mul_serie_m4(Ainv, U, Wm, V); } void pseudoinverse_m3_m3(float Ainv[3][3], float A[3][3], float epsilon) |