From a792998286e8d5ac19e7363ac8f6ff696c017dc3 Mon Sep 17 00:00:00 2001 From: grahamboree Date: Fri, 2 Jan 2015 18:10:45 -0500 Subject: [PATCH] Replaced math function macros with inline functions. --- Detour/Include/DetourMath.h | 21 +++++++++---------- DetourCrowd/Source/DetourCrowd.cpp | 2 +- .../Source/DetourObstacleAvoidance.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Detour/Include/DetourMath.h b/Detour/Include/DetourMath.h index 744c562..95e14f8 100644 --- a/Detour/Include/DetourMath.h +++ b/Detour/Include/DetourMath.h @@ -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 -#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 diff --git a/DetourCrowd/Source/DetourCrowd.cpp b/DetourCrowd/Source/DetourCrowd.cpp index 8fa75f3..0bd9e28 100644 --- a/DetourCrowd/Source/DetourCrowd.cpp +++ b/DetourCrowd/Source/DetourCrowd.cpp @@ -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); diff --git a/DetourCrowd/Source/DetourObstacleAvoidance.cpp b/DetourCrowd/Source/DetourObstacleAvoidance.cpp index afb100e..e28a61a 100644 --- a/DetourCrowd/Source/DetourObstacleAvoidance.cpp +++ b/DetourCrowd/Source/DetourObstacleAvoidance.cpp @@ -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;