code style and minor optimization[s]

This commit is contained in:
Recep Aslantas
2018-09-22 00:10:50 +03:00
parent 280ac72fd8
commit aa2b0f2631
3 changed files with 27 additions and 44 deletions

View File

@@ -198,26 +198,15 @@ glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_ortho_default(float aspect, glm_ortho_default(float aspect, mat4 dest) {
mat4 dest) {
if (aspect >= 1.0f) { if (aspect >= 1.0f) {
glm_ortho(-1.0f * aspect, glm_ortho(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
1.0f * aspect,
-1.0f,
1.0f,
-100.0f,
100.0f,
dest);
return; return;
} }
glm_ortho(-1.0f, aspect = 1.0f / aspect;
1.0f,
-1.0f / aspect, glm_ortho(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
1.0f / aspect,
-100.0f,
100.0f,
dest);
} }
/*! /*!
@@ -291,13 +280,8 @@ glm_perspective(float fovy,
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_perspective_default(float aspect, glm_perspective_default(float aspect, mat4 dest) {
mat4 dest) { glm_perspective(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
glm_perspective(GLM_PI_4f,
aspect,
0.01f,
100.0f,
dest);
} }
/*! /*!
@@ -310,8 +294,7 @@ glm_perspective_default(float aspect,
*/ */
CGLM_INLINE CGLM_INLINE
void void
glm_perspective_resize(float aspect, glm_perspective_resize(float aspect, mat4 proj) {
mat4 proj) {
if (proj[0][0] == 0.0f) if (proj[0][0] == 0.0f)
return; return;

View File

@@ -25,7 +25,7 @@
CGLM_INLINE CGLM_INLINE
void void
glm_mat4_print(mat4 matrix, glm_mat4_print(mat4 matrix,
FILE * __restrict ostream) { FILE * __restrict ostream) {
int i; int i;
int j; int j;
@@ -55,7 +55,7 @@ glm_mat4_print(mat4 matrix,
CGLM_INLINE CGLM_INLINE
void void
glm_mat3_print(mat3 matrix, glm_mat3_print(mat3 matrix,
FILE * __restrict ostream) { FILE * __restrict ostream) {
int i; int i;
int j; int j;
@@ -85,7 +85,7 @@ glm_mat3_print(mat3 matrix,
CGLM_INLINE CGLM_INLINE
void void
glm_vec4_print(vec4 vec, glm_vec4_print(vec4 vec,
FILE * __restrict ostream) { FILE * __restrict ostream) {
int i; int i;
@@ -107,7 +107,7 @@ glm_vec4_print(vec4 vec,
CGLM_INLINE CGLM_INLINE
void void
glm_vec3_print(vec3 vec, glm_vec3_print(vec3 vec,
FILE * __restrict ostream) { FILE * __restrict ostream) {
int i; int i;
@@ -129,7 +129,7 @@ glm_vec3_print(vec3 vec,
CGLM_INLINE CGLM_INLINE
void void
glm_ivec3_print(ivec3 vec, glm_ivec3_print(ivec3 vec,
FILE * __restrict ostream) { FILE * __restrict ostream) {
int i; int i;
@@ -151,7 +151,7 @@ glm_ivec3_print(ivec3 vec,
CGLM_INLINE CGLM_INLINE
void void
glm_versor_print(versor vec, glm_versor_print(versor vec,
FILE * __restrict ostream) { FILE * __restrict ostream) {
int i; int i;

View File

@@ -47,19 +47,19 @@ typedef CGLM_ALIGN_IF(16) vec4 mat4[4];
typedef vec4 versor; typedef vec4 versor;
#define GLM_E 2.71828182845904523536028747135266250 /* e */ #define GLM_E 2.71828182845904523536028747135266250 /* e */
#define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */ #define GLM_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */
#define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */ #define GLM_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */
#define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */ #define GLM_LN2 0.693147180559945309417232121458176568 /* loge(2) */
#define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */ #define GLM_LN10 2.30258509299404568401799145468436421 /* loge(10) */
#define GLM_PI 3.14159265358979323846264338327950288 /* pi */ #define GLM_PI 3.14159265358979323846264338327950288 /* pi */
#define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ #define GLM_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
#define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ #define GLM_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
#define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ #define GLM_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
#define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ #define GLM_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
#define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ #define GLM_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
#define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ #define GLM_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
#define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ #define GLM_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
#define GLM_Ef ((float)GLM_E) #define GLM_Ef ((float)GLM_E)
#define GLM_LOG2Ef ((float)GLM_LOG2E) #define GLM_LOG2Ef ((float)GLM_LOG2E)