mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 16:51:35 +00:00
pick mat3 from mat4
This commit is contained in:
@@ -11,6 +11,25 @@
|
||||
|
||||
#include "cglm-intrin.h"
|
||||
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat4_pick3_sse2(mat4 mat, mat3 dest) {
|
||||
__m128 x0, x1, x2, x3;
|
||||
|
||||
x0 = _mm_load_ps(mat[0]);
|
||||
x1 = _mm_load_ps(mat[1]);
|
||||
x2 = _mm_load_ps(mat[2]);
|
||||
|
||||
x3 = _mm_shuffle_ps(x0, x1, _MM_SHUFFLE(0, 0, 2, 2));
|
||||
x0 = _mm_shuffle_ps(x0, x3, _MM_SHUFFLE(2, 0, 1, 0));
|
||||
x1 = _mm_shuffle_ps(x1, x2, _MM_SHUFFLE(1, 0, 2, 1));
|
||||
|
||||
_mm_storeu_ps(&dest[0][0], x0);
|
||||
_mm_storeu_ps(&dest[1][1], x1);
|
||||
|
||||
dest[2][2] = mat[2][2];
|
||||
}
|
||||
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat4_scale_sse2(mat4 m, float s){
|
||||
|
@@ -63,6 +63,32 @@ glm_mat4_dup(mat4 mat, mat4 dest) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief copy top-left of mat4 to mat3
|
||||
*
|
||||
* @param[in] mat source
|
||||
* @param[out] dest destination
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat4_pick3(mat4 mat, mat3 dest) {
|
||||
#if defined( __SSE__ ) || defined( __SSE2__ )
|
||||
glm_mat4_pick3_sse2(mat, dest);
|
||||
#else
|
||||
dest[0][0] = mat[0][0];
|
||||
dest[0][1] = mat[0][1];
|
||||
dest[0][2] = mat[0][2];
|
||||
|
||||
dest[1][0] = mat[1][0];
|
||||
dest[1][1] = mat[1][1];
|
||||
dest[1][2] = mat[1][2];
|
||||
|
||||
dest[2][0] = mat[2][0];
|
||||
dest[2][1] = mat[2][1];
|
||||
dest[2][2] = mat[2][2];
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief multiply m1 and m2 to dest
|
||||
*
|
||||
|
Reference in New Issue
Block a user