mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
Simplify gfx_display_rotate_z
This commit is contained in:
parent
91c8541e20
commit
50873f7c38
@ -959,30 +959,43 @@ void gfx_display_draw_texture_slice(
|
||||
void gfx_display_rotate_z(gfx_display_t *p_disp,
|
||||
gfx_display_ctx_rotate_draw_t *draw, void *data)
|
||||
{
|
||||
math_matrix_4x4 matrix_rotated, matrix_scaled;
|
||||
math_matrix_4x4 *b = NULL;
|
||||
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
||||
float cosine, sine, radians;
|
||||
math_matrix_4x4 matrix_rotated = {
|
||||
{ 0.0f, 0.0f, 0.0f, 0.0f ,
|
||||
0.0f, 0.0f, 0.0f, 0.0f ,
|
||||
0.0f, 0.0f, 1.0f, 0.0f ,
|
||||
0.0f, 0.0f, 0.0f, 1.0f }
|
||||
};
|
||||
math_matrix_4x4 *b = NULL;
|
||||
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
|
||||
|
||||
if (
|
||||
!draw ||
|
||||
!dispctx ||
|
||||
!dispctx->get_default_mvp ||
|
||||
dispctx->handles_transform
|
||||
dispctx->handles_transform
|
||||
|| !dispctx->get_default_mvp
|
||||
|| !(b = (math_matrix_4x4*)dispctx->get_default_mvp(data))
|
||||
)
|
||||
return;
|
||||
|
||||
if (!(b = (math_matrix_4x4*)dispctx->get_default_mvp(data)))
|
||||
return;
|
||||
radians = draw->rotation;
|
||||
cosine = cosf(radians);
|
||||
sine = sinf(radians);
|
||||
MAT_ELEM_4X4(matrix_rotated, 0, 0) = cosine;
|
||||
MAT_ELEM_4X4(matrix_rotated, 0, 1) = -sine;
|
||||
MAT_ELEM_4X4(matrix_rotated, 1, 0) = sine;
|
||||
MAT_ELEM_4X4(matrix_rotated, 1, 1) = cosine;
|
||||
|
||||
matrix_4x4_rotate_z(matrix_rotated, draw->rotation);
|
||||
matrix_4x4_multiply(*draw->matrix, matrix_rotated, *b);
|
||||
|
||||
if (!draw->scale_enable)
|
||||
return;
|
||||
|
||||
matrix_4x4_scale(matrix_scaled,
|
||||
draw->scale_x, draw->scale_y, draw->scale_z);
|
||||
matrix_4x4_multiply(*draw->matrix, matrix_scaled, *draw->matrix);
|
||||
if (draw->scale_enable)
|
||||
{
|
||||
math_matrix_4x4 matrix_scaled = {
|
||||
{ draw->scale_x, 0.0f, 0.0f, 0.0f ,
|
||||
0.0f, draw->scale_y, 0.0f, 0.0f ,
|
||||
0.0f, 0.0f, draw->scale_z, 0.0f ,
|
||||
0.0f, 0.0f, 0.0f, 1.0f }
|
||||
};
|
||||
matrix_4x4_multiply(*draw->matrix, matrix_scaled, *draw->matrix);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user