From 8558d2360a16e5ee4dcfd9813617f309a4fbb9e7 Mon Sep 17 00:00:00 2001 From: Hrishikesh Date: Wed, 3 Feb 2021 06:32:44 +0530 Subject: [PATCH 1/2] Removed redundant function definitions in CameraMatrix and used the ones in Math.hpp --- include/core/CameraMatrix.hpp | 3 ++- src/core/CameraMatrix.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/core/CameraMatrix.hpp b/include/core/CameraMatrix.hpp index d9bff7f4..a644b651 100644 --- a/include/core/CameraMatrix.hpp +++ b/include/core/CameraMatrix.hpp @@ -5,6 +5,7 @@ #include "Plane.hpp" #include "Rect2.hpp" #include "Transform.hpp" +#include "Math.hpp" #include @@ -39,7 +40,7 @@ struct CameraMatrix { static real_t get_fovy(real_t p_fovx, real_t p_aspect) { - return rad2deg(atan(p_aspect * tan(deg2rad(p_fovx) * 0.5)) * 2.0); + return Math::rad2deg(atan(p_aspect * tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0); } static inline double deg2rad(double p_y) { return p_y * Math_PI / 180.0; } diff --git a/src/core/CameraMatrix.cpp b/src/core/CameraMatrix.cpp index 9d35d5c4..b1b7f20f 100644 --- a/src/core/CameraMatrix.cpp +++ b/src/core/CameraMatrix.cpp @@ -585,7 +585,7 @@ real_t CameraMatrix::get_fov() const { right_plane.normalize(); if ((matrix[8] == 0) && (matrix[9] == 0)) { - return rad2deg(acos(abs(right_plane.normal.x))) * 2.0; + return Math::rad2deg(acos(abs(right_plane.normal.x))) * 2.0; } else { // our frustum is asymmetrical need to calculate the left planes angle separately.. Plane left_plane = Plane(matrix[3] + matrix[0], @@ -594,7 +594,7 @@ real_t CameraMatrix::get_fov() const { matrix[15] + matrix[12]); left_plane.normalize(); - return rad2deg(acos(abs(left_plane.normal.x))) + rad2deg(acos(abs(right_plane.normal.x))); + return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x))); } } From 09df1fc9b58f886d3ed0d781d3d0f069c2b6b1a8 Mon Sep 17 00:00:00 2001 From: Hrishikesh Date: Wed, 3 Feb 2021 18:55:39 +0530 Subject: [PATCH 2/2] Removed the redundant functions in CameraMatrix.hpp --- include/core/CameraMatrix.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/core/CameraMatrix.hpp b/include/core/CameraMatrix.hpp index a644b651..dc6b7274 100644 --- a/include/core/CameraMatrix.hpp +++ b/include/core/CameraMatrix.hpp @@ -43,12 +43,6 @@ struct CameraMatrix { return Math::rad2deg(atan(p_aspect * tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0); } - static inline double deg2rad(double p_y) { return p_y * Math_PI / 180.0; } - static inline float deg2rad(float p_y) { return p_y * Math_PI / 180.0; } - - static inline double rad2deg(double p_y) { return p_y * 180.0 / Math_PI; } - static inline float rad2deg(float p_y) { return p_y * 180.0 / Math_PI; } - static inline double absd(double g) { union {