Lines Matching refs:mat
111 * \param mat a pointer to a GLmatrix structure.
117 #define TEST_MAT_FLAGS(mat, a) \
118 ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
212 * \param mat pointer to a GLmatrix structure containing the left multiplication
220 static void matrix_multf( GLmatrix *mat, const GLfloat *m, GLuint flags )
222 mat->flags |= (flags | MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE);
224 if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D))
225 matmul34( mat->m, mat->m, m );
227 matmul4( mat->m, mat->m, m );
339 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
351 static GLboolean invert_matrix_general( GLmatrix *mat )
353 return util_invert_mat4x4(mat->inv, mat->m);
359 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
371 static GLboolean invert_matrix_3d_general( GLmatrix *mat )
373 const GLfloat *in = mat->m;
374 GLfloat *out = mat->inv;
433 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
443 static GLboolean invert_matrix_3d( GLmatrix *mat )
445 const GLfloat *in = mat->m;
446 GLfloat *out = mat->inv;
448 if (!TEST_MAT_FLAGS(mat, MAT_FLAGS_ANGLE_PRESERVING)) {
449 return invert_matrix_3d_general( mat );
452 if (mat->flags & MAT_FLAG_UNIFORM_SCALE) {
473 else if (mat->flags & MAT_FLAG_ROTATION) {
494 if (mat->flags & MAT_FLAG_TRANSLATION) {
516 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
523 static GLboolean invert_matrix_identity( GLmatrix *mat )
525 memcpy( mat->inv, Identity, sizeof(Identity) );
532 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
539 static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat )
541 const GLfloat *in = mat->m;
542 GLfloat *out = mat->inv;
552 if (mat->flags & MAT_FLAG_TRANSLATION) {
564 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
572 static GLboolean invert_matrix_2d_no_rot( GLmatrix *mat )
574 const GLfloat *in = mat->m;
575 GLfloat *out = mat->inv;
584 if (mat->flags & MAT_FLAG_TRANSLATION) {
594 static GLboolean invert_matrix_perspective( GLmatrix *mat )
596 const GLfloat *in = mat->m;
597 GLfloat *out = mat->inv;
623 typedef GLboolean (*inv_mat_func)( GLmatrix *mat );
648 * \param mat pointer to a GLmatrix structure. The matrix inverse will be
657 static GLboolean matrix_invert( GLmatrix *mat )
659 if (inv_mat_tab[mat->type](mat)) {
660 mat->flags &= ~MAT_FLAG_SINGULAR;
663 mat->flags |= MAT_FLAG_SINGULAR;
664 memcpy( mat->inv, Identity, sizeof(Identity) );
685 _math_matrix_rotate( GLmatrix *mat,
753 /* no rotation, leave mat as-is */
851 matrix_multf( mat, m, MAT_FLAG_ROTATION );
857 * \param mat matrix to apply the projection.
865 * Creates the projection matrix and multiplies it with \p mat, marking the
869 _math_matrix_frustum( GLmatrix *mat,
891 matrix_multf( mat, m, MAT_FLAG_PERSPECTIVE );
940 * \param mat matrix to apply the projection.
948 * Creates the projection matrix and multiplies it with \p mat, marking the
952 _math_matrix_ortho( GLmatrix *mat,
960 matrix_multf( mat, m, (MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION));
966 * \param mat matrix.
971 * Multiplies in-place the elements of \p mat by the scale factors. Checks if
977 _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
979 GLfloat *m = mat->m;
986 mat->flags |= MAT_FLAG_UNIFORM_SCALE;
988 mat->flags |= MAT_FLAG_GENERAL_SCALE;
990 mat->flags |= (MAT_DIRTY_TYPE |
997 * \param mat matrix.
1002 * Adds the translation coordinates to the elements of \p mat in-place. Marks
1007 _math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
1009 GLfloat *m = mat->m;
1015 mat->flags |= (MAT_FLAG_TRANSLATION |
1043 * \param mat matrix.
1049 _math_matrix_set_identity( GLmatrix *mat )
1054 memcpy( mat->m, Identity, sizeof(Identity) );
1055 memcpy( mat->inv, Identity, sizeof(Identity) );
1057 mat->type = MATRIX_IDENTITY;
1058 mat->flags &= ~(MAT_DIRTY_FLAGS|
1113 * \param mat matrix.
1117 static void analyse_from_scratch( GLmatrix *mat )
1119 const GLfloat *m = mat->m;
1132 mat->flags &= ~MAT_FLAGS_GEOMETRY;
1137 mat->flags |= MAT_FLAG_TRANSLATION;
1142 mat->type = MATRIX_IDENTITY;
1145 mat->type = MATRIX_2D_NO_ROT;
1148 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1155 mat->type = MATRIX_2D;
1160 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1164 mat->flags |= MAT_FLAG_GENERAL_3D;
1166 mat->flags |= MAT_FLAG_ROTATION;
1170 mat->type = MATRIX_3D_NO_ROT;
1176 mat->flags |= MAT_FLAG_UNIFORM_SCALE;
1180 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1190 mat->type = MATRIX_3D;
1195 mat->flags |= MAT_FLAG_UNIFORM_SCALE;
1199 mat->flags |= MAT_FLAG_GENERAL_SCALE;
1207 mat->flags |= MAT_FLAG_ROTATION;
1209 mat->flags |= MAT_FLAG_GENERAL_3D;
1212 mat->flags |= MAT_FLAG_GENERAL_3D; /* shear, etc */
1216 mat->type = MATRIX_PERSPECTIVE;
1217 mat->flags |= MAT_FLAG_GENERAL;
1220 mat->type = MATRIX_GENERAL;
1221 mat->flags |= MAT_FLAG_GENERAL;
1230 static void analyse_from_flags( GLmatrix *mat )
1232 const GLfloat *m = mat->m;
1234 if (TEST_MAT_FLAGS(mat, 0)) {
1235 mat->type = MATRIX_IDENTITY;
1237 else if (TEST_MAT_FLAGS(mat, (MAT_FLAG_TRANSLATION |
1241 mat->type = MATRIX_2D_NO_ROT;
1244 mat->type = MATRIX_3D_NO_ROT;
1247 else if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) {
1251 mat->type = MATRIX_2D;
1254 mat->type = MATRIX_3D;
1261 mat->type = MATRIX_PERSPECTIVE;
1264 mat->type = MATRIX_GENERAL;
1271 * \param mat matrix.
1279 _math_matrix_analyse( GLmatrix *mat )
1281 if (mat->flags & MAT_DIRTY_TYPE) {
1282 if (mat->flags & MAT_DIRTY_FLAGS)
1283 analyse_from_scratch( mat );
1285 analyse_from_flags( mat );
1288 if (mat->flags & MAT_DIRTY_INVERSE) {
1289 matrix_invert( mat );
1290 mat->flags &= ~MAT_DIRTY_INVERSE;
1293 mat->flags &= ~(MAT_DIRTY_FLAGS | MAT_DIRTY_TYPE);
1385 * \param mat matrix.
1391 _math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
1393 memcpy( mat->m, m, 16*sizeof(GLfloat) );
1394 mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY);