Merge pull request #67 from grahamboree/removed_macros

Replaced math function macros with inline functions.
This commit is contained in:
Mikko Mononen 2015-01-03 01:17:35 +02:00
commit 2f788530f5
3 changed files with 12 additions and 13 deletions

View File

@ -1,21 +1,20 @@
#ifndef DETOURMATH_H
#define DETOURMATH_H
/**
@defgroup detour Detour
Members in this module are wrappers around the standard math library
*/
#ifndef DETOURMATH_H
#define DETOURMATH_H
#include <math.h>
#define dtMathFabs(x) fabs(x)
#define dtMathSqrtf(x) sqrtf(x)
#define dtMathFloorf(x) floorf(x)
#define dtMathCeilf(x) ceilf(x)
#define dtMathCosf(x) cosf(x)
#define dtMathSinf(x) sinf(x)
#define dtMathAtan2f(y, x) atan2f(y, x)
inline float dtMathFabsf(float x) { return fabsf(x); }
inline float dtMathSqrtf(float x) { return sqrtf(x); }
inline float dtMathFloorf(float x) { return floorf(x); }
inline float dtMathCeilf(float x) { return ceilf(x); }
inline float dtMathCosf(float x) { return cosf(x); }
inline float dtMathSinf(float x) { return sinf(x); }
inline float dtMathAtan2f(float y, float x) { return atan2f(y, x); }
#endif

View File

@ -206,7 +206,7 @@ static int getNeighbours(const float* pos, const float height, const float range
// Check for overlap.
float diff[3];
dtVsub(diff, pos, ag->npos);
if (dtMathFabs(diff[1]) >= (height+ag->params.height)/2.0f)
if (dtMathFabsf(diff[1]) >= (height+ag->params.height)/2.0f)
continue;
diff[1] = 0;
const float distSqr = dtVlenSqr(diff);

View File

@ -58,7 +58,7 @@ static int isectRaySeg(const float* ap, const float* u,
dtVsub(v,bq,bp);
dtVsub(w,ap,bp);
float d = dtVperp2D(u,v);
if (dtMathFabs(d) < 1e-6f) return 0;
if (dtMathFabsf(d) < 1e-6f) return 0;
d = 1.0f/d;
t = dtVperp2D(v,w) * d;
if (t < 0 || t > 1) return 0;