duDebugDraw::polyToCol changed to areaToCol (#255)
This commit is contained in:
parent
ad6e5de2e9
commit
16a7a30ada
@ -67,10 +67,8 @@ struct duDebugDraw
|
|||||||
/// End drawing primitives.
|
/// End drawing primitives.
|
||||||
virtual void end() = 0;
|
virtual void end() = 0;
|
||||||
|
|
||||||
/// Compute a color for given polygon.
|
/// Compute a color for given area.
|
||||||
/// @param poly [in] the polygon to compute color for.
|
virtual unsigned int areaToCol(unsigned int area);
|
||||||
/// @return The color value.
|
|
||||||
virtual unsigned int polyToCol(const struct dtPoly* poly);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline unsigned int duRGBA(int r, int g, int b, int a)
|
inline unsigned int duRGBA(int r, int g, int b, int a)
|
||||||
|
@ -28,16 +28,16 @@ duDebugDraw::~duDebugDraw()
|
|||||||
// Empty
|
// 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.
|
// Treat zero area type as default.
|
||||||
return duRGBA(0, 192, 255, 255);
|
return duRGBA(0, 192, 255, 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return duIntToCol(poly->getArea(), 255);
|
return duIntToCol(area, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh
|
|||||||
if (flags & DU_DRAWNAVMESH_COLOR_TILES)
|
if (flags & DU_DRAWNAVMESH_COLOR_TILES)
|
||||||
col = tileColor;
|
col = tileColor;
|
||||||
else
|
else
|
||||||
col = duTransCol(dd->polyToCol(p), 64);
|
col = duTransCol(dd->areaToCol(p->getArea()), 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < pd->triCount; ++j)
|
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))
|
if (query && query->isInClosedList(base | (dtPolyRef)i))
|
||||||
col = duRGBA(255,196,0,220);
|
col = duRGBA(255,196,0,220);
|
||||||
else
|
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 dtOffMeshConnection* con = &tile->offMeshCons[i - tile->header->offMeshBase];
|
||||||
const float* va = &tile->verts[p->verts[0]*3];
|
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 lidx = x+y*w;
|
||||||
const int lh = (int)layer.heights[lidx];
|
const int lh = (int)layer.heights[lidx];
|
||||||
if (lh == 0xff) continue;
|
if (lh == 0xff) continue;
|
||||||
|
|
||||||
const unsigned char area = layer.areas[lidx];
|
const unsigned char area = layer.areas[lidx];
|
||||||
|
|
||||||
unsigned int col;
|
unsigned int col;
|
||||||
if (area == 63)
|
if (area == 63)
|
||||||
col = duLerpCol(color, duRGBA(0,192,255,64), 32);
|
col = duLerpCol(color, duRGBA(0,192,255,64), 32);
|
||||||
else if (area == 0)
|
else if (area == 0)
|
||||||
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
|
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
|
||||||
else
|
else
|
||||||
col = duLerpCol(color, duIntToCol(area, 255), 32);
|
col = duLerpCol(color, dd->areaToCol(area), 32);
|
||||||
|
|
||||||
const float fx = bmin[0] + x*cs;
|
const float fx = bmin[0] + x*cs;
|
||||||
const float fy = bmin[1] + (lh+1)*ch;
|
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)
|
for (int i = 0; i < lmesh.npolys; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* p = &lmesh.polys[i*nvp*2];
|
const unsigned short* p = &lmesh.polys[i*nvp*2];
|
||||||
|
const unsigned char area = lmesh.areas[i];
|
||||||
|
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
if (lmesh.areas[i] == DT_TILECACHE_WALKABLE_AREA)
|
if (area == DT_TILECACHE_WALKABLE_AREA)
|
||||||
color = duRGBA(0,192,255,64);
|
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);
|
color = duRGBA(0,0,0,64);
|
||||||
else
|
else
|
||||||
color = duIntToCol(lmesh.areas[i], 255);
|
color = dd->areaToCol(area);
|
||||||
|
|
||||||
unsigned short vi[3];
|
unsigned short vi[3];
|
||||||
for (int j = 2; j < nvp; ++j)
|
for (int j = 2; j < nvp; ++j)
|
||||||
|
@ -198,7 +198,7 @@ void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf)
|
|||||||
else if (s->area == RC_NULL_AREA)
|
else if (s->area == RC_NULL_AREA)
|
||||||
fcol[0] = duRGBA(64,64,64,255);
|
fcol[0] = duRGBA(64,64,64,255);
|
||||||
else
|
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);
|
duAppendBox(dd, fx, orig[1]+s->smin*ch, fz, fx+cs, orig[1] + s->smax*ch, fz+cs, fcol);
|
||||||
s = s->next;
|
s = s->next;
|
||||||
@ -230,13 +230,14 @@ void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfi
|
|||||||
{
|
{
|
||||||
const rcCompactSpan& s = chf.spans[i];
|
const rcCompactSpan& s = chf.spans[i];
|
||||||
|
|
||||||
|
const unsigned char area = chf.areas[i];
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
if (chf.areas[i] == RC_WALKABLE_AREA)
|
if (area == RC_WALKABLE_AREA)
|
||||||
color = duRGBA(0,192,255,64);
|
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);
|
color = duRGBA(0,0,0,64);
|
||||||
else
|
else
|
||||||
color = duIntToCol(chf.areas[i], 255);
|
color = dd->areaToCol(area);
|
||||||
|
|
||||||
const float fy = chf.bmin[1] + (s.y+1)*ch;
|
const float fy = chf.bmin[1] + (s.y+1)*ch;
|
||||||
dd->vertex(fx, fy, fz, color);
|
dd->vertex(fx, fy, fz, color);
|
||||||
@ -403,7 +404,7 @@ void duDebugDrawHeightfieldLayer(duDebugDraw* dd, const struct rcHeightfieldLaye
|
|||||||
else if (area == RC_NULL_AREA)
|
else if (area == RC_NULL_AREA)
|
||||||
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
|
col = duLerpCol(color, duRGBA(0,0,0,64), 32);
|
||||||
else
|
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 fx = layer.bmin[0] + x*cs;
|
||||||
const float fy = layer.bmin[1] + (lh+1)*ch;
|
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)
|
for (int i = 0; i < mesh.npolys; ++i)
|
||||||
{
|
{
|
||||||
const unsigned short* p = &mesh.polys[i*nvp*2];
|
const unsigned short* p = &mesh.polys[i*nvp*2];
|
||||||
|
const unsigned char area = mesh.areas[i];
|
||||||
|
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
if (mesh.areas[i] == RC_WALKABLE_AREA)
|
if (area == RC_WALKABLE_AREA)
|
||||||
color = duRGBA(0,192,255,64);
|
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);
|
color = duRGBA(0,0,0,64);
|
||||||
else
|
else
|
||||||
color = duIntToCol(mesh.areas[i], 255);
|
color = dd->areaToCol(area);
|
||||||
|
|
||||||
unsigned short vi[3];
|
unsigned short vi[3];
|
||||||
for (int j = 2; j < nvp; ++j)
|
for (int j = 2; j < nvp; ++j)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user