Skip to content

Commit

Permalink
Merge pull request recastnavigation#82 from Kromster80/loopFix
Browse files Browse the repository at this point in the history
Loop fix and MAX_SEARCH
  • Loading branch information
memononen committed Feb 19, 2015
2 parents 2ab3968 + 3ca4db4 commit acbbe50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Detour/Source/DetourNavMeshQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,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,
Expand All @@ -715,9 +715,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.
Expand Down
2 changes: 1 addition & 1 deletion Recast/Source/RecastMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short
}

// Remove vertex.
for (int i = (int)rem; i < mesh.nverts; ++i)
for (int i = (int)rem; i < mesh.nverts - 1; ++i)
{
mesh.verts[i*3+0] = mesh.verts[(i+1)*3+0];
mesh.verts[i*3+1] = mesh.verts[(i+1)*3+1];
Expand Down

0 comments on commit acbbe50

Please sign in to comment.