matrix scale

This commit is contained in:
Recep Aslantas
2016-09-15 17:54:37 +03:00
parent 602b487b53
commit 6c5143313e
2 changed files with 23 additions and 0 deletions

View File

@@ -48,4 +48,14 @@
_mm_store_ps(D[3], r3); \
} while (0)
#define CGLM_MAT_SCALE_SSE_4x4f(M, S) \
do { \
__m128 xmm0; \
xmm0 = _mm_set1_ps(S); \
_mm_store_ps(M[0], _mm_mul_ps(_mm_load_ps(M[0]), xmm0)); \
_mm_store_ps(M[1], _mm_mul_ps(_mm_load_ps(M[1]), xmm0)); \
_mm_store_ps(M[2], _mm_mul_ps(_mm_load_ps(M[2]), xmm0)); \
_mm_store_ps(M[3], _mm_mul_ps(_mm_load_ps(M[3]), xmm0)); \
} while (0)
#endif /* cglm_mat_sse_h */

View File

@@ -124,6 +124,19 @@ glm_mat_transpose_self(mat4 m) {
#endif
}
CGLM_INLINE
void
glm_mat4_scale(mat4 m, float s) {
#if defined( __SSE__ ) || defined( __SSE2__ )
CGLM_MAT_SCALE_SSE_4x4f(m, s);
#else
m[0][0] *= s; m[0][1] *= s; m[0][2] *= s; m[0][3] *= s;
m[1][0] *= s; m[1][1] *= s; m[1][2] *= s; m[1][3] *= s;
m[2][0] *= s; m[2][1] *= s; m[2][2] *= s; m[2][3] *= s;
m[3][0] *= s; m[3][1] *= s; m[3][2] *= s; m[3][3] *= s;
#endif
}
CGLM_INLINE
float
glm_mat4_det(mat4 mat) {