duDebugDraw::polyToCol changed to areaToCol (#255)

This commit is contained in:
Domenico Albani 2017-02-01 17:44:39 +01:00 committed by Jakob Botsch Nielsen
parent ad6e5de2e9
commit 16a7a30ada
4 changed files with 23 additions and 22 deletions

View File

@ -67,10 +67,8 @@ struct duDebugDraw
/// End drawing primitives.
virtual void end() = 0;
/// Compute a color for given polygon.
/// @param poly [in] the polygon to compute color for.
/// @return The color value.
virtual unsigned int polyToCol(const struct dtPoly* poly);
/// Compute a color for given area.
virtual unsigned int areaToCol(unsigned int area);
};
inline unsigned int duRGBA(int r, int g, int b, int a)

View File

@ -28,16 +28,16 @@ duDebugDraw::~duDebugDraw()
// Empty
}
unsigned int duDebugDraw::polyToCol(const struct dtPoly* poly)
unsigned int duDebugDraw::areaToCol(unsigned int area)
{
if (poly->getArea() == 0)
if (area == 0)
{
// Treat zero area type as default.
return duRGBA(0, 192, 255, 255);
}
else
{
return duIntToCol(poly->getArea(), 255);
return duIntToCol(area, 255);
}
}

View File

@ -142,7 +142,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh
if (flags & DU_DRAWNAVMESH_COLOR_TILES)
col = tileColor;
else
col = duTransCol(dd->polyToCol(p), 64);
col = duTransCol(dd->areaToCol(p->getArea()), 64);
}
for (int j = 0; j < pd->triCount; ++j)
@ -178,7 +178,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh
if (query && query->isInClosedList(base | (dtPolyRef)i))
col = duRGBA(255,196,0,220);
else
col = duDarkenCol(duTransCol(dd->polyToCol(p), 220));
col = duDarkenCol(duTransCol(dd->areaToCol(p->getArea()), 220));
const dtOffMeshConnection* con = &tile->offMeshCons[i - tile->header->offMeshBase];
const float* va = &tile->verts[p->verts[0]*3];
@ -553,15 +553,15 @@ void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLay
const int lidx = x+y*w;
const int lh = (int)layer.heights[lidx];
if (lh == 0xff) continue;
const unsigned char area = layer.areas[lidx];
unsigned int col;
if (area == 63)
col = duLerpCol(color, duRGBA(0,192,255,64), 32);
else if (area == 0)
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
else
col = duLerpCol(color, duIntToCol(area, 255), 32);
col = duLerpCol(color, dd->areaToCol(area), 32);
const float fx = bmin[0] + x*cs;
const float fy = bmin[1] + (lh+1)*ch;
@ -737,14 +737,15 @@ void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyM
for (int i = 0; i < lmesh.npolys; ++i)
{
const unsigned short* p = &lmesh.polys[i*nvp*2];
const unsigned char area = lmesh.areas[i];
unsigned int color;
if (lmesh.areas[i] == DT_TILECACHE_WALKABLE_AREA)
if (area == DT_TILECACHE_WALKABLE_AREA)
color = duRGBA(0,192,255,64);
else if (lmesh.areas[i] == DT_TILECACHE_NULL_AREA)
else if (area == DT_TILECACHE_NULL_AREA)
color = duRGBA(0,0,0,64);
else
color = duIntToCol(lmesh.areas[i], 255);
color = dd->areaToCol(area);
unsigned short vi[3];
for (int j = 2; j < nvp; ++j)

View File

@ -198,7 +198,7 @@ void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf)
else if (s->area == RC_NULL_AREA)
fcol[0] = duRGBA(64,64,64,255);
else
fcol[0] = duMultCol(duIntToCol(s->area, 255), 200);
fcol[0] = duMultCol(dd->areaToCol(s->area), 200);
duAppendBox(dd, fx, orig[1]+s->smin*ch, fz, fx+cs, orig[1] + s->smax*ch, fz+cs, fcol);
s = s->next;
@ -230,13 +230,14 @@ void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfi
{
const rcCompactSpan& s = chf.spans[i];
const unsigned char area = chf.areas[i];
unsigned int color;
if (chf.areas[i] == RC_WALKABLE_AREA)
if (area == RC_WALKABLE_AREA)
color = duRGBA(0,192,255,64);
else if (chf.areas[i] == RC_NULL_AREA)
else if (area == RC_NULL_AREA)
color = duRGBA(0,0,0,64);
else
color = duIntToCol(chf.areas[i], 255);
color = dd->areaToCol(area);
const float fy = chf.bmin[1] + (s.y+1)*ch;
dd->vertex(fx, fy, fz, color);
@ -403,7 +404,7 @@ void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLaye
else if (area == RC_NULL_AREA)
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
else
col = duLerpCol(color, duIntToCol(area, 255), 32);
col = duLerpCol(color, dd->areaToCol(area), 32);
const float fx = layer.bmin[0] + x*cs;
const float fy = layer.bmin[1] + (lh+1)*ch;
@ -866,14 +867,15 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh)
for (int i = 0; i < mesh.npolys; ++i)
{
const unsigned short* p = &mesh.polys[i*nvp*2];
const unsigned char area = mesh.areas[i];
unsigned int color;
if (mesh.areas[i] == RC_WALKABLE_AREA)
if (area == RC_WALKABLE_AREA)
color = duRGBA(0,192,255,64);
else if (mesh.areas[i] == RC_NULL_AREA)
else if (area == RC_NULL_AREA)
color = duRGBA(0,0,0,64);
else
color = duIntToCol(mesh.areas[i], 255);
color = dd->areaToCol(area);
unsigned short vi[3];
for (int j = 2; j < nvp; ++j)