From ca58e90e15dd845be336452b9d514b6efbad20cf Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Wed, 26 Apr 2017 14:25:55 -0600 Subject: [PATCH] common: remove EQUAL_EPSILON from mathlib.hh --- common/mathlib.cc | 5 +++-- include/common/mathlib.hh | 5 ++--- include/light/light.hh | 1 + include/vis/vis.hh | 1 + light/phong.cc | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/mathlib.cc b/common/mathlib.cc index 1a8ffee0..ec843201 100644 --- a/common/mathlib.cc +++ b/common/mathlib.cc @@ -222,12 +222,13 @@ qmat3x3f RotateFromUpToSurfaceNormal(const qvec3f &surfaceNormal) return rotations; } +// FIXME: remove these bool AABBsDisjoint(const vec3_t minsA, const vec3_t maxsA, const vec3_t minsB, const vec3_t maxsB) { for (int i=0; i<3; i++) { - if (maxsA[i] < (minsB[i] - EQUAL_EPSILON)) return true; - if (minsA[i] > (maxsB[i] + EQUAL_EPSILON)) return true; + if (maxsA[i] < (minsB[i] - 0.001)) return true; + if (minsA[i] > (maxsB[i] + 0.001)) return true; } return false; } diff --git a/include/common/mathlib.hh b/include/common/mathlib.hh index bed8c0dc..02ea75ee 100644 --- a/include/common/mathlib.hh +++ b/include/common/mathlib.hh @@ -56,7 +56,6 @@ typedef struct { extern const vec3_t vec3_origin; -#define EQUAL_EPSILON 0.001 #define ANGLEEPSILON 0.000001 #define ZERO_TRI_AREA_EPSILON 0.05f #define POINT_EQUAL_EPSILON 0.05f @@ -64,10 +63,10 @@ extern const vec3_t vec3_origin; qboolean VectorCompare(const vec3_t v1, const vec3_t v2, vec_t epsilon); static inline bool -GLMVectorCompare(const qvec3f &v1, const qvec3f &v2) +GLMVectorCompare(const qvec3f &v1, const qvec3f &v2, float epsilon) { for (int i = 0; i < 3; i++) - if (fabs(v1[i] - v2[i]) > EQUAL_EPSILON) + if (fabs(v1[i] - v2[i]) > epsilon) return false; return true; } diff --git a/include/light/light.hh b/include/light/light.hh index 56c9ec41..9a2d3823 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -43,6 +43,7 @@ #define ON_EPSILON 0.1 #define ANGLE_EPSILON 0.001 +#define EQUAL_EPSILON 0.001 typedef struct { vec3_t color; diff --git a/include/vis/vis.hh b/include/vis/vis.hh index 43a7f457..41c33e63 100644 --- a/include/vis/vis.hh +++ b/include/vis/vis.hh @@ -28,6 +28,7 @@ #define PORTALFILE2 "PRT2" #define PORTALFILEAM "PRT1-AM" #define ON_EPSILON 0.1 +#define EQUAL_EPSILON 0.001 #define MAX_WINDING 64 #define MAX_WINDING_FIXED 24 diff --git a/light/phong.cc b/light/phong.cc index 00516155..c29e3e43 100644 --- a/light/phong.cc +++ b/light/phong.cc @@ -416,7 +416,7 @@ CalcualateVertexNormals(const bsp2_t *bsp) // sanity check if (!neighboursToSmooth.size()) { for (auto vertIndexNormalPair : smoothedNormals) { - Q_assert(GLMVectorCompare(vertIndexNormalPair.second, f_norm)); + Q_assert(GLMVectorCompare(vertIndexNormalPair.second, f_norm, EQUAL_EPSILON)); } }