Added more bits to compact neighbour indices, moved region id to rcCompactSpan to save memory.

This commit is contained in:
Mikko Mononen
2010-03-05 09:10:13 +00:00
parent ababd28f59
commit d9d9fa85a5
13 changed files with 2440 additions and 1934 deletions

View File

@@ -202,6 +202,8 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
}
// Find neighbour connections.
const float MAX_LAYERS = RC_NOT_CONNECTED-1;
int tooHighNeighbour = 0;
for (int y = 0; y < h; ++y)
{
for (int x = 0; x < w; ++x)
@@ -234,7 +236,13 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
if ((top - bot) >= walkableHeight && rcAbs((int)ns.y - (int)s.y) <= walkableClimb)
{
// Mark direction as walkable.
rcSetCon(s, dir, k - (int)nc.index);
const int idx = k - (int)nc.index;
if (idx < 0 || idx > MAX_LAYERS)
{
tooHighNeighbour = rcMax(tooHighNeighbour, idx);
continue;
}
rcSetCon(s, dir, idx);
break;
}
}
@@ -244,6 +252,12 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
}
}
if (tooHighNeighbour > MAX_LAYERS)
{
if (rcGetLog())
rcGetLog()->log(RC_LOG_ERROR, "rcBuildCompactHeightfield: Heighfield has too many layers %d (max: %d)", tooHighNeighbour, MAX_LAYERS);
}
rcTimeVal endTime = rcGetPerformanceTimer();
if (rcGetBuildTimes())