diff --git a/Makefile.common b/Makefile.common index 3658ffe9c9..861d83462c 100644 --- a/Makefile.common +++ b/Makefile.common @@ -776,7 +776,6 @@ OBJ += gfx/video_context_driver.o \ $(LIBRETRO_COMM_DIR)/gfx/math/vector_2.o \ $(LIBRETRO_COMM_DIR)/gfx/math/vector_3.o \ $(LIBRETRO_COMM_DIR)/gfx/math/vector_4.o \ - $(LIBRETRO_COMM_DIR)/gfx/math/matrix_4x4.o \ $(LIBRETRO_COMM_DIR)/gfx/math/matrix_3x3.o ifeq ($(HAVE_KMS), 1) diff --git a/cores/libretro-ffmpeg/fft/fft.cpp b/cores/libretro-ffmpeg/fft/fft.cpp index 5302dcc4ab..68bae10c92 100644 --- a/cores/libretro-ffmpeg/fft/fft.cpp +++ b/cores/libretro-ffmpeg/fft/fft.cpp @@ -276,7 +276,7 @@ static void fft_render(glfft_t *fft, GLuint backbuffer, unsigned width, unsigned printf("center %.2f %.2f %.2f\n", center[0], center[1], center[2]); printf("up %.2f %.2f %.2f\n", up[0], up[1], up[2]); #endif - matrix_4x4_lookat(&mvp_lookat, eye, center, up); + matrix_4x4_lookat(mvp_lookat, eye, center, up); #ifdef GLM_USE_DEBUG printf("mvp_lookat: \n %.2f, %.2f, %.2f, %.2f \n %.2f, %.2f, %.2f, %.2f \n %.2f, %.2f, %.2f, %.2f \n %.2f, %.2f, %.2f, %.2f \n\n", MAT_ELEM_4X4(mvp_lookat, 0, 0), diff --git a/griffin/griffin.c b/griffin/griffin.c index 94d8830e37..451f1ac4d5 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -281,7 +281,6 @@ VIDEO IMAGE VIDEO DRIVER ============================================================ */ -#include "../libretro-common/gfx/math/matrix_4x4.c" #include "../libretro-common/gfx/math/matrix_3x3.c" #include "../libretro-common/gfx/math/vector_2.c" #include "../libretro-common/gfx/math/vector_3.c" diff --git a/libretro-common/gfx/math/matrix_4x4.c b/libretro-common/gfx/math/matrix_4x4.c deleted file mode 100644 index 5e75b046da..0000000000 --- a/libretro-common/gfx/math/matrix_4x4.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2010-2017 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (matrix_4x4.c). - * --------------------------------------------------------------------------------------- - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -#include -#include - -void matrix_4x4_lookat(math_matrix_4x4 *out, - vec3_t eye, - vec3_t center, - vec3_t up) -{ - vec3_t zaxis; /* the "forward" vector */ - vec3_t xaxis; /* the "right" vector */ - vec3_t yaxis; /* the "up" vector */ - - vec3_copy(&zaxis[0], center); - vec3_subtract(&zaxis[0], eye); - vec3_normalize(&zaxis[0]); - - vec3_cross(&xaxis[0], &zaxis[0], up); - vec3_normalize(&xaxis[0]); - vec3_cross(&yaxis[0], &xaxis[0], zaxis); - - MAT_ELEM_4X4(*out, 0, 0) = xaxis[0]; - MAT_ELEM_4X4(*out, 0, 1) = yaxis[0]; - MAT_ELEM_4X4(*out, 0, 2) = -zaxis[0]; - MAT_ELEM_4X4(*out, 0, 3) = 0.0; - - MAT_ELEM_4X4(*out, 1, 0) = xaxis[1]; - MAT_ELEM_4X4(*out, 1, 1) = yaxis[1]; - MAT_ELEM_4X4(*out, 1, 2) = -zaxis[1]; - MAT_ELEM_4X4(*out, 1, 3) = 0.0f; - - MAT_ELEM_4X4(*out, 2, 0) = xaxis[2]; - MAT_ELEM_4X4(*out, 2, 1) = yaxis[2]; - MAT_ELEM_4X4(*out, 2, 2) = -zaxis[2]; - MAT_ELEM_4X4(*out, 2, 3) = 0.0f; - - MAT_ELEM_4X4(*out, 3, 0) = -(xaxis[0] * eye[0] + xaxis[1] * eye[1] + xaxis[2] * eye[2]); - MAT_ELEM_4X4(*out, 3, 1) = -(yaxis[0] * eye[0] + yaxis[1] * eye[1] + yaxis[2] * eye[2]); - MAT_ELEM_4X4(*out, 3, 2) = -(zaxis[0] * eye[0] + zaxis[1] * eye[1] + zaxis[2] * eye[2]); - MAT_ELEM_4X4(*out, 3, 3) = 1.f; -} diff --git a/libretro-common/include/gfx/math/matrix_4x4.h b/libretro-common/include/gfx/math/matrix_4x4.h index 02f7fa8738..0878df2c0b 100644 --- a/libretro-common/include/gfx/math/matrix_4x4.h +++ b/libretro-common/include/gfx/math/matrix_4x4.h @@ -207,10 +207,34 @@ typedef struct math_matrix_4x4 MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \ } -void matrix_4x4_lookat(math_matrix_4x4 *out, - vec3_t eye, - vec3_t center, - vec3_t up); +#define matrix_4x4_lookat(out, eye, center, up) \ +{ \ + vec3_t zaxis; /* the "forward" vector */ \ + vec3_t xaxis; /* the "right" vector */ \ + vec3_t yaxis; /* the "up" vector */ \ + vec3_copy(&zaxis[0], center); \ + vec3_subtract(&zaxis[0], eye); \ + vec3_normalize(&zaxis[0]); \ + vec3_cross(&xaxis[0], &zaxis[0], up); \ + vec3_normalize(&xaxis[0]); \ + vec3_cross(&yaxis[0], &xaxis[0], zaxis); \ + MAT_ELEM_4X4(out, 0, 0) = xaxis[0]; \ + MAT_ELEM_4X4(out, 0, 1) = yaxis[0]; \ + MAT_ELEM_4X4(out, 0, 2) = -zaxis[0]; \ + MAT_ELEM_4X4(out, 0, 3) = 0.0; \ + MAT_ELEM_4X4(out, 1, 0) = xaxis[1]; \ + MAT_ELEM_4X4(out, 1, 1) = yaxis[1]; \ + MAT_ELEM_4X4(out, 1, 2) = -zaxis[1]; \ + MAT_ELEM_4X4(out, 1, 3) = 0.0f; \ + MAT_ELEM_4X4(out, 2, 0) = xaxis[2]; \ + MAT_ELEM_4X4(out, 2, 1) = yaxis[2]; \ + MAT_ELEM_4X4(out, 2, 2) = -zaxis[2]; \ + MAT_ELEM_4X4(out, 2, 3) = 0.0f; \ + MAT_ELEM_4X4(out, 3, 0) = -(xaxis[0] * eye[0] + xaxis[1] * eye[1] + xaxis[2] * eye[2]); \ + MAT_ELEM_4X4(out, 3, 1) = -(yaxis[0] * eye[0] + yaxis[1] * eye[1] + yaxis[2] * eye[2]); \ + MAT_ELEM_4X4(out, 3, 2) = -(zaxis[0] * eye[0] + zaxis[1] * eye[1] + zaxis[2] * eye[2]); \ + MAT_ELEM_4X4(out, 3, 3) = 1.f; \ +} /* * Multiplies a with b, stores the result in out