From 9035462e8660bf4ed64557331f88ba1a573a7eb2 Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Mon, 1 Feb 2010 14:57:26 +0000 Subject: [PATCH] rcBuildRegionsMonotone works again too. --- Recast/Include/Recast.h | 4 +--- Recast/Source/RecastRegion.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Recast/Include/Recast.h b/Recast/Include/Recast.h index 5b5422a..ca1a620 100644 --- a/Recast/Include/Recast.h +++ b/Recast/Include/Recast.h @@ -547,13 +547,11 @@ bool rcBuildRegions(rcCompactHeightfield& chf, // removed or merged to neighbour region. // Params: // chf - (in/out) compact heightfield representing the open space. -// walkableRadius - (in) the radius of the agent. // minRegionSize - (in) the smallest allowed regions size. // maxMergeRegionSize - (in) the largest allowed regions size which can be merged. // Returns false if operation ran out of memory. bool rcBuildRegionsMonotone(rcCompactHeightfield& chf, - int walkableRadius, int borderSize, - int minRegionSize, int mergeRegionSize); + int borderSize, int minRegionSize, int mergeRegionSize); // Builds simplified contours from the regions outlines. // Params: diff --git a/Recast/Source/RecastRegion.cpp b/Recast/Source/RecastRegion.cpp index f1956d0..636e386 100644 --- a/Recast/Source/RecastRegion.cpp +++ b/Recast/Source/RecastRegion.cpp @@ -991,7 +991,7 @@ struct rcSweepSpan bool rcBuildRegionsMonotone(rcCompactHeightfield& chf, int borderSize, int minRegionSize, int mergeRegionSize) { -/* rcTimeVal startTime = rcGetPerformanceTimer(); + rcTimeVal startTime = rcGetPerformanceTimer(); const int w = chf.width; const int h = chf.height; @@ -1047,7 +1047,7 @@ bool rcBuildRegionsMonotone(rcCompactHeightfield& chf, for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i) { const rcCompactSpan& s = chf.spans[i]; - if (chf.dist[i] < minLevel) continue; + if (chf.areas[i] == RC_NULL_AREA) continue; // -x unsigned short previd = 0; @@ -1056,7 +1056,7 @@ bool rcBuildRegionsMonotone(rcCompactHeightfield& chf, const int ax = x + rcGetDirOffsetX(0); const int ay = y + rcGetDirOffsetY(0); const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 0); - if ((srcReg[ai] & RC_BORDER_REG) == 0) + if ((srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai]) previd = srcReg[ai]; } @@ -1074,7 +1074,7 @@ bool rcBuildRegionsMonotone(rcCompactHeightfield& chf, const int ax = x + rcGetDirOffsetX(3); const int ay = y + rcGetDirOffsetY(3); const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, 3); - if (srcReg[ai] && (srcReg[ai] & RC_BORDER_REG) == 0) + if (srcReg[ai] && (srcReg[ai] & RC_BORDER_REG) == 0 && chf.areas[i] == chf.areas[ai]) { unsigned short nr = srcReg[ai]; if (!sweeps[previd].nei || sweeps[previd].nei == nr) @@ -1141,7 +1141,6 @@ bool rcBuildRegionsMonotone(rcCompactHeightfield& chf, rcGetBuildTimes()->buildRegions += rcGetDeltaTimeUsec(startTime, endTime); rcGetBuildTimes()->buildRegionsFilter += rcGetDeltaTimeUsec(filterStartTime, filterEndTime); } -*/ return true; }