Merge pull request #67 from grahamboree/removed_macros
Replaced math function macros with inline functions.
This commit is contained in:
commit
2f788530f5
@ -1,21 +1,20 @@
|
|||||||
#ifndef DETOURMATH_H
|
|
||||||
#define DETOURMATH_H
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@defgroup detour Detour
|
@defgroup detour Detour
|
||||||
|
|
||||||
Members in this module are wrappers around the standard math library
|
Members in this module are wrappers around the standard math library
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef DETOURMATH_H
|
||||||
|
#define DETOURMATH_H
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define dtMathFabs(x) fabs(x)
|
inline float dtMathFabsf(float x) { return fabsf(x); }
|
||||||
#define dtMathSqrtf(x) sqrtf(x)
|
inline float dtMathSqrtf(float x) { return sqrtf(x); }
|
||||||
#define dtMathFloorf(x) floorf(x)
|
inline float dtMathFloorf(float x) { return floorf(x); }
|
||||||
#define dtMathCeilf(x) ceilf(x)
|
inline float dtMathCeilf(float x) { return ceilf(x); }
|
||||||
#define dtMathCosf(x) cosf(x)
|
inline float dtMathCosf(float x) { return cosf(x); }
|
||||||
#define dtMathSinf(x) sinf(x)
|
inline float dtMathSinf(float x) { return sinf(x); }
|
||||||
#define dtMathAtan2f(y, x) atan2f(y, x)
|
inline float dtMathAtan2f(float y, float x) { return atan2f(y, x); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -206,7 +206,7 @@ static int getNeighbours(const float* pos, const float height, const float range
|
|||||||
// Check for overlap.
|
// Check for overlap.
|
||||||
float diff[3];
|
float diff[3];
|
||||||
dtVsub(diff, pos, ag->npos);
|
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;
|
continue;
|
||||||
diff[1] = 0;
|
diff[1] = 0;
|
||||||
const float distSqr = dtVlenSqr(diff);
|
const float distSqr = dtVlenSqr(diff);
|
||||||
|
@ -58,7 +58,7 @@ static int isectRaySeg(const float* ap, const float* u,
|
|||||||
dtVsub(v,bq,bp);
|
dtVsub(v,bq,bp);
|
||||||
dtVsub(w,ap,bp);
|
dtVsub(w,ap,bp);
|
||||||
float d = dtVperp2D(u,v);
|
float d = dtVperp2D(u,v);
|
||||||
if (dtMathFabs(d) < 1e-6f) return 0;
|
if (dtMathFabsf(d) < 1e-6f) return 0;
|
||||||
d = 1.0f/d;
|
d = 1.0f/d;
|
||||||
t = dtVperp2D(v,w) * d;
|
t = dtVperp2D(v,w) * d;
|
||||||
if (t < 0 || t > 1) return 0;
|
if (t < 0 || t > 1) return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user