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];
|
rcCompactSpan& s = chf.spans[i];
|
||||||
if ((int)s.y >= miny && (int)s.y <= maxy)
|
if ((int)s.y >= miny && (int)s.y <= maxy)
|
||||||
{
|
{
|
||||||
|
if (chf.areas[i] != RC_NULL_AREA)
|
||||||
chf.areas[i] = areaId;
|
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)
|
for (int i = (int)c.index, ni = (int)(c.index+c.count); i < ni; ++i)
|
||||||
{
|
{
|
||||||
rcCompactSpan& s = chf.spans[i];
|
rcCompactSpan& s = chf.spans[i];
|
||||||
|
if (chf.areas[i] == RC_NULL_AREA)
|
||||||
|
continue;
|
||||||
if ((int)s.y >= miny && (int)s.y <= maxy)
|
if ((int)s.y >= miny && (int)s.y <= maxy)
|
||||||
{
|
{
|
||||||
float p[3];
|
float p[3];
|
||||||
|
@ -283,6 +283,8 @@ static bool floodRegion(int x, int y, int i,
|
|||||||
if (chf.areas[ai] != area)
|
if (chf.areas[ai] != area)
|
||||||
continue;
|
continue;
|
||||||
unsigned short nr = srcReg[ai];
|
unsigned short nr = srcReg[ai];
|
||||||
|
if (nr & RC_BORDER_REG) // Do not take borders into account.
|
||||||
|
continue;
|
||||||
if (nr != 0 && nr != r)
|
if (nr != 0 && nr != r)
|
||||||
ar = nr;
|
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);
|
const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(cs, dir);
|
||||||
if (chf.areas[ai] != area)
|
if (chf.areas[ai] != area)
|
||||||
continue;
|
continue;
|
||||||
if (chf.dist[ai] >= lev)
|
if (chf.dist[ai] >= lev && srcReg[ai] == 0)
|
||||||
{
|
|
||||||
if (srcReg[ai] == 0)
|
|
||||||
{
|
{
|
||||||
srcReg[ai] = r;
|
srcReg[ai] = r;
|
||||||
srcDist[ai] = 0;
|
srcDist[ai] = 0;
|
||||||
@ -332,7 +332,6 @@ static bool floodRegion(int x, int y, int i,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return count > 0;
|
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)
|
if (chf.dist[i] < level || srcReg[i] != 0 || chf.areas[i] == RC_NULL_AREA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (floodRegion(x, y, i, level, regionId, chf, srcReg, srcDist, stack))
|
if (floodRegion(x, y, i, level, regionId, chf, srcReg, srcDist, stack))
|
||||||
regionId++;
|
regionId++;
|
||||||
}
|
}
|
||||||
@ -1250,7 +1248,6 @@ bool rcBuildRegions(rcContext* ctx, rcCompactHeightfield& chf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->stopTimer(RC_TIMER_BUILD_REGIONS_FLOOD);
|
ctx->stopTimer(RC_TIMER_BUILD_REGIONS_FLOOD);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expand current regions until no empty connected cells found.
|
// Expand current regions until no empty connected cells found.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user