Turn more matrix 4x4 functions into macros

This commit is contained in:
twinaphex 2017-04-16 03:53:07 +02:00
parent 809bce6cd9
commit fbd6d0ebc6
6 changed files with 32 additions and 32 deletions

View File

@ -290,7 +290,7 @@ static void gl_set_projection(gl_t *gl,
return;
}
matrix_4x4_rotate_z(&rot, M_PI * gl->rotation / 180.0f);
matrix_4x4_rotate_z(rot, M_PI * gl->rotation / 180.0f);
matrix_4x4_multiply(&gl->mvp, &rot, &gl->mvp_no_rot);
}

View File

@ -341,7 +341,7 @@ static void vita2d_set_projection(vita_video_t *vita,
return;
}
matrix_4x4_rotate_z(&rot, M_PI * vita->rotation / 180.0f);
matrix_4x4_rotate_z(rot, M_PI * vita->rotation / 180.0f);
matrix_4x4_multiply(&vita->mvp, &rot, &vita->mvp_no_rot);
}

View File

@ -1324,7 +1324,7 @@ static void vulkan_set_projection(vk_t *vk,
return;
}
matrix_4x4_rotate_z(&rot, M_PI * vk->rotation / 180.0f);
matrix_4x4_rotate_z(rot, M_PI * vk->rotation / 180.0f);
matrix_4x4_multiply(&vk->mvp, &rot, &vk->mvp_no_rot);
}

View File

@ -106,33 +106,6 @@ void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad)
MAT_ELEM_4X4(*mat, 3, 3) = 1.0f;
}
/*
* Builds a rotation matrix using the
* rotation around the Z-axis.
*/
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad)
{
float cosine = cosf(rad);
float sine = sinf(rad);
MAT_ELEM_4X4(*mat, 0, 0) = cosine;
MAT_ELEM_4X4(*mat, 0, 1) = -sine;
MAT_ELEM_4X4(*mat, 0, 2) = 0.0f;
MAT_ELEM_4X4(*mat, 0, 3) = 0.0f;
MAT_ELEM_4X4(*mat, 1, 0) = sine;
MAT_ELEM_4X4(*mat, 1, 1) = cosine;
MAT_ELEM_4X4(*mat, 1, 2) = 0.0f;
MAT_ELEM_4X4(*mat, 1, 3) = 0.0f;
MAT_ELEM_4X4(*mat, 2, 0) = 0.0f;
MAT_ELEM_4X4(*mat, 2, 1) = 0.0f;
MAT_ELEM_4X4(*mat, 2, 2) = 1.0f;
MAT_ELEM_4X4(*mat, 2, 3) = 0.0f;
MAT_ELEM_4X4(*mat, 3, 0) = 0.0f;
MAT_ELEM_4X4(*mat, 3, 1) = 0.0f;
MAT_ELEM_4X4(*mat, 3, 2) = 0.0f;
MAT_ELEM_4X4(*mat, 3, 3) = 1.0f;
}
/*
* Creates an orthographic projection matrix.
*/

View File

@ -68,7 +68,32 @@ void matrix_4x4_transpose(math_matrix_4x4 *out, const math_matrix_4x4 *in);
void matrix_4x4_rotate_x(math_matrix_4x4 *mat, float rad);
void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad);
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad);
/*
* Builds a rotation matrix using the
* rotation around the Z-axis.
*/
#define matrix_4x4_rotate_z(mat, radians) \
{ \
float cosine = cosf(radians); \
float sine = sinf(radians); \
MAT_ELEM_4X4(mat, 0, 0) = cosine; \
MAT_ELEM_4X4(mat, 0, 1) = -sine; \
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 0) = sine; \
MAT_ELEM_4X4(mat, 1, 1) = cosine; \
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 2, 2) = 1.0f; \
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
}
void matrix_4x4_ortho(math_matrix_4x4 *mat,
float left, float right,

View File

@ -604,7 +604,9 @@ void menu_display_draw_texture(
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
draw.pipeline.id = 0;
coords.color = (const float*)color;
menu_display_rotate_z(&rotate_draw);
draw.texture = texture;
draw.x = x;
draw.y = height - y;
@ -906,7 +908,7 @@ void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw)
b = (math_matrix_4x4*)menu_disp->get_default_mvp();
matrix_4x4_rotate_z(&matrix_rotated, draw->rotation);
matrix_4x4_rotate_z(matrix_rotated, draw->rotation);
matrix_4x4_multiply(draw->matrix, &matrix_rotated, b);
if (!draw->scale_enable)