mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-07-05 05:29:07 +00:00
Heighfield Layer progress.
This commit is contained in:
@@ -300,7 +300,7 @@ void duDebugDrawLeanHeightfieldSolid(duDebugDraw* dd, const rcLeanHeightfield& l
|
||||
|
||||
for (int i = idx, ni = idx+count; i < ni; ++i)
|
||||
{
|
||||
const int y = floors[i] & mask;
|
||||
const int h = floors[i] & mask;
|
||||
unsigned char area = areas[i];
|
||||
|
||||
unsigned int color;
|
||||
@@ -311,7 +311,7 @@ void duDebugDrawLeanHeightfieldSolid(duDebugDraw* dd, const rcLeanHeightfield& l
|
||||
else
|
||||
color = duIntToCol(area, 255);
|
||||
|
||||
const float fy = lhf.bmin[1] + (y+1)*ch;
|
||||
const float fy = lhf.bmin[1] + (h+1)*ch;
|
||||
dd->vertex(fx, fy, fz, color);
|
||||
dd->vertex(fx, fy, fz+cs, color);
|
||||
dd->vertex(fx+cs, fy, fz+cs, color);
|
||||
@@ -323,6 +323,98 @@ void duDebugDrawLeanHeightfieldSolid(duDebugDraw* dd, const rcLeanHeightfield& l
|
||||
dd->end();
|
||||
}
|
||||
|
||||
void duDebugDrawHeightfieldLayers(duDebugDraw* dd, const struct rcHeightfieldLayerSet& lset)
|
||||
{
|
||||
if (!dd) return;
|
||||
|
||||
const float cs = lset.cs;
|
||||
const float ch = lset.ch;
|
||||
const int w = lset.width;
|
||||
const int h = lset.height;
|
||||
|
||||
for (int i = 0; i < lset.nlayers; ++i)
|
||||
{
|
||||
const rcHeightfieldLayer* layer = &lset.layers[i];
|
||||
|
||||
unsigned int color = duIntToCol(i+1, 255);
|
||||
|
||||
// Layer bounds
|
||||
float bmin[3], bmax[3];
|
||||
rcVcopy(bmin, lset.bmin);
|
||||
rcVcopy(bmax, lset.bmax);
|
||||
bmin[1] = lset.bmin[1] + (layer->ymin-1)*ch;
|
||||
bmax[1] = lset.bmin[1] + (layer->ymax+1)*ch;
|
||||
duDebugDrawBoxWire(dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duTransCol(color,128), 2.0f);
|
||||
|
||||
// Layer height
|
||||
dd->begin(DU_DRAW_QUADS);
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
for (int x = 0; x < w; ++x)
|
||||
{
|
||||
const int idx = x+y*w;
|
||||
const int h = (int)layer->heights[idx];
|
||||
if (h == 0xffff) continue;
|
||||
const unsigned char area = layer->areas[idx];
|
||||
|
||||
unsigned int col;
|
||||
if (area == RC_WALKABLE_AREA)
|
||||
col = duLerpCol(color, duRGBA(0,192,255,64), 32);
|
||||
else if (area == RC_NULL_AREA)
|
||||
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
|
||||
else
|
||||
col = duLerpCol(color, duIntToCol(area, 255), 32);
|
||||
|
||||
const float fx = lset.bmin[0] + x*cs;
|
||||
const float fy = lset.bmin[1] + (h+1)*ch;
|
||||
const float fz = lset.bmin[2] + y*cs;
|
||||
|
||||
dd->vertex(fx, fy, fz, col);
|
||||
dd->vertex(fx, fy, fz+cs, col);
|
||||
dd->vertex(fx+cs, fy, fz+cs, col);
|
||||
dd->vertex(fx+cs, fy, fz, col);
|
||||
}
|
||||
}
|
||||
dd->end();
|
||||
|
||||
// Portals
|
||||
unsigned int pcol = duLerpCol(color,duRGBA(255,255,255,255),128);
|
||||
dd->begin(DU_DRAW_LINES, 2.0f);
|
||||
for (int j = 0; j < layer->nportals; ++j)
|
||||
{
|
||||
const rcHeightfieldLayerPortal* portal = &layer->portals[j];
|
||||
if (portal->dir == 0 || portal->dir == 2)
|
||||
{
|
||||
const int ha = (int)layer->heights[portal->pos + portal->smin*w];
|
||||
const int hb = (int)layer->heights[portal->pos + (portal->smax-1)*w];
|
||||
const int xx = (portal->dir == 0) ? portal->pos : portal->pos+1;
|
||||
const float fx = lset.bmin[0] + xx*cs;
|
||||
const float fya = lset.bmin[1] + (ha+4)*ch;
|
||||
const float fyb = lset.bmin[1] + (hb+4)*ch;
|
||||
const float fza = lset.bmin[2] + portal->smin*cs;
|
||||
const float fzb = lset.bmin[2] + portal->smax*cs;
|
||||
dd->vertex(fx, fya, fza, pcol);
|
||||
dd->vertex(fx, fyb, fzb, pcol);
|
||||
}
|
||||
else if (portal->dir == 3 || portal->dir == 1)
|
||||
{
|
||||
const int ha = (int)layer->heights[portal->smin + portal->pos*w];
|
||||
const int hb = (int)layer->heights[(portal->smax-1) + portal->pos*w];
|
||||
const int yy = (portal->dir == 3) ? portal->pos : portal->pos+1;
|
||||
const float fxa = lset.bmin[0] + portal->smin*cs;
|
||||
const float fxb = lset.bmin[0] + portal->smax*cs;
|
||||
const float fya = lset.bmin[1] + (ha+3)*ch;
|
||||
const float fyb = lset.bmin[1] + (hb+3)*ch;
|
||||
const float fz = lset.bmin[2] + yy*cs;
|
||||
dd->vertex(fxa, fya, fz, pcol);
|
||||
dd->vertex(fxb, fyb, fz, pcol);
|
||||
}
|
||||
}
|
||||
dd->end();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void getContourCenter(const rcContour* cont, const float* orig, float cs, float ch, float* center)
|
||||
{
|
||||
center[0] = 0;
|
||||
|
||||
Reference in New Issue
Block a user