diff options
| author | Tyge <[email protected]> | 2020-04-15 16:17:26 +0200 |
|---|---|---|
| committer | Tyge <[email protected]> | 2020-04-15 16:17:26 +0200 |
| commit | 4b392a990bb125de0f9858eeabbc1273ebb45deb (patch) | |
| tree | 9b2dd83cc8bdfc2306134ba004cd7fffb0270244 | |
| parent | c9db6edd7b173e9d37ea0463d6bdd4076dccbfd6 (diff) | |
| download | STC-modified-4b392a990bb125de0f9858eeabbc1273ebb45deb.tar.gz STC-modified-4b392a990bb125de0f9858eeabbc1273ebb45deb.zip | |
Minor Refactoring.
| -rw-r--r-- | stc/cmat3.h | 19 | ||||
| -rw-r--r-- | stc/cmat4.h | 23 | ||||
| -rw-r--r-- | stc/cquat.h | 2 |
3 files changed, 21 insertions, 23 deletions
diff --git a/stc/cmat3.h b/stc/cmat3.h index 95d5d7f1..24903c02 100644 --- a/stc/cmat3.h +++ b/stc/cmat3.h @@ -34,8 +34,7 @@ #define cmat3d_zero ((CMat3d) cmat3_zero_init) #define declare_CMat3(tag, T) \ - typedef T (*CMat3##tag##Raw)[3]; \ - typedef const T (*CMat3##tag##ConstRaw)[3]; \ + typedef const T (*CMat3##tag##ConstRef)[3]; \ \ typedef union CMat3##tag { \ CVec3##tag v[3]; \ @@ -43,7 +42,7 @@ } CMat3##tag; \ \ static inline CMat3##tag \ - cmat3##tag##_mult(CMat3##tag##ConstRaw m1, CMat3##tag##ConstRaw m2) { \ + cmat3##tag##_mult(CMat3##tag##ConstRef m1, CMat3##tag##ConstRef m2) { \ const T *a = m1[0], *b = m2[0]; \ return (CMat3##tag) { \ a[0] * b[0] + a[3] * b[1] + a[6] * b[2], \ @@ -67,21 +66,21 @@ return self; \ } \ static inline CMat3##tag \ - cmat3##tag##_scalarMult(CMat3##tag##ConstRaw m, T s) { \ + cmat3##tag##_scalarMult(CMat3##tag##ConstRef m, T s) { \ CMat3##tag dst; \ T *c = dst.arr; const T *a = m[0]; \ for (int i = 0; i < 9; ++i) *c++ = *a++ * s; \ return dst; \ } \ static inline CMat3##tag \ - cmat3##tag##_compMult(CMat3##tag##ConstRaw m1, CMat3##tag##ConstRaw m2) { \ + cmat3##tag##_compMult(CMat3##tag##ConstRef m1, CMat3##tag##ConstRef m2) { \ CMat3##tag dst; \ T *c = dst.arr; const T *a = m1[0], *b = m2[0]; \ for (int i = 0; i < 9; ++i) *c++ = *a++ * *b++; \ return dst; \ } \ static inline CVec3##tag \ - cmat3##tag##_vecMult(CMat3##tag##ConstRaw m, CVec3##tag v) { \ + cmat3##tag##_vecMult(CMat3##tag##ConstRef m, CVec3##tag v) { \ return (CVec3##tag) { \ m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z, \ m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z, \ @@ -90,7 +89,7 @@ } \ \ static inline CMat3##tag \ - cmat3##tag##_transpose(CMat3##tag##ConstRaw m) { \ + cmat3##tag##_transpose(CMat3##tag##ConstRef m) { \ return (CMat3##tag) { \ m[0][0], m[1][0], m[2][0], \ m[0][1], m[1][1], m[2][1], \ @@ -99,13 +98,13 @@ } \ \ static inline T \ - cmat3##tag##_trace(CMat3##tag##ConstRaw m) { \ + cmat3##tag##_trace(CMat3##tag##ConstRef m) { \ return m[0][0] + m[1][1] + m[2][2]; \ } \ \ \ static inline T \ - cmat3##tag##_determinant(CMat3##tag##ConstRaw m) { \ + cmat3##tag##_determinant(CMat3##tag##ConstRef m) { \ const T *a = m[0]; \ return a[0] * (a[4] * a[8] - a[7] * a[5]) \ - a[3] * (a[1] * a[8] - a[2] * a[7]) \ @@ -113,7 +112,7 @@ } \ \ static inline CMat3##tag \ - cmat3##tag##_inverse(CMat3##tag##ConstRaw m) { \ + cmat3##tag##_inverse(CMat3##tag##ConstRef m) { \ const T *a = m[0]; \ T k = 1.0f / cmat3##tag##_determinant(m); \ return (CMat3##tag) { \ diff --git a/stc/cmat4.h b/stc/cmat4.h index 18581c17..0fd5cbfe 100644 --- a/stc/cmat4.h +++ b/stc/cmat4.h @@ -37,8 +37,7 @@ #define cmat4d_zero ((CMat4d) cmat4_zero_init) #define declare_CMat4(tag, T) \ - typedef T (*CMat4##tag##Raw)[4]; \ - typedef const T (*CMat4##tag##ConstRaw)[4]; \ + typedef const T (*CMat4##tag##ConstRef)[4]; \ \ typedef union CMat4##tag { \ CVec4##tag v[4]; \ @@ -46,7 +45,7 @@ } CMat4##tag; \ \ static inline CMat4##tag \ - cmat4##tag##_mult(CMat4##tag##ConstRaw mat1, CMat4##tag##ConstRaw mat2) { \ + cmat4##tag##_mult(CMat4##tag##ConstRef mat1, CMat4##tag##ConstRef mat2) { \ const T *a = mat1[0], *b = mat2[0]; \ return (CMat4##tag) { \ a[ 0] * b[ 0] + a[ 4] * b[ 1] + a[ 8] * b[ 2] + a[12] * b[ 3], \ @@ -75,21 +74,21 @@ return self; \ } \ static inline CMat4##tag \ - cmat4##tag##_scalarMult(CMat4##tag##ConstRaw m, T s) { \ + cmat4##tag##_scalarMult(CMat4##tag##ConstRef m, T s) { \ CMat4##tag dst; \ T *c = dst.arr; const T *a = m[0]; \ for (int i = 0; i < 16; ++i) *c++ = *a++ * s; \ return dst; \ } \ static inline CMat4##tag \ - cmat4##tag##_compMult(CMat4##tag##ConstRaw m1, CMat4##tag##ConstRaw m2) { \ + cmat4##tag##_compMult(CMat4##tag##ConstRef m1, CMat4##tag##ConstRef m2) { \ CMat4##tag dst; \ T *c = dst.arr; const T *a = m1[0], *b = m2[0]; \ for (int i = 0; i < 16; ++i) *c++ = *a++ * *b++; \ return dst; \ } \ static inline CVec4##tag \ - cmat4##tag##_vecMult(CMat4##tag##ConstRaw m, CVec4##tag v) { \ + cmat4##tag##_vecMult(CMat4##tag##ConstRef m, CVec4##tag v) { \ return (CVec4##tag) { \ m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z + m[3][0] * v.w, \ m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z + m[3][1] * v.w, \ @@ -99,7 +98,7 @@ } \ \ static inline CMat4##tag \ - cmat4##tag##_transpose(CMat4##tag##ConstRaw m) { \ + cmat4##tag##_transpose(CMat4##tag##ConstRef m) { \ return (CMat4##tag) { \ m[0][0], m[1][0], m[2][0], m[3][0], \ m[0][1], m[1][1], m[2][1], m[3][1], \ @@ -109,7 +108,7 @@ } \ \ static inline CMat3##tag \ - cmat4##tag##_transpose3(CMat4##tag##ConstRaw m) { \ + cmat4##tag##_transpose3(CMat4##tag##ConstRef m) { \ return (CMat3##tag) { \ m[0][0], m[1][0], m[2][0], \ m[0][1], m[1][1], m[2][1], \ @@ -118,7 +117,7 @@ } \ \ static inline CMat3##tag \ - cmat4##tag##_to3(CMat4##tag##ConstRaw m) { \ + cmat4##tag##_to3(CMat4##tag##ConstRef m) { \ return (CMat3##tag) { \ m[0][0], m[0][1], m[0][2], \ m[1][0], m[1][1], m[1][2], \ @@ -127,12 +126,12 @@ } \ \ static inline T \ - cmat4##tag##_trace(CMat4##tag##ConstRaw m) { \ + cmat4##tag##_trace(CMat4##tag##ConstRef m) { \ return m[0][0] + m[1][1] + m[2][2] + m[3][3]; \ } \ \ static inline T \ - cmat4##tag##_determinant(CMat4##tag##ConstRaw mat) { \ + cmat4##tag##_determinant(CMat4##tag##ConstRef mat) { \ const T *p = mat[0]; \ T a, b, c, d, e, f; \ a = p[10] * p[15] - p[14] * p[11], \ @@ -149,7 +148,7 @@ \ \ static inline CMat4##tag \ - cmat4##tag##_inverse(CMat4##tag##ConstRaw mat) { \ + cmat4##tag##_inverse(CMat4##tag##ConstRef mat) { \ CMat4##tag dst; \ const T *p = mat[0]; \ T a, b, c, d, e, f, det; \ diff --git a/stc/cquat.h b/stc/cquat.h index 280a7e80..b2aa6903 100644 --- a/stc/cquat.h +++ b/stc/cquat.h @@ -66,7 +66,7 @@ } \ \ static inline CQuat##tag \ - cquat##tag##_fromMat4(CMat4##tag##ConstRaw m) { \ + cquat##tag##_fromMat4(CMat4##tag##ConstRef m) { \ T trace = m[0][0] + m[1][1] + m[2][2], r, rinv; \ CQuat##tag dst; \ if (trace >= 0.0f) { \ |
