From e3d5c9904ee500148709b8caebe72a746d0caace Mon Sep 17 00:00:00 2001 From: Kromster80 Date: Thu, 30 Oct 2014 16:59:51 +0300 Subject: [PATCH 1/3] Renamed local variable to avoid scope collisions I'm not sure if C++ vars are scoped into {} blocks, but in ported code that is an issue. It's easier to have vars names unique. Does not harm anyone I guess? ;-) --- Recast/Source/RecastLayers.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Recast/Source/RecastLayers.cpp b/Recast/Source/RecastLayers.cpp index cb1a39f..5e3a3f2 100644 --- a/Recast/Source/RecastLayers.cpp +++ b/Recast/Source/RecastLayers.cpp @@ -239,15 +239,15 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i) { const rcCompactSpan& s = chf.spans[i]; - const unsigned char ri = srcReg[i]; - if (ri == 0xff) continue; + const unsigned char regi = srcReg[i]; + if (regi == 0xff) continue; - regs[ri].ymin = rcMin(regs[ri].ymin, s.y); - regs[ri].ymax = rcMax(regs[ri].ymax, s.y); + regs[regi].ymin = rcMin(regs[regi].ymin, s.y); + regs[regi].ymax = rcMax(regs[regi].ymax, s.y); // Collect all region layers. if (nlregs < RC_MAX_LAYERS) - lregs[nlregs++] = ri; + lregs[nlregs++] = regi; // Update neighbours for (int dir = 0; dir < 4; ++dir) @@ -258,8 +258,8 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, const int ay = y + rcGetDirOffsetY(dir); const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir); const unsigned char rai = srcReg[ai]; - if (rai != 0xff && rai != ri) - addUnique(regs[ri].neis, regs[ri].nneis, rai); + if (rai != 0xff && rai != regi) + addUnique(regs[regi].neis, regs[regi].nneis, rai); } } From a7a67af47b83043e1d2d72781e2956f18a0007e7 Mon Sep 17 00:00:00 2001 From: Kromster80 Date: Thu, 30 Oct 2014 17:05:39 +0300 Subject: [PATCH 2/3] Typo fixes --- Recast/Source/RecastLayers.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Recast/Source/RecastLayers.cpp b/Recast/Source/RecastLayers.cpp index 5e3a3f2..0fec7cd 100644 --- a/Recast/Source/RecastLayers.cpp +++ b/Recast/Source/RecastLayers.cpp @@ -38,7 +38,7 @@ struct rcLayerRegion unsigned char layerId; // Layer ID unsigned char nlayers; // Layer count unsigned char nneis; // Neighbour count - unsigned char base; // Flag indicating if the region is the base of merged regions. + unsigned char base; // Flag indicating if the region is the base of merged regions. }; @@ -293,7 +293,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, for (int i = 0; i < nregs; ++i) { rcLayerRegion& root = regs[i]; - // Skip alreadu visited. + // Skip already visited. if (root.layerId != 0xff) continue; @@ -368,7 +368,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, rcLayerRegion& rj = regs[j]; if (!rj.base) continue; - // Skip if teh regions are not close to each other. + // Skip if the regions are not close to each other. if (!overlapRange(ri.ymin,ri.ymax+mergeHeight, rj.ymin,rj.ymax+mergeHeight)) continue; // Skip if the height range would become too large. @@ -377,7 +377,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, if ((ymax - ymin) >= 255) continue; - // Make sure that there is no overlap when mergin 'ri' and 'rj'. + // Make sure that there is no overlap when merging 'ri' and 'rj'. bool overlap = false; // Iterate over all regions which have the same layerId as 'rj' for (int k = 0; k < nregs; ++k) @@ -417,7 +417,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, // Add overlaid layers from 'rj' to 'ri'. for (int k = 0; k < rj.nlayers; ++k) addUnique(ri.layers, ri.nlayers, rj.layers[k]); - // Update heigh bounds. + // Update height bounds. ri.ymin = rcMin(ri.ymin, rj.ymin); ri.ymax = rcMax(ri.ymax, rj.ymax); } @@ -528,7 +528,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, layer->cs = chf.cs; layer->ch = chf.ch; - // Adjust the bbox to fit the heighfield. + // Adjust the bbox to fit the heightfield. rcVcopy(layer->bmin, bmin); rcVcopy(layer->bmax, bmax); layer->bmin[1] = bmin[1] + hmin*chf.ch; @@ -542,7 +542,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, layer->miny = layer->height; layer->maxy = 0; - // Copy height and area from compact heighfield. + // Copy height and area from compact heightfield. for (int y = 0; y < lh; ++y) { for (int x = 0; x < lw; ++x) From 6c3b5750525e2432e17abdceb1dd374d82995df3 Mon Sep 17 00:00:00 2001 From: Kromster80 Date: Thu, 30 Oct 2014 21:19:19 +0400 Subject: [PATCH 3/3] Rolled back to pull --- Recast/Source/RecastLayers.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Recast/Source/RecastLayers.cpp b/Recast/Source/RecastLayers.cpp index 0fec7cd..bb0aeba 100644 --- a/Recast/Source/RecastLayers.cpp +++ b/Recast/Source/RecastLayers.cpp @@ -239,15 +239,15 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i) { const rcCompactSpan& s = chf.spans[i]; - const unsigned char regi = srcReg[i]; - if (regi == 0xff) continue; + const unsigned char ri = srcReg[i]; + if (ri == 0xff) continue; - regs[regi].ymin = rcMin(regs[regi].ymin, s.y); - regs[regi].ymax = rcMax(regs[regi].ymax, s.y); + regs[ri].ymin = rcMin(regs[ri].ymin, s.y); + regs[ri].ymax = rcMax(regs[ri].ymax, s.y); // Collect all region layers. if (nlregs < RC_MAX_LAYERS) - lregs[nlregs++] = regi; + lregs[nlregs++] = ri; // Update neighbours for (int dir = 0; dir < 4; ++dir) @@ -258,8 +258,8 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf, const int ay = y + rcGetDirOffsetY(dir); const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir); const unsigned char rai = srcReg[ai]; - if (rai != 0xff && rai != regi) - addUnique(regs[regi].neis, regs[regi].nneis, rai); + if (rai != 0xff && rai != ri) + addUnique(regs[ri].neis, regs[ri].nneis, rai); } }