Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CGLM_USE_DEFAULT_EPSILON and use system's float epsilon as default #170

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/cglm/affine.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ bool
glm_uniscaled(mat4 m) {
CGLM_ALIGN(8) vec3 s;
glm_decompose_scalev(m, s);
return glm_vec3_eq_all(s);
return glm_vec3_eq_eps(s, s[0]);
}

/*!
Expand Down
16 changes: 11 additions & 5 deletions include/cglm/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@
#include "types.h"
#include "simd/intrin.h"

#ifndef CGLM_USE_DEFAULT_EPSILON
# ifndef GLM_FLT_EPSILON
# define GLM_FLT_EPSILON 1e-6
/** CGLM_USE_DEFAULT_EPSILON is removed, to override float epsilon,
* just define GLM_FLT_EPSILON with epsilon value like below
*
* #define GLM_FLT_EPSILON 1e-6f
*/

#ifndef GLM_FLT_EPSILON
# ifndef FLT_EPSILON
# define GLM_FLT_EPSILON 1e-6f
# else
# define GLM_FLT_EPSILON FLT_EPSILON
# endif
#else
# define GLM_FLT_EPSILON FLT_EPSILON
#endif

#endif /* cglm_common_h */
6 changes: 3 additions & 3 deletions test/src/test_cam.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ TEST_IMPL(camera_decomp) {
farVal = 100.0f;

glm_perspective(fovy, aspect, nearVal, farVal, proj);
ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < GLM_FLT_EPSILON)
ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < GLM_FLT_EPSILON)
ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < GLM_FLT_EPSILON)
ASSERT(fabsf(aspect - glm_persp_aspect(proj)) < 1e-5f)
ASSERT(fabsf(fovy - glm_persp_fovy(proj)) < 1e-5f)
ASSERT(fabsf(49.984f - glm_deg(glm_persp_fovy(proj))) < 1e-5f)

glm_persp_sizes(proj, fovy, sizes);

Expand Down
2 changes: 1 addition & 1 deletion test/src/test_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test_rand_quat(versor q);
CGLM_INLINE
bool
test_eq(float a, float b) {
return fabsf(a - b) <= GLM_FLT_EPSILON * 10;
return fabsf(a - b) <= 1e-5f;
}

CGLM_INLINE
Expand Down