diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-16 23:53:12 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-16 23:53:12 +0400 |
commit | 3311164b24da61f2967f96d0ee27508a7e2e0267 (patch) | |
tree | 0824417cf3d645f59d98b210c02a4c5ef6c05a48 /source/blender/blenlib | |
parent | 3c8ab559a5bd31fd38e9c5cf9da8505ca28f4887 (diff) |
Math lib: matrix multiplication order fix for two functions that were
inconsistent with similar functions & math notation:
mul_m4_m4m4(R, B, A) => mult_m4_m4m4(R, A, B)
mul_m3_m3m4(R, B, A) => mult_m3_m3m4(R, A, B)
For branch maintainers, it should be relatively simple to fix things manually,
it's also possible run this script after merging to do automatic replacement:
http://www.pasteall.org/27459/python
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 18 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 6 |
3 files changed, 16 insertions, 14 deletions
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 008d2ad49ce..4d3a4dfe445 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -68,10 +68,12 @@ void sub_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]); void sub_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]); void mul_m3_m3m3(float R[3][3], float A[3][3], float B[3][3]); -void mul_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]); void mul_m4_m3m4(float R[4][4], float A[3][3], float B[4][4]); void mul_m4_m4m3(float R[4][4], float A[4][4], float B[3][3]); -void mul_m3_m3m4(float R[3][3], float A[3][3], float B[4][4]); +/* note: the A,B arguments are reversed compared to previous mul_m4_m4m4 + function, for consistency with above functions & math notation. */ +void mult_m4_m4m4(float R[4][4], float A[4][4], float B[4][4]); +void mult_m3_m3m4(float R[3][3], float A[4][4], float B[3][3]); void mul_serie_m3(float R[3][3], float M1[3][3], float M2[3][3], float M3[3][3], float M4[3][3], diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 37cb49fc17b..ee9cbaf1f81 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -142,7 +142,7 @@ void swap_m4m4(float m1[][4], float m2[][4]) /******************************** Arithmetic *********************************/ -void mul_m4_m4m4(float m1[][4], float m2_[][4], float m3_[][4]) +void mult_m4_m4m4(float m1[][4], float m3_[][4], float m2_[][4]) { float m2[4][4], m3[4][4]; @@ -209,7 +209,7 @@ void mul_m4_m4m3(float (*m1)[4], float (*m3)[4], float (*m2)[3]) } /* m1 = m2 * m3, ignore the elements on the 4th row/column of m3*/ -void mul_m3_m3m4(float m1[][3], float m2[][3], float m3[][4]) +void mult_m3_m3m4(float m1[][3], float m3[][4], float m2[][3]) { /* m1[i][j] = m2[i][k] * m3[k][j] */ m1[0][0] = m2[0][0] * m3[0][0] + m2[0][1] * m3[1][0] +m2[0][2] * m3[2][0]; @@ -280,19 +280,19 @@ void mul_serie_m4(float answ[][4], float m1[][4], if(m1==NULL || m2==NULL) return; - mul_m4_m4m4(answ, m2, m1); + mult_m4_m4m4(answ, m1, m2); if(m3) { - mul_m4_m4m4(temp, m3, answ); + mult_m4_m4m4(temp, answ, m3); if(m4) { - mul_m4_m4m4(answ, m4, temp); + mult_m4_m4m4(answ, temp, m4); if(m5) { - mul_m4_m4m4(temp, m5, answ); + mult_m4_m4m4(temp, answ, m5); if(m6) { - mul_m4_m4m4(answ, m6, temp); + mult_m4_m4m4(answ, temp, m6); if(m7) { - mul_m4_m4m4(temp, m7, answ); + mult_m4_m4m4(temp, answ, m7); if(m8) { - mul_m4_m4m4(answ, m8, temp); + mult_m4_m4m4(answ, temp, m8); } else copy_m4_m4(answ, temp); } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index e4664798f5d..5596b6f9f22 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1433,7 +1433,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4]) /* split scaling and rotation, there is probably a faster way to do this, it's done like this now to correctly get negative scaling */ - mul_m4_m4m4(baseRS, basemat, mat); + mult_m4_m4m4(baseRS, mat, basemat); mat4_to_size(scale,baseRS); copy_v3_v3(dscale, scale); @@ -1452,10 +1452,10 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4]) copy_v3_v3(baseR[3], baseRS[3]); invert_m4_m4(baseinv, basemat); - mul_m4_m4m4(R, baseinv, baseR); + mult_m4_m4m4(R, baseR, baseinv); invert_m4_m4(baseRinv, baseR); - mul_m4_m4m4(S, baseRS, baseRinv); + mult_m4_m4m4(S, baseRinv, baseRS); /* set scaling part */ mul_serie_m4(dq->scale, basemat, S, baseinv, NULL, NULL, NULL, NULL, NULL); |