Fix for issue 144. Treat region borders as empty in floodRegions() to allow 1 width regions to grow next to tile border. Made area marking code not to override RC_NULL_AREA.
This commit is contained in:
parent
1be9de72d8
commit
2aa70cb497
@ -322,6 +322,7 @@ void rcMarkBoxArea(rcContext* ctx, const float* bmin, const float* bmax, unsigne
|
||||
rcCompactSpan& s = chf.spans[i];
|
||||
if ((int)s.y >= miny && (int)s.y <= maxy)
|
||||
{
|
||||
if (chf.areas[i] != RC_NULL_AREA)
|
||||
chf.areas[i] = areaId;
|
||||
}
|
||||
}
|
||||
@ -393,6 +394,8 @@ void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
|
||||
for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
|
||||
{
|
||||
rcCompactSpan& s = chf.spans[i];
|
||||
if (chf.areas[i] == RC_NULL_AREA)
|
||||
continue;
|
||||
if ((int)s.y >= miny && (int)s.y <= maxy)
|
||||
{
|
||||
float p[3];
|
||||
|
@ -283,6 +283,8 @@ static bool floodRegion(int x, int y, int i,
|
||||
if (chf.areas[ai] != area)
|
||||
continue;
|
||||
unsigned short nr = srcReg[ai];
|
||||
if (nr & RC_BORDER_REG) // Do not take borders into account.
|
||||
continue;
|
||||
if (nr != 0 && nr != r)
|
||||
ar = nr;
|
||||
|
||||
@ -319,9 +321,7 @@ static bool floodRegion(int x, int y, int i,
|
||||
const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(cs, dir);
|
||||
if (chf.areas[ai] != area)
|
||||
continue;
|
||||
if (chf.dist[ai] >= lev)
|
||||
{
|
||||
if (srcReg[ai] == 0)
|
||||
if (chf.dist[ai] >= lev && srcReg[ai] == 0)
|
||||
{
|
||||
srcReg[ai] = r;
|
||||
srcDist[ai] = 0;
|
||||
@ -332,7 +332,6 @@ static bool floodRegion(int x, int y, int i,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
@ -1242,7 +1241,6 @@ bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
{
|
||||
if (chf.dist[i] < level || srcReg[i] != 0 || chf.areas[i] == RC_NULL_AREA)
|
||||
continue;
|
||||
|
||||
if (floodRegion(x, y, i, level, regionId, chf, srcReg, srcDist, stack))
|
||||
regionId++;
|
||||
}
|
||||
@ -1250,7 +1248,6 @@ bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
||||
}
|
||||
|
||||
ctx->stopTimer(RC_TIMER_BUILD_REGIONS_FLOOD);
|
||||
|
||||
}
|
||||
|
||||
// Expand current regions until no empty connected cells found.
|
||||
|
Loading…
x
Reference in New Issue
Block a user