aboutsummaryrefslogtreecommitdiff
path: root/dep/recastnavigation/Detour
diff options
context:
space:
mode:
Diffstat (limited to 'dep/recastnavigation/Detour')
-rw-r--r--dep/recastnavigation/Detour/Include/DetourCommon.h15
-rw-r--r--dep/recastnavigation/Detour/Include/DetourMath.h20
-rw-r--r--dep/recastnavigation/Detour/Source/DetourCommon.cpp9
-rw-r--r--dep/recastnavigation/Detour/Source/DetourNavMesh.cpp4
-rw-r--r--dep/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp6
-rw-r--r--dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp25
6 files changed, 44 insertions, 35 deletions
diff --git a/dep/recastnavigation/Detour/Include/DetourCommon.h b/dep/recastnavigation/Detour/Include/DetourCommon.h
index 0888614ea9b..2afba0d780b 100644
--- a/dep/recastnavigation/Detour/Include/DetourCommon.h
+++ b/dep/recastnavigation/Detour/Include/DetourCommon.h
@@ -19,6 +19,8 @@
#ifndef DETOURCOMMON_H
#define DETOURCOMMON_H
+#include "DetourMath.h"
+
/**
@defgroup detour Detour
@@ -71,11 +73,6 @@ template<class T> inline T dtSqr(T a) { return a*a; }
/// @return The value, clamped to the specified range.
template<class T> inline T dtClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
-/// Returns the square root of the value.
-/// @param[in] x The value.
-/// @return The square root of the vlaue.
-float dtSqrt(float x);
-
/// @}
/// @name Vector helper functions.
/// @{
@@ -202,7 +199,7 @@ inline void dtVcopy(float* dest, const float* a)
/// @return The scalar length of the vector.
inline float dtVlen(const float* v)
{
- return dtSqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
+ return dtMathSqrtf(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
}
/// Derives the square of the scalar length of the vector. (len * len)
@@ -222,7 +219,7 @@ inline float dtVdist(const float* v1, const float* v2)
const float dx = v2[0] - v1[0];
const float dy = v2[1] - v1[1];
const float dz = v2[2] - v1[2];
- return dtSqrt(dx*dx + dy*dy + dz*dz);
+ return dtMathSqrtf(dx*dx + dy*dy + dz*dz);
}
/// Returns the square of the distance between two points.
@@ -247,7 +244,7 @@ inline float dtVdist2D(const float* v1, const float* v2)
{
const float dx = v2[0] - v1[0];
const float dz = v2[2] - v1[2];
- return dtSqrt(dx*dx + dz*dz);
+ return dtMathSqrtf(dx*dx + dz*dz);
}
/// Derives the square of the distance between the specified points on the xz-plane.
@@ -265,7 +262,7 @@ inline float dtVdist2DSqr(const float* v1, const float* v2)
/// @param[in,out] v The vector to normalize. [(x, y, z)]
inline void dtVnormalize(float* v)
{
- float d = 1.0f / dtSqrt(dtSqr(v[0]) + dtSqr(v[1]) + dtSqr(v[2]));
+ float d = 1.0f / dtMathSqrtf(dtSqr(v[0]) + dtSqr(v[1]) + dtSqr(v[2]));
v[0] *= d;
v[1] *= d;
v[2] *= d;
diff --git a/dep/recastnavigation/Detour/Include/DetourMath.h b/dep/recastnavigation/Detour/Include/DetourMath.h
new file mode 100644
index 00000000000..95e14f8843b
--- /dev/null
+++ b/dep/recastnavigation/Detour/Include/DetourMath.h
@@ -0,0 +1,20 @@
+/**
+@defgroup detour Detour
+
+Members in this module are wrappers around the standard math library
+*/
+
+#ifndef DETOURMATH_H
+#define DETOURMATH_H
+
+#include <math.h>
+
+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/dep/recastnavigation/Detour/Source/DetourCommon.cpp b/dep/recastnavigation/Detour/Source/DetourCommon.cpp
index b5700f5930b..26fe65c1781 100644
--- a/dep/recastnavigation/Detour/Source/DetourCommon.cpp
+++ b/dep/recastnavigation/Detour/Source/DetourCommon.cpp
@@ -16,16 +16,11 @@
// 3. This notice may not be removed or altered from any source distribution.
//
-#include <math.h>
#include "DetourCommon.h"
+#include "DetourMath.h"
//////////////////////////////////////////////////////////////////////////////////////////
-float dtSqrt(float x)
-{
- return sqrtf(x);
-}
-
void dtClosestPtPointTriangle(float* closest, const float* p,
const float* a, const float* b, const float* c)
{
@@ -360,7 +355,7 @@ void dtRandomPointInConvexPoly(const float* pts, const int npts, float* areas,
acc += dacc;
}
- float v = dtSqrt(t);
+ float v = dtMathSqrtf(t);
const float a = 1 - v;
const float b = (1 - u) * v;
diff --git a/dep/recastnavigation/Detour/Source/DetourNavMesh.cpp b/dep/recastnavigation/Detour/Source/DetourNavMesh.cpp
index 51740509950..e8a679bb5d1 100644
--- a/dep/recastnavigation/Detour/Source/DetourNavMesh.cpp
+++ b/dep/recastnavigation/Detour/Source/DetourNavMesh.cpp
@@ -16,13 +16,13 @@
// 3. This notice may not be removed or altered from any source distribution.
//
-#include <math.h>
#include <float.h>
#include <string.h>
#include <stdio.h>
#include "DetourNavMesh.h"
#include "DetourNode.h"
#include "DetourCommon.h"
+#include "DetourMath.h"
#include "DetourAlloc.h"
#include "DetourAssert.h"
#include <new>
@@ -709,7 +709,7 @@ dtPolyRef dtNavMesh::findNearestPolyInTile(const dtMeshTile* tile,
float closestPtPoly[3];
float diff[3];
bool posOverPoly = false;
- float d = 0;
+ float d;
closestPointOnPoly(ref, center, closestPtPoly, &posOverPoly);
// If a point is directly over a polygon and closer than
diff --git a/dep/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp b/dep/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp
index 9d8471b96a1..1bf271bed7a 100644
--- a/dep/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp
+++ b/dep/recastnavigation/Detour/Source/DetourNavMeshBuilder.cpp
@@ -16,13 +16,13 @@
// 3. This notice may not be removed or altered from any source distribution.
//
-#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include "DetourNavMesh.h"
#include "DetourCommon.h"
+#include "DetourMath.h"
#include "DetourNavMeshBuilder.h"
#include "DetourAlloc.h"
#include "DetourAssert.h"
@@ -202,8 +202,8 @@ static int createBVTree(const unsigned short* verts, const int /*nverts*/,
if (z > it.bmax[2]) it.bmax[2] = z;
}
// Remap y
- it.bmin[1] = (unsigned short)floorf((float)it.bmin[1]*ch/cs);
- it.bmax[1] = (unsigned short)ceilf((float)it.bmax[1]*ch/cs);
+ it.bmin[1] = (unsigned short)dtMathFloorf((float)it.bmin[1]*ch/cs);
+ it.bmax[1] = (unsigned short)dtMathCeilf((float)it.bmax[1]*ch/cs);
}
int curNode = 0;
diff --git a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
index ec3a2946ea5..fbf3724e85b 100644
--- a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
+++ b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
@@ -16,13 +16,13 @@
// 3. This notice may not be removed or altered from any source distribution.
//
-#include <math.h>
#include <float.h>
#include <string.h>
#include "DetourNavMeshQuery.h"
#include "DetourNavMesh.h"
#include "DetourNode.h"
#include "DetourCommon.h"
+#include "DetourMath.h"
#include "DetourAlloc.h"
#include "DetourAssert.h"
#include <new>
@@ -99,9 +99,9 @@ inline float dtQueryFilter::getCost(const float* pa, const float* pb,
return dtVdist(pa, pb) * m_areaCost[curPoly->getArea()];
}
#endif
-
+
// Edited by TC
-static const float H_SCALE = 2.0f; // Search heuristic scale.
+static const float H_SCALE = 2.0f; // Search heuristic scale.
dtNavMeshQuery* dtAllocNavMeshQuery()
@@ -309,7 +309,7 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr
return DT_SUCCESS;
}
-dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const float* centerPos, const float radius,
+dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const float* centerPos, const float maxRadius,
const dtQueryFilter* filter, float (*frand)(),
dtPolyRef* randomRef, float* randomPt) const
{
@@ -341,7 +341,7 @@ dtStatus dtNavMeshQuery::findRandomPointAroundCircle(dtPolyRef startRef, const f
dtStatus status = DT_SUCCESS;
- const float radiusSqr = dtSqr(radius);
+ const float radiusSqr = dtSqr(maxRadius);
float areaSum = 0.0f;
const dtMeshTile* randomTile = 0;
@@ -705,7 +705,7 @@ dtStatus dtNavMeshQuery::getPolyHeight(dtPolyRef ref, const float* pos, float* h
/// @p nearestRef before using @p nearestPt.
///
/// @warning This function is not suitable for large area searches. If the search
-/// extents overlaps more than 128 polygons it may return an invalid result.
+/// extents overlaps more than MAX_SEARCH (128) polygons it may return an invalid result.
///
dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* extents,
const dtQueryFilter* filter,
@@ -716,9 +716,10 @@ dtStatus dtNavMeshQuery::findNearestPoly(const float* center, const float* exten
*nearestRef = 0;
// Get nearby polygons from proximity grid.
- dtPolyRef polys[128];
+ const int MAX_SEARCH = 128;
+ dtPolyRef polys[MAX_SEARCH];
int polyCount = 0;
- if (dtStatusFailed(queryPolygons(center, extents, filter, polys, &polyCount, 128)))
+ if (dtStatusFailed(queryPolygons(center, extents, filter, polys, &polyCount, MAX_SEARCH)))
return DT_FAILURE | DT_INVALID_PARAM;
// Find nearest polygon amongst the nearby polygons.
@@ -1304,12 +1305,8 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters)
if (!m_query.filter->passFilter(neighbourRef, neighbourTile, neighbourPoly))
continue;
- // deal explicitly with crossing tile boundaries
- unsigned char crossSide = 0;
- if (bestTile->links[i].side != 0xff)
- crossSide = bestTile->links[i].side >> 1;
-
- dtNode* neighbourNode = m_nodePool->getNode(neighbourRef, crossSide);
+ // get the neighbor node
+ dtNode* neighbourNode = m_nodePool->getNode(neighbourRef, 0);
if (!neighbourNode)
{
m_query.status |= DT_OUT_OF_NODES;