diff options
Diffstat (limited to 'dep/recastnavigation')
| -rw-r--r-- | dep/recastnavigation/Detour/DetourCommon.cpp | 4 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourCommon.h | 5 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourMath.h | 21 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourNavMesh.cpp | 32 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourNavMesh.h | 72 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourNavMeshBuilder.cpp | 6 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourNavMeshQuery.cpp | 15 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourNavMeshQuery.h | 4 | ||||
| -rw-r--r-- | dep/recastnavigation/Detour/DetourNode.cpp | 29 | ||||
| -rw-r--r-- | dep/recastnavigation/Recast/Recast.cpp | 20 | ||||
| -rw-r--r-- | dep/recastnavigation/Recast/Recast.h | 15 | ||||
| -rw-r--r-- | dep/recastnavigation/Recast/RecastLayers.cpp | 4 | ||||
| -rw-r--r-- | dep/recastnavigation/Recast/RecastMesh.cpp | 4 | ||||
| -rw-r--r-- | dep/recastnavigation/Recast/RecastMeshDetail.cpp | 6 |
14 files changed, 78 insertions, 159 deletions
diff --git a/dep/recastnavigation/Detour/DetourCommon.cpp b/dep/recastnavigation/Detour/DetourCommon.cpp index a98d8c8e56d..b5700f5930b 100644 --- a/dep/recastnavigation/Detour/DetourCommon.cpp +++ b/dep/recastnavigation/Detour/DetourCommon.cpp @@ -16,14 +16,14 @@ // 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 dtMathSqrtf(x); + return sqrtf(x); } void dtClosestPtPointTriangle(float* closest, const float* p, diff --git a/dep/recastnavigation/Detour/DetourCommon.h b/dep/recastnavigation/Detour/DetourCommon.h index 0888614ea9b..ed7c5149db9 100644 --- a/dep/recastnavigation/Detour/DetourCommon.h +++ b/dep/recastnavigation/Detour/DetourCommon.h @@ -32,11 +32,6 @@ feature to find minor members. /// @name General helper functions /// @{ -/// Used to ignore a function parameter. VS complains about unused parameters -/// and this silences the warning. -/// @param [in] _ Unused parameter -template<class T> void dtIgnoreUnused(const T&) { } - /// Swaps the values of the two parameters. /// @param[in,out] a Value A /// @param[in,out] b Value B diff --git a/dep/recastnavigation/Detour/DetourMath.h b/dep/recastnavigation/Detour/DetourMath.h deleted file mode 100644 index 744c562e5f1..00000000000 --- a/dep/recastnavigation/Detour/DetourMath.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef DETOURMATH_H -#define DETOURMATH_H - -/** -@defgroup detour Detour - -Members in this module are wrappers around the standard math library - -*/ - -#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) - -#endif diff --git a/dep/recastnavigation/Detour/DetourNavMesh.cpp b/dep/recastnavigation/Detour/DetourNavMesh.cpp index 3bc2b735055..6b8e2d9d649 100644 --- a/dep/recastnavigation/Detour/DetourNavMesh.cpp +++ b/dep/recastnavigation/Detour/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> @@ -193,13 +193,11 @@ dtNavMesh::dtNavMesh() : m_tileLutMask(0), m_posLookup(0), m_nextFree(0), - m_tiles(0) + m_tiles(0), + m_saltBits(0), + m_tileBits(0), + m_polyBits(0) { -#ifndef DT_POLYREF64 - m_saltBits = 0; - m_tileBits = 0; - m_polyBits = 0; -#endif memset(&m_params, 0, sizeof(dtNavMeshParams)); m_orig[0] = 0; m_orig[1] = 0; @@ -250,17 +248,11 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params) m_nextFree = &m_tiles[i]; } - // Init ID generator values. -#ifndef DT_POLYREF64 - m_tileBits = dtIlog2(dtNextPow2((unsigned int)params->maxTiles)); - m_polyBits = dtIlog2(dtNextPow2((unsigned int)params->maxPolys)); - // Only allow 31 salt bits, since the salt mask is calculated using 32bit uint and it will overflow. - m_saltBits = dtMin((unsigned int)31, 32 - m_tileBits - m_polyBits); - - if (m_saltBits < 10) - return DT_FAILURE | DT_INVALID_PARAM; -#endif - + // Edited by TC + m_tileBits = STATIC_TILE_BITS; + m_polyBits = STATIC_POLY_BITS; + m_saltBits = STATIC_SALT_BITS; + return DT_SUCCESS; } @@ -1214,11 +1206,7 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz tile->offMeshCons = 0; // Update salt, salt should never be zero. -#ifdef DT_POLYREF64 - tile->salt = (tile->salt+1) & ((1<<DT_SALT_BITS)-1); -#else tile->salt = (tile->salt+1) & ((1<<m_saltBits)-1); -#endif if (tile->salt == 0) tile->salt++; diff --git a/dep/recastnavigation/Detour/DetourNavMesh.h b/dep/recastnavigation/Detour/DetourNavMesh.h index d87fee8d5d2..c094e4134d5 100644 --- a/dep/recastnavigation/Detour/DetourNavMesh.h +++ b/dep/recastnavigation/Detour/DetourNavMesh.h @@ -22,39 +22,37 @@ #include "DetourAlloc.h" #include "DetourStatus.h" -// Undefine (or define in a build cofnig) the following line to use 64bit polyref. -// Generally not needed, useful for very large worlds. -// Note: tiles build using 32bit refs are not compatible with 64bit refs! -//#define DT_POLYREF64 1 - -#ifdef DT_POLYREF64 -// TODO: figure out a multiplatform version of uint64_t -// - maybe: https://code.google.com/p/msinttypes/ -// - or: http://www.azillionmonkeys.com/qed/pstdint.h + +// Edited by TC +#if defined(WIN32) && !defined(__MINGW32__) +typedef unsigned __int64 uint64; +#else #include <stdint.h> +#ifndef uint64_t +#ifdef __linux__ +#include <linux/types.h> +#endif #endif +typedef uint64_t uint64; +#endif // Note: If you want to use 64-bit refs, change the types of both dtPolyRef & dtTileRef. // It is also recommended that you change dtHashRef() to a proper 64-bit hash. +// Edited by TC +// We cannot have over 31 bits for either tile nor poly +// without changing polyCount to use 64bits too. +static const int STATIC_SALT_BITS = 12; +static const int STATIC_TILE_BITS = 21; +static const int STATIC_POLY_BITS = 31; + /// A handle to a polygon within a navigation mesh tile. /// @ingroup detour -#ifdef DT_POLYREF64 -static const unsigned int DT_SALT_BITS = 16; -static const unsigned int DT_TILE_BITS = 28; -static const unsigned int DT_POLY_BITS = 20; -typedef uint64_t dtPolyRef; -#else -typedef unsigned int dtPolyRef; -#endif +typedef uint64 dtPolyRef; // Edited by TC /// A handle to a tile within a navigation mesh. /// @ingroup detour -#ifdef DT_POLYREF64 -typedef uint64_t dtTileRef; -#else -typedef unsigned int dtTileRef; -#endif +typedef uint64 dtTileRef; // Edited by TC /// The maximum number of vertices per navigation polygon. /// @ingroup detour @@ -492,11 +490,7 @@ public: /// @param[in] ip The index of the polygon within the tile. inline dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const { -#ifdef DT_POLYREF64 - return ((dtPolyRef)salt << (DT_POLY_BITS+DT_TILE_BITS)) | ((dtPolyRef)it << DT_POLY_BITS) | (dtPolyRef)ip; -#else return ((dtPolyRef)salt << (m_polyBits+m_tileBits)) | ((dtPolyRef)it << m_polyBits) | (dtPolyRef)ip; -#endif } /// Decodes a standard polygon reference. @@ -508,21 +502,12 @@ public: /// @see #encodePolyId inline void decodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const { -#ifdef DT_POLYREF64 - const dtPolyRef saltMask = ((dtPolyRef)1<<DT_SALT_BITS)-1; - const dtPolyRef tileMask = ((dtPolyRef)1<<DT_TILE_BITS)-1; - const dtPolyRef polyMask = ((dtPolyRef)1<<DT_POLY_BITS)-1; - salt = (unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask); - it = (unsigned int)((ref >> DT_POLY_BITS) & tileMask); - ip = (unsigned int)(ref & polyMask); -#else const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1; const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1; const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1; salt = (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask); it = (unsigned int)((ref >> m_polyBits) & tileMask); ip = (unsigned int)(ref & polyMask); -#endif } /// Extracts a tile's salt value from the specified polygon reference. @@ -531,13 +516,8 @@ public: /// @see #encodePolyId inline unsigned int decodePolyIdSalt(dtPolyRef ref) const { -#ifdef DT_POLYREF64 - const dtPolyRef saltMask = ((dtPolyRef)1<<DT_SALT_BITS)-1; - return (unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask); -#else const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1; return (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask); -#endif } /// Extracts the tile's index from the specified polygon reference. @@ -546,13 +526,8 @@ public: /// @see #encodePolyId inline unsigned int decodePolyIdTile(dtPolyRef ref) const { -#ifdef DT_POLYREF64 - const dtPolyRef tileMask = ((dtPolyRef)1<<DT_TILE_BITS)-1; - return (unsigned int)((ref >> DT_POLY_BITS) & tileMask); -#else const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1; return (unsigned int)((ref >> m_polyBits) & tileMask); -#endif } /// Extracts the polygon's index (within its tile) from the specified polygon reference. @@ -561,13 +536,8 @@ public: /// @see #encodePolyId inline unsigned int decodePolyIdPoly(dtPolyRef ref) const { -#ifdef DT_POLYREF64 - const dtPolyRef polyMask = ((dtPolyRef)1<<DT_POLY_BITS)-1; - return (unsigned int)(ref & polyMask); -#else const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1; return (unsigned int)(ref & polyMask); -#endif } /// @} @@ -627,11 +597,9 @@ private: dtMeshTile* m_nextFree; ///< Freelist of tiles. dtMeshTile* m_tiles; ///< List of tiles. -#ifndef DT_POLYREF64 unsigned int m_saltBits; ///< Number of salt bits in the tile ID. unsigned int m_tileBits; ///< Number of tile bits in the tile ID. unsigned int m_polyBits; ///< Number of poly bits in the tile ID. -#endif }; /// Allocates a navigation mesh object using the Detour allocator. diff --git a/dep/recastnavigation/Detour/DetourNavMeshBuilder.cpp b/dep/recastnavigation/Detour/DetourNavMeshBuilder.cpp index 1bf271bed7a..9d8471b96a1 100644 --- a/dep/recastnavigation/Detour/DetourNavMeshBuilder.cpp +++ b/dep/recastnavigation/Detour/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)dtMathFloorf((float)it.bmin[1]*ch/cs); - it.bmax[1] = (unsigned short)dtMathCeilf((float)it.bmax[1]*ch/cs); + it.bmin[1] = (unsigned short)floorf((float)it.bmin[1]*ch/cs); + it.bmax[1] = (unsigned short)ceilf((float)it.bmax[1]*ch/cs); } int curNode = 0; diff --git a/dep/recastnavigation/Detour/DetourNavMeshQuery.cpp b/dep/recastnavigation/Detour/DetourNavMeshQuery.cpp index bdbee004834..e6557cf707e 100644 --- a/dep/recastnavigation/Detour/DetourNavMeshQuery.cpp +++ b/dep/recastnavigation/Detour/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,8 +99,9 @@ inline float dtQueryFilter::getCost(const float* pa, const float* pb, return dtVdist(pa, pb) * m_areaCost[curPoly->getArea()]; } #endif - -static const float H_SCALE = 0.999f; // Search heuristic scale. + +// Edited by TC +static const float H_SCALE = 2.0f; // Search heuristic scale. dtNavMeshQuery* dtAllocNavMeshQuery() @@ -510,7 +511,11 @@ dtStatus dtNavMeshQuery::closestPointOnPoly(dtPolyRef ref, const float* pos, flo return DT_FAILURE | DT_INVALID_PARAM; if (!tile) return DT_FAILURE | DT_INVALID_PARAM; - + + // Edited by TC + if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION) + return DT_FAILURE; + closestPointOnPolyInTile(tile, poly, pos, closest); return DT_SUCCESS; @@ -3342,7 +3347,7 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen dtVsub(hitNormal, centerPos, hitPos); dtVnormalize(hitNormal); - *hitDist = dtMathSqrtf(radiusSqr); + *hitDist = dtSqrt(radiusSqr); return status; } diff --git a/dep/recastnavigation/Detour/DetourNavMeshQuery.h b/dep/recastnavigation/Detour/DetourNavMeshQuery.h index 6edf5bf6117..d431bf177bd 100644 --- a/dep/recastnavigation/Detour/DetourNavMeshQuery.h +++ b/dep/recastnavigation/Detour/DetourNavMeshQuery.h @@ -200,8 +200,8 @@ public: /// Finalizes and returns the results of an incomplete sliced path query, returning the path to the furthest /// polygon on the existing path that was visited during the search. - /// @param[in] existing An array of polygon references for the existing path. - /// @param[in] existingSize The number of polygon in the @p existing array. + /// @param[out] existing An array of polygon references for the existing path. + /// @param[out] existingSize The number of polygon in the @p existing array. /// @param[out] path An ordered list of polygon references representing the path. (Start to end.) /// [(polyRef) * @p pathCount] /// @param[out] pathCount The number of polygons returned in the @p path array. diff --git a/dep/recastnavigation/Detour/DetourNode.cpp b/dep/recastnavigation/Detour/DetourNode.cpp index 57cb2066696..4c8215e20d0 100644 --- a/dep/recastnavigation/Detour/DetourNode.cpp +++ b/dep/recastnavigation/Detour/DetourNode.cpp @@ -22,30 +22,17 @@ #include "DetourCommon.h" #include <string.h> -#ifdef DT_POLYREF64 -// From Thomas Wang, https://gist.github.com/badboy/6267743 inline unsigned int dtHashRef(dtPolyRef a) { - a = (~a) + (a << 18); // a = (a << 18) - a - 1; - a = a ^ (a >> 31); - a = a * 21; // a = (a + (a << 2)) + (a << 4); - a = a ^ (a >> 11); - a = a + (a << 6); - a = a ^ (a >> 22); - return (unsigned int)a; + // Edited by TC + a = (~a) + (a << 18); + a = a ^ (a >> 31); + a = a * 21; + a = a ^ (a >> 11); + a = a + (a << 6); + a = a ^ (a >> 22); + return (unsigned int)a; } -#else -inline unsigned int dtHashRef(dtPolyRef a) -{ - a += ~(a<<15); - a ^= (a>>10); - a += (a<<3); - a ^= (a>>6); - a += ~(a<<11); - a ^= (a>>16); - return (unsigned int)a; -} -#endif ////////////////////////////////////////////////////////////////////////////////////////// dtNodePool::dtNodePool(int maxNodes, int hashSize) : diff --git a/dep/recastnavigation/Recast/Recast.cpp b/dep/recastnavigation/Recast/Recast.cpp index b9d86036c3f..803daac3bcf 100644 --- a/dep/recastnavigation/Recast/Recast.cpp +++ b/dep/recastnavigation/Recast/Recast.cpp @@ -208,11 +208,12 @@ void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcAllocHeightfield, rcHeightfield -bool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height, +bool rcCreateHeightfield(rcContext* /*ctx*/, rcHeightfield& hf, int width, int height, const float* bmin, const float* bmax, float cs, float ch) { - rcIgnoreUnused(ctx); + // TODO: VC complains about unref formal variable, figure out a way to handle this better. +// rcAssert(ctx); hf.width = width; hf.height = height; @@ -244,12 +245,13 @@ static void calcTriNormal(const float* v0, const float* v1, const float* v2, flo /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles -void rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, +void rcMarkWalkableTriangles(rcContext* /*ctx*/, const float walkableSlopeAngle, const float* verts, int /*nv*/, const int* tris, int nt, unsigned char* areas) { - rcIgnoreUnused(ctx); + // TODO: VC complains about unref formal variable, figure out a way to handle this better. +// rcAssert(ctx); const float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI); @@ -273,12 +275,13 @@ void rcMarkWalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, /// See the #rcConfig documentation for more information on the configuration parameters. /// /// @see rcHeightfield, rcClearUnwalkableTriangles, rcRasterizeTriangles -void rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, +void rcClearUnwalkableTriangles(rcContext* /*ctx*/, const float walkableSlopeAngle, const float* verts, int /*nv*/, const int* tris, int nt, unsigned char* areas) { - rcIgnoreUnused(ctx); + // TODO: VC complains about unref formal variable, figure out a way to handle this better. +// rcAssert(ctx); const float walkableThr = cosf(walkableSlopeAngle/180.0f*RC_PI); @@ -294,9 +297,10 @@ void rcClearUnwalkableTriangles(rcContext* ctx, const float walkableSlopeAngle, } } -int rcGetHeightFieldSpanCount(rcContext* ctx, rcHeightfield& hf) +int rcGetHeightFieldSpanCount(rcContext* /*ctx*/, rcHeightfield& hf) { - rcIgnoreUnused(ctx); + // TODO: VC complains about unref formal variable, figure out a way to handle this better. +// rcAssert(ctx); const int w = hf.width; const int h = hf.height; diff --git a/dep/recastnavigation/Recast/Recast.h b/dep/recastnavigation/Recast/Recast.h index 336837ec270..fb36aa4c5cf 100644 --- a/dep/recastnavigation/Recast/Recast.h +++ b/dep/recastnavigation/Recast/Recast.h @@ -219,7 +219,7 @@ struct rcConfig int maxEdgeLen; /// The maximum distance a simplfied contour's border edges should deviate - /// the original raw contour. [Limit: >=0] [Units: vx] + /// the original raw contour. [Limit: >=0] [Units: wu] float maxSimplificationError; /// The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx] @@ -243,7 +243,7 @@ struct rcConfig }; /// Defines the number of bits allocated to rcSpan::smin and rcSpan::smax. -static const int RC_SPAN_HEIGHT_BITS = 13; +static const int RC_SPAN_HEIGHT_BITS = 16; // EDITED BY TC /// Defines the maximum value for rcSpan::smin and rcSpan::smax. static const int RC_SPAN_MAX_HEIGHT = (1<<RC_SPAN_HEIGHT_BITS)-1; @@ -255,9 +255,9 @@ static const int RC_SPANS_PER_POOL = 2048; /// @see rcHeightfield struct rcSpan { - unsigned int smin : 13; ///< The lower limit of the span. [Limit: < #smax] - unsigned int smax : 13; ///< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT] - unsigned int area : 6; ///< The area id assigned to the span. + unsigned int smin : 16; ///< The lower limit of the span. [Limit: < #smax] + unsigned int smax : 16; ///< The upper limit of the span. [Limit: <= #RC_SPAN_MAX_HEIGHT] + unsigned char area; ///< The area id assigned to the span. rcSpan* next; ///< The next span higher up in column. }; @@ -549,11 +549,6 @@ static const int RC_NOT_CONNECTED = 0x3f; /// @name General helper functions /// @{ -/// Used to ignore a function parameter. VS complains about unused parameters -/// and this silences the warning. -/// @param [in] _ Unused parameter -template<class T> void rcIgnoreUnused(const T&) { } - /// Swaps the values of the two parameters. /// @param[in,out] a Value A /// @param[in,out] b Value B diff --git a/dep/recastnavigation/Recast/RecastLayers.cpp b/dep/recastnavigation/Recast/RecastLayers.cpp index 204f72e8cb2..5ea6cb79d16 100644 --- a/dep/recastnavigation/Recast/RecastLayers.cpp +++ b/dep/recastnavigation/Recast/RecastLayers.cpp @@ -325,7 +325,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, continue; // Skip if the height range would become too large. const int ymin = rcMin(root.ymin, regn.ymin); - const int ymax = rcMax(root.ymax, regn.ymax); + const int ymax = rcMax(root.ymax, regn.ymax); // Edited by TC if ((ymax - ymin) >= 255) continue; @@ -373,7 +373,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, continue; // Skip if the height range would become too large. const int ymin = rcMin(ri.ymin, rj.ymin); - const int ymax = rcMax(ri.ymax, rj.ymax); + const int ymax = rcMax(ri.ymax, rj.ymax); // Edited by TC if ((ymax - ymin) >= 255) continue; diff --git a/dep/recastnavigation/Recast/RecastMesh.cpp b/dep/recastnavigation/Recast/RecastMesh.cpp index 23a466053b1..13aad2af01c 100644 --- a/dep/recastnavigation/Recast/RecastMesh.cpp +++ b/dep/recastnavigation/Recast/RecastMesh.cpp @@ -1105,9 +1105,7 @@ bool rcBuildPolyMesh(rcContext* ctx, rcContourSet& cset, const int nvp, rcPolyMe unsigned short* pa = &polys[bestPa*nvp]; unsigned short* pb = &polys[bestPb*nvp]; mergePolys(pa, pb, bestEa, bestEb, tmpPoly, nvp); - unsigned short* lastPoly = &polys[(npolys-1)*nvp]; - if (pb != lastPoly) - memcpy(pb, lastPoly, sizeof(unsigned short)*nvp); + memcpy(pb, &polys[(npolys-1)*nvp], sizeof(unsigned short)*nvp); npolys--; } else diff --git a/dep/recastnavigation/Recast/RecastMeshDetail.cpp b/dep/recastnavigation/Recast/RecastMeshDetail.cpp index 77438fd8f58..f49d67400c2 100644 --- a/dep/recastnavigation/Recast/RecastMeshDetail.cpp +++ b/dep/recastnavigation/Recast/RecastMeshDetail.cpp @@ -200,8 +200,8 @@ static unsigned short getHeight(const float fx, const float fy, const float fz, { int ix = (int)floorf(fx*ics + 0.01f); int iz = (int)floorf(fz*ics + 0.01f); - ix = rcClamp(ix-hp.xmin, 0, hp.width - 1); - iz = rcClamp(iz-hp.ymin, 0, hp.height - 1); + ix = rcClamp(ix-hp.xmin, 0, hp.width); + iz = rcClamp(iz-hp.ymin, 0, hp.height); unsigned short h = hp.data[ix+iz*hp.width]; if (h == RC_UNSET_HEIGHT) { @@ -554,7 +554,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin, float dx = vi[0] - vj[0]; float dy = vi[1] - vj[1]; float dz = vi[2] - vj[2]; - float d = sqrtf(dx*dx + dz*dz); + float d = rcSqrt(dx*dx + dz*dz); int nn = 1 + (int)floorf(d/sampleDist); if (nn >= MAX_VERTS_PER_EDGE) nn = MAX_VERTS_PER_EDGE-1; if (nverts+nn >= MAX_VERTS) |
