From 4078bc5756f59da8fb582496d2f998b8c99024e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 24 Jun 2015 11:48:20 +0200 Subject: [PATCH] (math/matrix_4x4c.) Cleanup --- libretro-common/gfx/math/matrix_4x4.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libretro-common/gfx/math/matrix_4x4.c b/libretro-common/gfx/math/matrix_4x4.c index c132c5730f..15846ba17a 100644 --- a/libretro-common/gfx/math/matrix_4x4.c +++ b/libretro-common/gfx/math/matrix_4x4.c @@ -155,11 +155,13 @@ void matrix_4x4_translate(math_matrix_4x4 *out, float x, void matrix_4x4_projection(math_matrix_4x4 *out, float znear, float zfar) { + float delta_z = zfar - znear; + memset(out, 0, sizeof(*out)); MAT_ELEM_4X4(*out, 0, 0) = znear; MAT_ELEM_4X4(*out, 1, 1) = zfar; - MAT_ELEM_4X4(*out, 2, 2) = (zfar + znear) / (zfar - znear); - MAT_ELEM_4X4(*out, 2, 3) = -2.0f * zfar * znear / (zfar - znear); + MAT_ELEM_4X4(*out, 2, 2) = (zfar + znear) / delta_z; + MAT_ELEM_4X4(*out, 2, 3) = -2.0f * zfar * znear / delta_z; MAT_ELEM_4X4(*out, 3, 2) = -1.0f; }