diff --git a/DebugUtils/Source/DetourDebugDraw.cpp b/DebugUtils/Source/DetourDebugDraw.cpp index b79ea80c..8fa13fde 100755 --- a/DebugUtils/Source/DetourDebugDraw.cpp +++ b/DebugUtils/Source/DetourDebugDraw.cpp @@ -511,7 +511,7 @@ static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheL for (int x = 0; x < w; ++x) { const int idx = x+y*w; - const int h = (int)layer.heights[idx]; + const int lh = (int)layer.heights[idx]; if (h == 0xff) continue; for (int dir = 0; dir < 4; ++dir) @@ -520,10 +520,10 @@ static void debugDrawTileCachePortals(struct duDebugDraw* dd, const dtTileCacheL { const int* seg = &segs[dir*4]; const float ax = bmin[0] + (x+seg[0])*cs; - const float ay = bmin[1] + (h+2)*ch; + const float ay = bmin[1] + (lh+2)*ch; const float az = bmin[2] + (y+seg[1])*cs; const float bx = bmin[0] + (x+seg[2])*cs; - const float by = bmin[1] + (h+2)*ch; + const float by = bmin[1] + (lh+2)*ch; const float bz = bmin[2] + (y+seg[3])*cs; dd->vertex(ax, ay, az, pcol); dd->vertex(bx, by, bz, pcol); @@ -560,10 +560,10 @@ void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLay { for (int x = 0; x < w; ++x) { - const int idx = x+y*w; - const int h = (int)layer.heights[idx]; - if (h == 0xff) continue; - const unsigned char area = layer.areas[idx]; + const int lidx = x+y*w; + const int lh = (int)layer.heights[lidx]; + if (lh == 0xff) continue; + const unsigned char area = layer.areas[lidx]; unsigned int col; if (area == 63) @@ -574,7 +574,7 @@ void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLay col = duLerpCol(color, duIntToCol(area, 255), 32); const float fx = bmin[0] + x*cs; - const float fy = bmin[1] + (h+1)*ch; + const float fy = bmin[1] + (lh+1)*ch; const float fz = bmin[2] + y*cs; dd->vertex(fx, fy, fz, col); @@ -614,15 +614,15 @@ void duDebugDrawTileCacheLayerRegions(struct duDebugDraw* dd, const dtTileCacheL { for (int x = 0; x < w; ++x) { - const int idx = x+y*w; - const int h = (int)layer.heights[idx]; - if (h == 0xff) continue; - const unsigned char reg = layer.regs[idx]; + const int lidx = x+y*w; + const int lh = (int)layer.heights[lidx]; + if (lh == 0xff) continue; + const unsigned char reg = layer.regs[lidx]; unsigned int col = duLerpCol(color, duIntToCol(reg, 255), 192); const float fx = bmin[0] + x*cs; - const float fy = bmin[1] + (h+1)*ch; + const float fy = bmin[1] + (lh+1)*ch; const float fz = bmin[2] + y*cs; dd->vertex(fx, fy, fz, col); diff --git a/DebugUtils/Source/RecastDebugDraw.cpp b/DebugUtils/Source/RecastDebugDraw.cpp index a9ef1441..b1a57ef4 100644 --- a/DebugUtils/Source/RecastDebugDraw.cpp +++ b/DebugUtils/Source/RecastDebugDraw.cpp @@ -344,8 +344,8 @@ static void drawLayerPortals(duDebugDraw* dd, const rcHeightfieldLayer* layer) for (int x = 0; x < w; ++x) { const int idx = x+y*w; - const int h = (int)layer->heights[idx]; - if (h == 255) continue; + const int lh = (int)layer->heights[idx]; + if (lh == 255) continue; for (int dir = 0; dir < 4; ++dir) { @@ -353,10 +353,10 @@ static void drawLayerPortals(duDebugDraw* dd, const rcHeightfieldLayer* layer) { const int* seg = &segs[dir*4]; const float ax = layer->bmin[0] + (x+seg[0])*cs; - const float ay = layer->bmin[1] + (h+2)*ch; + const float ay = layer->bmin[1] + (lh+2)*ch; const float az = layer->bmin[2] + (y+seg[1])*cs; const float bx = layer->bmin[0] + (x+seg[2])*cs; - const float by = layer->bmin[1] + (h+2)*ch; + const float by = layer->bmin[1] + (lh+2)*ch; const float bz = layer->bmin[2] + (y+seg[3])*cs; dd->vertex(ax, ay, az, pcol); dd->vertex(bx, by, bz, pcol); @@ -392,10 +392,10 @@ void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLaye { for (int x = 0; x < w; ++x) { - const int idx = x+y*w; - const int h = (int)layer.heights[idx]; + const int lidx = x+y*w; + const int lh = (int)layer.heights[lidx]; if (h == 0xff) continue; - const unsigned char area = layer.areas[idx]; + const unsigned char area = layer.areas[lidx]; unsigned int col; if (area == RC_WALKABLE_AREA) @@ -406,7 +406,7 @@ void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLaye col = duLerpCol(color, duIntToCol(area, 255), 32); const float fx = layer.bmin[0] + x*cs; - const float fy = layer.bmin[1] + (h+1)*ch; + const float fy = layer.bmin[1] + (lh+1)*ch; const float fz = layer.bmin[2] + y*cs; dd->vertex(fx, fy, fz, col); @@ -719,9 +719,9 @@ void duDebugDrawRegionConnections(duDebugDraw* dd, const rcContourSet& cset, con for (int i = 0; i < cset.nconts; ++i) { const rcContour* cont = &cset.conts[i]; - unsigned int color = duDarkenCol(duIntToCol(cont->reg,a)); + unsigned int col = duDarkenCol(duIntToCol(cont->reg,a)); getContourCenter(cont, orig, cs, ch, pos); - dd->vertex(pos, color); + dd->vertex(pos, col); } dd->end(); } diff --git a/Detour/Source/DetourNavMesh.cpp b/Detour/Source/DetourNavMesh.cpp index 36703ed0..2be9afd4 100644 --- a/Detour/Source/DetourNavMesh.cpp +++ b/Detour/Source/DetourNavMesh.cpp @@ -493,19 +493,19 @@ void dtNavMesh::connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int // Link target poly to off-mesh connection. if (targetCon->flags & DT_OFFMESH_CON_BIDIR) { - unsigned int idx = allocLink(tile); - if (idx != DT_NULL_LINK) + unsigned int tidx = allocLink(tile); + if (tidx != DT_NULL_LINK) { const unsigned short landPolyIdx = (unsigned short)decodePolyIdPoly(ref); dtPoly* landPoly = &tile->polys[landPolyIdx]; - dtLink* link = &tile->links[idx]; + dtLink* link = &tile->links[tidx]; link->ref = getPolyRefBase(target) | (dtPolyRef)(targetCon->poly); link->edge = 0xff; link->side = (unsigned char)side; link->bmin = link->bmax = 0; // Add to linked list. link->next = landPoly->firstLink; - landPoly->firstLink = idx; + landPoly->firstLink = tidx; } } } @@ -600,19 +600,19 @@ void dtNavMesh::connectIntOffMeshLinks(dtMeshTile* tile) if (j == 0 || (j == 1 && (con->flags & DT_OFFMESH_CON_BIDIR))) { // Link target poly to off-mesh connection. - unsigned int idx = allocLink(tile); - if (idx != DT_NULL_LINK) + unsigned int tidx = allocLink(tile); + if (tidx != DT_NULL_LINK) { const unsigned short landPolyIdx = (unsigned short)decodePolyIdPoly(ref); dtPoly* landPoly = &tile->polys[landPolyIdx]; - dtLink* link = &tile->links[idx]; + dtLink* link = &tile->links[tidx]; link->ref = base | (dtPolyRef)(con->poly); link->edge = 0xff; link->side = 0xff; link->bmin = link->bmax = 0; // Add to linked list. link->next = landPoly->firstLink; - landPoly->firstLink = idx; + landPoly->firstLink = tidx; } } diff --git a/Detour/Source/DetourNavMeshQuery.cpp b/Detour/Source/DetourNavMeshQuery.cpp index bb1ae670..24ade0a2 100644 --- a/Detour/Source/DetourNavMeshQuery.cpp +++ b/Detour/Source/DetourNavMeshQuery.cpp @@ -821,7 +821,7 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, // Add or update the node. neighbourNode->pidx = m_nodePool->getNodeIdx(bestNode); neighbourNode->id = neighbourRef; - neighbourNode->flags &= ~DT_NODE_CLOSED; + neighbourNode->flags = (neighbourNode->flags & ~DT_NODE_CLOSED); neighbourNode->cost = cost; neighbourNode->total = total; @@ -1078,7 +1078,7 @@ dtStatus dtNavMeshQuery::updateSlicedFindPath(const int maxIter, int* doneIters) // Add or update the node. neighbourNode->pidx = m_nodePool->getNodeIdx(bestNode); neighbourNode->id = neighbourRef; - neighbourNode->flags &= ~DT_NODE_CLOSED; + neighbourNode->flags = (neighbourNode->flags & ~DT_NODE_CLOSED); neighbourNode->cost = cost; neighbourNode->total = total; @@ -2218,7 +2218,7 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float* continue; neighbourNode->id = neighbourRef; - neighbourNode->flags &= ~DT_NODE_CLOSED; + neighbourNode->flags = (neighbourNode->flags & ~DT_NODE_CLOSED); neighbourNode->pidx = m_nodePool->getNodeIdx(bestNode); neighbourNode->total = total; @@ -2398,7 +2398,7 @@ dtStatus dtNavMeshQuery::findPolysAroundShape(dtPolyRef startRef, const float* v continue; neighbourNode->id = neighbourRef; - neighbourNode->flags &= ~DT_NODE_CLOSED; + neighbourNode->flags = (neighbourNode->flags & ~DT_NODE_CLOSED); neighbourNode->pidx = m_nodePool->getNodeIdx(bestNode); neighbourNode->total = total; @@ -2720,17 +2720,17 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* else { // Internal edge - dtPolyRef ref = 0; + dtPolyRef neiRef = 0; if (poly->neis[j]) { const unsigned int idx = (unsigned int)(poly->neis[j]-1); - ref = m_nav->getPolyRefBase(tile) | idx; - if (!filter->passFilter(ref, tile, &tile->polys[idx])) - ref = 0; + neiRef = m_nav->getPolyRefBase(tile) | idx; + if (!filter->passFilter(neiRef, tile, &tile->polys[idx])) + neiRef = 0; } // If the edge leads to another polygon and portals are not stored, skip. - if (ref != 0 && !storePortals) + if (neiRef != 0 && !storePortals) continue; if (n < maxSegments) @@ -2741,7 +2741,7 @@ dtStatus dtNavMeshQuery::getPolyWallSegments(dtPolyRef ref, const dtQueryFilter* dtVcopy(seg+0, vj); dtVcopy(seg+3, vi); if (segmentRefs) - segmentRefs[n] = ref; + segmentRefs[n] = neiRef; n++; } else @@ -2977,7 +2977,7 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen continue; neighbourNode->id = neighbourRef; - neighbourNode->flags &= ~DT_NODE_CLOSED; + neighbourNode->flags = (neighbourNode->flags & ~DT_NODE_CLOSED); neighbourNode->pidx = m_nodePool->getNodeIdx(bestNode); neighbourNode->total = total; diff --git a/DetourCrowd/Source/DetourCrowd.cpp b/DetourCrowd/Source/DetourCrowd.cpp index ca984dc6..7e0cf685 100644 --- a/DetourCrowd/Source/DetourCrowd.cpp +++ b/DetourCrowd/Source/DetourCrowd.cpp @@ -772,6 +772,8 @@ void dtCrowd::updateMoveRequest(const float /*dt*/) // Update requests. m_pathq.update(MAX_ITERS_PER_UPDATE); + dtStatus status; + // Process path results. for (int i = 0; i < m_moveRequestCount; ++i) { @@ -781,7 +783,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/) if (req->state == MR_TARGET_WAITING_FOR_PATH) { // Poll path queue. - dtStatus status = m_pathq.getRequestStatus(req->pathqRef); + status = m_pathq.getRequestStatus(req->pathqRef); if (dtStatusFailed(status)) { req->pathqRef = DT_PATHQ_INVALID; @@ -800,7 +802,7 @@ void dtCrowd::updateMoveRequest(const float /*dt*/) dtPolyRef* res = m_pathResult; bool valid = true; int nres = 0; - dtStatus status = m_pathq.getPathResult(req->pathqRef, res, &nres, m_maxPathResult); + status = m_pathq.getPathResult(req->pathqRef, res, &nres, m_maxPathResult); if (dtStatusFailed(status) || !nres) valid = false; diff --git a/DetourCrowd/Source/DetourObstacleAvoidance.cpp b/DetourCrowd/Source/DetourObstacleAvoidance.cpp index a77c5733..d3f90b7a 100644 --- a/DetourCrowd/Source/DetourObstacleAvoidance.cpp +++ b/DetourCrowd/Source/DetourObstacleAvoidance.cpp @@ -491,12 +491,12 @@ int dtObstacleAvoidanceQuery::sampleVelocityAdaptive(const float* pos, const flo for (int j = 0; j < nr; ++j) { - const float rad = (float)(nr-j)/(float)nr; + const float r = (float)(nr-j)/(float)nr; float a = dang + (j&1)*0.5f*da; for (int i = 0; i < nd; ++i) { - pat[npat*2+0] = cosf(a)*rad; - pat[npat*2+1] = sinf(a)*rad; + pat[npat*2+0] = cosf(a)*r; + pat[npat*2+1] = sinf(a)*r; npat++; a += da; } diff --git a/DetourTileCache/Source/DetourTileCache.cpp b/DetourTileCache/Source/DetourTileCache.cpp index 7e56f9e9..3a213a98 100644 --- a/DetourTileCache/Source/DetourTileCache.cpp +++ b/DetourTileCache/Source/DetourTileCache.cpp @@ -668,7 +668,7 @@ dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh* { navmesh->removeTile(navmesh->getTileRefAt(tile->header->tx,tile->header->ty,tile->header->tlayer),0,0); // Let the navmesh own the data. - dtStatus status = navmesh->addTile(navData,navDataSize,DT_TILE_FREE_DATA,0,0); + status = navmesh->addTile(navData,navDataSize,DT_TILE_FREE_DATA,0,0); if (dtStatusFailed(status)) { dtFree(navData); diff --git a/DetourTileCache/Source/DetourTileCacheBuilder.cpp b/DetourTileCache/Source/DetourTileCacheBuilder.cpp index eb575c90..ca336a0e 100644 --- a/DetourTileCache/Source/DetourTileCacheBuilder.cpp +++ b/DetourTileCache/Source/DetourTileCacheBuilder.cpp @@ -708,10 +708,10 @@ static unsigned char getCornerHeight(dtTileCacheLayer& layer, if (px >= 0 && pz >= 0 && px < w && pz < h) { const int idx = px + pz*w; - const int h = (int)layer.heights[idx]; - if (dtAbs(h-y) <= walkableClimb && layer.areas[idx] != DT_TILECACHE_NULL_AREA) + const int lh = (int)layer.heights[idx]; + if (dtAbs(lh-y) <= walkableClimb && layer.areas[idx] != DT_TILECACHE_NULL_AREA) { - height = dtMax(height, (unsigned char)h); + height = dtMax(height, (unsigned char)lh); portal &= (layer.cons[idx] >> 4); if (preg != 0xff && preg != layer.regs[idx]) allSameReg = false; @@ -809,11 +809,11 @@ dtStatus dtBuildTileCacheContours(dtTileCacheAlloc* alloc, unsigned char* vn = &temp.verts[i*4]; unsigned char nei = vn[3]; // The neighbour reg is stored at segment vertex of a segment. bool shouldRemove = false; - unsigned char h = getCornerHeight(layer, (int)v[0], (int)v[1], (int)v[2], - walkableClimb, shouldRemove); + unsigned char lh = getCornerHeight(layer, (int)v[0], (int)v[1], (int)v[2], + walkableClimb, shouldRemove); dst[0] = v[0]; - dst[1] = h; + dst[1] = lh; dst[2] = v[2]; // Store portal direction and remove status to the fourth component. @@ -989,9 +989,9 @@ static bool buildMeshAdjacency(dtTileCacheAlloc* alloc, if (zmin > zmax) dtSwap(zmin, zmax); - for (int i = 0; i < edgeCount; ++i) + for (int m = 0; m < edgeCount; ++m) { - rcEdge& e = edges[i]; + rcEdge& e = edges[m]; // Skip connected edges. if (e.poly[0] != e.poly[1]) continue; @@ -1019,9 +1019,9 @@ static bool buildMeshAdjacency(dtTileCacheAlloc* alloc, unsigned short xmax = (unsigned short)vb[0]; if (xmin > xmax) dtSwap(xmin, xmax); - for (int i = 0; i < edgeCount; ++i) + for (int m = 0; m < edgeCount; ++m) { - rcEdge& e = edges[i]; + rcEdge& e = edges[m]; // Skip connected edges. if (e.poly[0] != e.poly[1]) continue; @@ -1458,9 +1458,9 @@ static bool canRemoveVertex(dtTileCachePolyMesh& mesh, const unsigned short rem) // Check if the edge exists bool exists = false; - for (int k = 0; k < nedges; ++k) + for (int m = 0; m < nedges; ++m) { - unsigned short* e = &edges[k*3]; + unsigned short* e = &edges[m*3]; if (e[1] == b) { // Exists, increment vertex share count. diff --git a/Recast/Source/Recast.cpp b/Recast/Source/Recast.cpp index 283cf0c1..803daac3 100644 --- a/Recast/Source/Recast.cpp +++ b/Recast/Source/Recast.cpp @@ -439,13 +439,13 @@ bool rcBuildCompactHeightfield(rcContext* ctx, const int walkableHeight, const i if ((top - bot) >= walkableHeight && rcAbs((int)ns.y - (int)s.y) <= walkableClimb) { // Mark direction as walkable. - const int idx = k - (int)nc.index; - if (idx < 0 || idx > MAX_LAYERS) + const int lidx = k - (int)nc.index; + if (lidx < 0 || lidx > MAX_LAYERS) { - tooHighNeighbour = rcMax(tooHighNeighbour, idx); + tooHighNeighbour = rcMax(tooHighNeighbour, lidx); continue; } - rcSetCon(s, dir, idx); + rcSetCon(s, dir, lidx); break; } } diff --git a/Recast/Source/RecastArea.cpp b/Recast/Source/RecastArea.cpp index a59acc53..d0465b3d 100644 --- a/Recast/Source/RecastArea.cpp +++ b/Recast/Source/RecastArea.cpp @@ -75,8 +75,8 @@ bool rcErodeWalkableArea(rcContext* ctx, int radius, rcCompactHeightfield& chf) { const int nx = x + rcGetDirOffsetX(dir); const int ny = y + rcGetDirOffsetY(dir); - const int ni = (int)chf.cells[nx+ny*w].index + rcGetCon(s, dir); - if (chf.areas[ni] != RC_NULL_AREA) + const int nidx = (int)chf.cells[nx+ny*w].index + rcGetCon(s, dir); + if (chf.areas[nidx] != RC_NULL_AREA) { nc++; } diff --git a/Recast/Source/RecastContour.cpp b/Recast/Source/RecastContour.cpp index 79c71680..5d58e522 100644 --- a/Recast/Source/RecastContour.cpp +++ b/Recast/Source/RecastContour.cpp @@ -752,9 +752,9 @@ bool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf, if (borderSize > 0) { // If the heightfield was build with bordersize, remove the offset. - for (int i = 0; i < cont->nverts; ++i) + for (int j = 0; j < cont->nverts; ++j) { - int* v = &cont->verts[i*4]; + int* v = &cont->verts[j*4]; v[0] -= borderSize; v[2] -= borderSize; } @@ -771,9 +771,9 @@ bool rcBuildContours(rcContext* ctx, rcCompactHeightfield& chf, if (borderSize > 0) { // If the heightfield was build with bordersize, remove the offset. - for (int i = 0; i < cont->nrverts; ++i) + for (int j = 0; j < cont->nrverts; ++j) { - int* v = &cont->rverts[i*4]; + int* v = &cont->rverts[j*4]; v[0] -= borderSize; v[2] -= borderSize; } diff --git a/Recast/Source/RecastLayers.cpp b/Recast/Source/RecastLayers.cpp index 617cf45f..c6168107 100644 --- a/Recast/Source/RecastLayers.cpp +++ b/Recast/Source/RecastLayers.cpp @@ -550,14 +550,14 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, const int cx = borderSize+x; const int cy = borderSize+y; const rcCompactCell& c = chf.cells[cx+cy*w]; - for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i) + for (int j = (int)c.index, nj = (int)(c.index+c.count); j < nj; ++j) { - const rcCompactSpan& s = chf.spans[i]; + const rcCompactSpan& s = chf.spans[j]; // Skip unassigned regions. - if (srcReg[i] == 0xff) + if (srcReg[j] == 0xff) continue; // Skip of does nto belong to current layer. - unsigned char lid = regs[srcReg[i]].layerId; + unsigned char lid = regs[srcReg[j]].layerId; if (lid != curId) continue; @@ -570,7 +570,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, // Store height and area type. const int idx = x+y*lw; layer->heights[idx] = (unsigned char)(s.y - hmin); - layer->areas[idx] = chf.areas[i]; + layer->areas[idx] = chf.areas[j]; // Check connection. unsigned char portal = 0; diff --git a/Recast/Source/RecastMesh.cpp b/Recast/Source/RecastMesh.cpp index db8c4c22..012115f3 100644 --- a/Recast/Source/RecastMesh.cpp +++ b/Recast/Source/RecastMesh.cpp @@ -550,9 +550,9 @@ static bool canRemoveVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned sho // Check if the edge exists bool exists = false; - for (int k = 0; k < nedges; ++k) + for (int m = 0; m < nedges; ++m) { - int* e = &edges[k*3]; + int* e = &edges[m*3]; if (e[1] == b) { // Exists, increment vertex share count. diff --git a/Recast/Source/RecastMeshDetail.cpp b/Recast/Source/RecastMeshDetail.cpp index e8c23fb1..b3872754 100644 --- a/Recast/Source/RecastMeshDetail.cpp +++ b/Recast/Source/RecastMeshDetail.cpp @@ -267,11 +267,11 @@ static int addEdge(rcContext* ctx, int* edges, int& nedges, const int maxEdges, int e = findEdge(edges, nedges, s, t); if (e == UNDEF) { - int* e = &edges[nedges*4]; - e[0] = s; - e[1] = t; - e[2] = l; - e[3] = r; + int* edge = &edges[nedges*4]; + edge[0] = s; + edge[1] = t; + edge[2] = l; + edge[3] = r; return nedges++; } else @@ -583,10 +583,10 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin, int maxi = -1; for (int m = a+1; m < b; ++m) { - float d = distancePtSeg(&edge[m*3],va,vb); - if (d > maxd) + float dev = distancePtSeg(&edge[m*3],va,vb); + if (dev > maxd) { - maxd = d; + maxd = dev; maxi = m; } } diff --git a/Recast/Source/RecastRegion.cpp b/Recast/Source/RecastRegion.cpp index 4290972e..76e631cc 100644 --- a/Recast/Source/RecastRegion.cpp +++ b/Recast/Source/RecastRegion.cpp @@ -298,9 +298,9 @@ static bool floodRegion(int x, int y, int i, const int ai2 = (int)chf.cells[ax2+ay2*w].index + rcGetCon(as, dir2); if (chf.areas[ai2] != area) continue; - unsigned short nr = srcReg[ai2]; - if (nr != 0 && nr != r) - ar = nr; + unsigned short nr2 = srcReg[ai2]; + if (nr2 != 0 && nr2 != r) + ar = nr2; } } } @@ -678,17 +678,17 @@ static void walkContour(int x, int y, int i, int dir, // Remove adjacent duplicates. if (cont.size() > 1) { - for (int i = 0; i < cont.size(); ) + for (int j = 0; j < cont.size(); ) { - int ni = (i+1) % cont.size(); - if (cont[i] == cont[ni]) + int nj = (j+1) % cont.size(); + if (cont[j] == cont[nj]) { - for (int j = i; j < cont.size()-1; ++j) - cont[j] = cont[j+1]; + for (int k = j; k < cont.size()-1; ++k) + cont[k] = cont[k+1]; cont.pop(); } else - ++i; + ++j; } } } @@ -806,14 +806,14 @@ static bool filterSmallRegions(rcContext* ctx, int minRegionArea, int mergeRegio connectsToBorder = true; continue; } - rcRegion& nreg = regions[creg.connections[j]]; - if (nreg.visited) + rcRegion& neireg = regions[creg.connections[j]]; + if (neireg.visited) continue; - if (nreg.id == 0 || (nreg.id & RC_BORDER_REG)) + if (neireg.id == 0 || (neireg.id & RC_BORDER_REG)) continue; // Visit - stack.push(nreg.id); - nreg.visited = true; + stack.push(neireg.id); + neireg.visited = true; } } diff --git a/RecastDemo/Build/Xcode/Recast.xcodeproj/project.pbxproj b/RecastDemo/Build/Xcode/Recast.xcodeproj/project.pbxproj index 6d633268..7c81b7be 100644 --- a/RecastDemo/Build/Xcode/Recast.xcodeproj/project.pbxproj +++ b/RecastDemo/Build/Xcode/Recast.xcodeproj/project.pbxproj @@ -596,6 +596,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.6; OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", + "-Wshadow", "-Wreorder", "-Wsign-compare", "-Wall", @@ -623,6 +624,7 @@ OTHER_CFLAGS = ""; OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", + "-Wshadow", "-Wreorder", "-Wsign-compare", "-Wall", diff --git a/RecastDemo/Source/CrowdTool.cpp b/RecastDemo/Source/CrowdTool.cpp index a97e3fc2..36e35918 100644 --- a/RecastDemo/Source/CrowdTool.cpp +++ b/RecastDemo/Source/CrowdTool.cpp @@ -192,7 +192,7 @@ void CrowdToolState::reset() void CrowdToolState::handleRender() { DebugDrawGL dd; - const float s = m_sample->getAgentRadius(); + const float rad = m_sample->getAgentRadius(); dtNavMesh* nav = m_sample->getNavMesh(); dtCrowd* crowd = m_sample->getCrowd(); @@ -226,7 +226,7 @@ void CrowdToolState::handleRender() } if (m_targetRef) - duDebugDrawCross(&dd, m_targetPos[0],m_targetPos[1]+0.1f,m_targetPos[2], s, duRGBA(255,255,255,192), 2.0f); + duDebugDrawCross(&dd, m_targetPos[0],m_targetPos[1]+0.1f,m_targetPos[2], rad, duRGBA(255,255,255,192), 2.0f); // Occupancy grid. if (m_toolParams.m_showGrid) @@ -378,16 +378,16 @@ void CrowdToolState::handleRender() const dtCrowdAgent* nei = 0; for (int i = 0; i < crowd->getAgentCount(); ++i) { - const dtCrowdAgent* ag = crowd->getAgent(i); - if (!ag->active) continue; + const dtCrowdAgent* nag = crowd->getAgent(i); + if (!nag->active) continue; if (n == 0) { - nei = crowd->getAgent(ag->neis[j].idx); + nei = nag; break; } n--; } - if (nei ) + if (nei) { dd.vertex(pos[0],pos[1]+radius,pos[2], duRGBA(0,192,128,128)); dd.vertex(nei->npos[0],nei->npos[1]+radius,nei->npos[2], duRGBA(0,192,128,128)); @@ -583,7 +583,8 @@ void CrowdToolState::handleRenderOverlay(double* proj, double* model, int* view) void CrowdToolState::handleUpdate(const float dt) { - updateTick(dt); + if (m_run) + updateTick(dt); } void CrowdToolState::addAgent(const float* p) diff --git a/RecastDemo/Source/InputGeom.cpp b/RecastDemo/Source/InputGeom.cpp index eb274a31..2a8300fd 100644 --- a/RecastDemo/Source/InputGeom.cpp +++ b/RecastDemo/Source/InputGeom.cpp @@ -272,8 +272,8 @@ bool InputGeom::save(const char* filepath) { ConvexVolume* vol = &m_volumes[i]; fprintf(fp, "v %d %d %f %f\n", vol->nverts, vol->area, vol->hmin, vol->hmax); - for (int i = 0; i < vol->nverts; ++i) - fprintf(fp, "%f %f %f\n", vol->verts[i*3+0], vol->verts[i*3+1], vol->verts[i*3+2]); + for (int j = 0; j < vol->nverts; ++j) + fprintf(fp, "%f %f %f\n", vol->verts[j*3+0], vol->verts[j*3+1], vol->verts[j*3+2]); } fclose(fp); diff --git a/RecastDemo/Source/NavMeshTesterTool.cpp b/RecastDemo/Source/NavMeshTesterTool.cpp index 373a0beb..1a9a8c1d 100644 --- a/RecastDemo/Source/NavMeshTesterTool.cpp +++ b/RecastDemo/Source/NavMeshTesterTool.cpp @@ -458,9 +458,9 @@ void NavMeshTesterTool::handleToggle() } // Move position at the other side of the off-mesh link. dtVcopy(m_iterPos, endPos); - float h; - m_navQuery->getPolyHeight(m_pathIterPolys[0], m_iterPos, &h); - m_iterPos[1] = h; + float eh = 0.0f; + m_navQuery->getPolyHeight(m_pathIterPolys[0], m_iterPos, &eh); + m_iterPos[1] = eh; } } @@ -655,9 +655,9 @@ void NavMeshTesterTool::recalc() } // Move position at the other side of the off-mesh link. dtVcopy(iterPos, endPos); - float h; - m_navQuery->getPolyHeight(polys[0], iterPos, &h); - iterPos[1] = h; + float eh = 0.0f; + m_navQuery->getPolyHeight(polys[0], iterPos, &eh); + iterPos[1] = eh; } } @@ -914,10 +914,10 @@ void NavMeshTesterTool::handleRender() if (m_nsmoothPath) { dd.depthMask(false); - const unsigned int pathCol = duRGBA(0,0,0,220); + const unsigned int spathCol = duRGBA(0,0,0,220); dd.begin(DU_DRAW_LINES, 3.0f); for (int i = 0; i < m_nsmoothPath; ++i) - dd.vertex(m_smoothPath[i*3], m_smoothPath[i*3+1]+0.1f, m_smoothPath[i*3+2], pathCol); + dd.vertex(m_smoothPath[i*3], m_smoothPath[i*3+1]+0.1f, m_smoothPath[i*3+2], spathCol); dd.end(); dd.depthMask(true); } @@ -969,7 +969,7 @@ void NavMeshTesterTool::handleRender() if (m_nstraightPath) { dd.depthMask(false); - const unsigned int pathCol = duRGBA(64,16,0,220); + const unsigned int spathCol = duRGBA(64,16,0,220); const unsigned int offMeshCol = duRGBA(128,96,0,220); dd.begin(DU_DRAW_LINES, 2.0f); for (int i = 0; i < m_nstraightPath-1; ++i) @@ -996,7 +996,7 @@ void NavMeshTesterTool::handleRender() col = offMeshCol; else col = pathCol; - dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], pathCol); + dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], spathCol); } dd.end(); dd.depthMask(true); @@ -1012,17 +1012,17 @@ void NavMeshTesterTool::handleRender() duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol); dd.depthMask(false); - const unsigned int pathCol = m_hitResult ? duRGBA(64,16,0,220) : duRGBA(240,240,240,220); + const unsigned int spathCol = m_hitResult ? duRGBA(64,16,0,220) : duRGBA(240,240,240,220); dd.begin(DU_DRAW_LINES, 2.0f); for (int i = 0; i < m_nstraightPath-1; ++i) { - dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], pathCol); - dd.vertex(m_straightPath[(i+1)*3], m_straightPath[(i+1)*3+1]+0.4f, m_straightPath[(i+1)*3+2], pathCol); + dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], spathCol); + dd.vertex(m_straightPath[(i+1)*3], m_straightPath[(i+1)*3+1]+0.4f, m_straightPath[(i+1)*3+2], spathCol); } dd.end(); dd.begin(DU_DRAW_POINTS, 4.0f); for (int i = 0; i < m_nstraightPath; ++i) - dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], pathCol); + dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], spathCol); dd.end(); if (m_hitResult) diff --git a/RecastDemo/Source/Sample_TempObstacles.cpp b/RecastDemo/Source/Sample_TempObstacles.cpp index edfb8424..51b47bb9 100644 --- a/RecastDemo/Source/Sample_TempObstacles.cpp +++ b/RecastDemo/Source/Sample_TempObstacles.cpp @@ -222,7 +222,7 @@ struct MeshProcess : public dtTileCacheMeshProcess -static const int MAX_TILES = 32; +static const int MAX_LAYERS = 32; struct TileCacheData { @@ -239,7 +239,7 @@ struct RasterizationContext chf(0), ntiles(0) { - memset(tiles, 0, sizeof(TileCacheData)*MAX_TILES); + memset(tiles, 0, sizeof(TileCacheData)*MAX_LAYERS); } ~RasterizationContext() @@ -248,7 +248,7 @@ struct RasterizationContext delete [] triareas; rcFreeHeightfieldLayerSet(lset); rcFreeCompactHeightfield(chf); - for (int i = 0; i < MAX_TILES; ++i) + for (int i = 0; i < MAX_LAYERS; ++i) { dtFree(tiles[i].data); tiles[i].data = 0; @@ -259,7 +259,7 @@ struct RasterizationContext unsigned char* triareas; rcHeightfieldLayerSet* lset; rcCompactHeightfield* chf; - TileCacheData tiles[MAX_TILES]; + TileCacheData tiles[MAX_LAYERS]; int ntiles; }; @@ -396,7 +396,7 @@ static int rasterizeTileLayers(BuildContext* ctx, InputGeom* geom, } rc.ntiles = 0; - for (int i = 0; i < rcMin(rc.lset->nlayers, MAX_TILES); ++i) + for (int i = 0; i < rcMin(rc.lset->nlayers, MAX_LAYERS); ++i) { TileCacheData* tile = &rc.tiles[rc.ntiles++]; const rcHeightfieldLayer* layer = &rc.lset->layers[i]; @@ -505,9 +505,8 @@ void drawDetail(duDebugDraw* dd, dtTileCache* tc, const int tx, const int ty, in struct dtTileCacheAlloc* alloc; }; - const int MAX_TILES = 32; - dtCompressedTileRef tiles[MAX_TILES]; - const int ntiles = tc->getTilesAt(tx,ty,tiles,MAX_TILES); + dtCompressedTileRef tiles[MAX_LAYERS]; + const int ntiles = tc->getTilesAt(tx,ty,tiles,MAX_LAYERS); dtTileCacheAlloc* talloc = tc->getAlloc(); dtTileCacheCompressor* tcomp = tc->getCompressor(); @@ -575,9 +574,8 @@ void drawDetail(duDebugDraw* dd, dtTileCache* tc, const int tx, const int ty, in void drawDetailOverlay(const dtTileCache* tc, const int tx, const int ty, double* proj, double* model, int* view) { - const int MAX_TILES = 32; - dtCompressedTileRef tiles[MAX_TILES]; - const int ntiles = tc->getTilesAt(tx,ty,tiles,MAX_TILES); + dtCompressedTileRef tiles[MAX_LAYERS]; + const int ntiles = tc->getTilesAt(tx,ty,tiles,MAX_LAYERS); if (!ntiles) return; @@ -1281,15 +1279,14 @@ bool Sample_TempObstacles::handleBuild() { for (int x = 0; x < tw; ++x) { - static const int MAX_TILES = 32; - TileCacheData tiles[MAX_TILES]; + TileCacheData tiles[MAX_LAYERS]; memset(tiles, 0, sizeof(tiles)); - int ntiles = rasterizeTileLayers(m_ctx, m_geom, x, y, cfg, tiles, MAX_TILES); + int ntiles = rasterizeTileLayers(m_ctx, m_geom, x, y, cfg, tiles, MAX_LAYERS); for (int i = 0; i < ntiles; ++i) { TileCacheData* tile = &tiles[i]; - dtStatus status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, 0); + status = m_tileCache->addTile(tile->data, tile->dataSize, DT_COMPRESSEDTILE_FREE_DATA, 0); if (dtStatusFailed(status)) { dtFree(tile->data); diff --git a/RecastDemo/Source/Sample_TileMesh.cpp b/RecastDemo/Source/Sample_TileMesh.cpp index 618cdb7b..1d0f4575 100644 --- a/RecastDemo/Source/Sample_TileMesh.cpp +++ b/RecastDemo/Source/Sample_TileMesh.cpp @@ -979,16 +979,16 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const for (int i = 0; i < ncid; ++i) { const rcChunkyTriMeshNode& node = chunkyMesh->nodes[cid[i]]; - const int* tris = &chunkyMesh->tris[node.i*3]; - const int ntris = node.n; + const int* ctris = &chunkyMesh->tris[node.i*3]; + const int nctris = node.n; - m_tileTriCount += ntris; + m_tileTriCount += nctris; - memset(m_triareas, 0, ntris*sizeof(unsigned char)); + memset(m_triareas, 0, nctris*sizeof(unsigned char)); rcMarkWalkableTriangles(m_ctx, m_cfg.walkableSlopeAngle, - verts, nverts, tris, ntris, m_triareas); + verts, nverts, ctris, nctris, m_triareas); - rcRasterizeTriangles(m_ctx, verts, nverts, tris, m_triareas, ntris, *m_solid, m_cfg.walkableClimb); + rcRasterizeTriangles(m_ctx, verts, nverts, ctris, m_triareas, nctris, *m_solid, m_cfg.walkableClimb); } if (!m_keepInterResults) diff --git a/RecastDemo/Source/main.cpp b/RecastDemo/Source/main.cpp index ecf299bf..fc85942f 100644 --- a/RecastDemo/Source/main.cpp +++ b/RecastDemo/Source/main.cpp @@ -71,7 +71,8 @@ int main(int /*argc*/, char** /*argv*/) } // Center window - putenv("SDL_VIDEO_CENTERED=1"); + char env[] = "SDL_VIDEO_CENTERED=1"; + putenv(env); // Init OpenGL SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); @@ -374,8 +375,8 @@ int main(int /*argc*/, char** /*argv*/) // Hit test mesh. if (processHitTest && geom && sample) { - float t; - bool hit = geom->raycastMesh(rays, raye, t); + float hitt; + bool hit = geom->raycastMesh(rays, raye, hitt); if (hit) { @@ -383,16 +384,16 @@ int main(int /*argc*/, char** /*argv*/) { // Marker mposSet = true; - mpos[0] = rays[0] + (raye[0] - rays[0])*t; - mpos[1] = rays[1] + (raye[1] - rays[1])*t; - mpos[2] = rays[2] + (raye[2] - rays[2])*t; + mpos[0] = rays[0] + (raye[0] - rays[0])*hitt; + mpos[1] = rays[1] + (raye[1] - rays[1])*hitt; + mpos[2] = rays[2] + (raye[2] - rays[2])*hitt; } else { float pos[3]; - pos[0] = rays[0] + (raye[0] - rays[0])*t; - pos[1] = rays[1] + (raye[1] - rays[1])*t; - pos[2] = rays[2] + (raye[2] - rays[2])*t; + pos[0] = rays[0] + (raye[0] - rays[0])*hitt; + pos[1] = rays[1] + (raye[1] - rays[1])*hitt; + pos[2] = rays[2] + (raye[2] - rays[2])*hitt; sample->handleClick(rays, pos, processHitTestShift); } }