diff --git a/src/naveditor/Editor.cpp b/src/naveditor/Editor.cpp index 8d7afd97..80bef3b2 100644 --- a/src/naveditor/Editor.cpp +++ b/src/naveditor/Editor.cpp @@ -33,7 +33,7 @@ #include "game/server/ai_hull.h" #include "coordsize.h" -unsigned int EditorDebugDraw::areaToCol(unsigned int area) +unsigned int EditorDebugDraw::areaToFaceCol(const unsigned int area) const { switch(area) { @@ -48,6 +48,21 @@ unsigned int EditorDebugDraw::areaToCol(unsigned int area) } } +unsigned int EditorDebugDraw::areaToEdgeCol(const unsigned int area) const +{ + switch (area) + { + // Ground : light blue + case DT_POLYAREA_GROUND: return duRGBA(0, 24, 32, 255); + // Jump : blue + case DT_POLYAREA_JUMP: return duRGBA(0, 0, 48, 255); + // Trigger : light green + case DT_POLYAREA_TRIGGER: return duRGBA(0, 32, 24, 255); + // Unexpected : white + default: return duRGBA(28, 28, 28, 255); + } +} + static int s_traverseAnimTraverseFlags[TraverseAnimType_e::ANIMTYPE_COUNT]; static void initTraverseMasks() diff --git a/src/naveditor/InputGeom.cpp b/src/naveditor/InputGeom.cpp index ca728306..013b4366 100644 --- a/src/naveditor/InputGeom.cpp +++ b/src/naveditor/InputGeom.cpp @@ -780,7 +780,7 @@ void InputGeom::drawBoxVolumes(struct duDebugDraw* dd, const float* offset, cons const unsigned int faceCol = vol->area == RC_NULL_AREA ? duRGBA(255, 0, 0, faceAlpha) // Use red for visibility (null acts as deletion). - : duTransCol(dd->areaToCol(vol->area), faceAlpha); + : duTransCol(dd->areaToFaceCol(vol->area), faceAlpha); unsigned int fcol[6] = { faceCol, faceCol, faceCol, faceCol, faceCol, faceCol }; @@ -791,7 +791,7 @@ void InputGeom::drawBoxVolumes(struct duDebugDraw* dd, const float* offset, cons const unsigned int wireCol = vol->area == RC_NULL_AREA ? duRGBA(255, 0, 0, WIRE_ALPHA) - : duTransCol(dd->areaToCol(vol->area), WIRE_ALPHA); + : duTransCol(dd->areaToFaceCol(vol->area), WIRE_ALPHA); duDebugDrawBoxWire(dd, vol->verts[0],vol->verts[1],vol->verts[2], @@ -813,7 +813,7 @@ void InputGeom::drawCylinderVolumes(struct duDebugDraw* dd, const float* offset, const unsigned int faceCol = vol->area == RC_NULL_AREA ? duRGBA(255, 0, 0, faceAlpha) // Use red for visibility (null acts as deletion). - : duTransCol(dd->areaToCol(vol->area), faceAlpha); + : duTransCol(dd->areaToFaceCol(vol->area), faceAlpha); const float radius = vol->verts[3]; const float height = vol->verts[4]; @@ -824,7 +824,7 @@ void InputGeom::drawCylinderVolumes(struct duDebugDraw* dd, const float* offset, const unsigned int wireCol = vol->area == RC_NULL_AREA ? duRGBA(255, 0, 0, WIRE_ALPHA) - : duTransCol(dd->areaToCol(vol->area), WIRE_ALPHA); + : duTransCol(dd->areaToFaceCol(vol->area), WIRE_ALPHA); duDebugDrawCylinderWire(dd, vol->verts[0]-radius,vol->verts[1]-radius,vol->verts[2]+0.1f, @@ -849,7 +849,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, c if (vol->area == RC_NULL_AREA) col = duRGBA(255, 0, 0, faceAlpha); // Use red for visibility (null acts as deletion). else - col = duTransCol(dd->areaToCol(vol->area), faceAlpha); + col = duTransCol(dd->areaToFaceCol(vol->area), faceAlpha); for (int j = 0, k = vol->nverts-1; j < vol->nverts; k = j++) { @@ -885,7 +885,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, c if (vol->area == RC_NULL_AREA) col = duRGBA(255, 0, 0, WIRE_ALPHA); else - col = duTransCol(dd->areaToCol(vol->area), WIRE_ALPHA); + col = duTransCol(dd->areaToFaceCol(vol->area), WIRE_ALPHA); for (int j = 0, k = vol->nverts-1; j < vol->nverts; k = j++) { @@ -914,7 +914,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, const float* offset, c if (vol->area == RC_NULL_AREA) col = duDarkenCol(duRGBA(255, 0, 0, WIRE_ALPHA)); else - col = duDarkenCol(duTransCol(dd->areaToCol(vol->area), WIRE_ALPHA)); + col = duDarkenCol(duTransCol(dd->areaToFaceCol(vol->area), WIRE_ALPHA)); for (int j = 0; j < vol->nverts; ++j) { diff --git a/src/naveditor/include/Editor.h b/src/naveditor/include/Editor.h index 8d76b59b..e292fd69 100644 --- a/src/naveditor/include/Editor.h +++ b/src/naveditor/include/Editor.h @@ -193,7 +193,8 @@ struct TraverseLinkPolyPair class EditorDebugDraw : public DebugDrawGL { public: - virtual unsigned int areaToCol(unsigned int area); + virtual unsigned int areaToFaceCol(const unsigned int area) const; + virtual unsigned int areaToEdgeCol(const unsigned int area) const; }; enum EditorPartitionType diff --git a/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h b/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h index 183c0a57..df8cb7b0 100644 --- a/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h +++ b/src/thirdparty/recast/DebugUtils/Include/DebugDraw.h @@ -68,7 +68,8 @@ struct duDebugDraw virtual void end() = 0; /// Compute a color for given area. - virtual unsigned int areaToCol(unsigned int area); + virtual unsigned int areaToFaceCol(const unsigned int area) const; + virtual unsigned int areaToEdgeCol(const unsigned int area) const; }; inline unsigned int duRGBA(int r, int g, int b, int a) diff --git a/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp index e05bf713..644888de 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DebugDraw.cpp @@ -36,7 +36,7 @@ duDebugDraw::~duDebugDraw() // Empty } -unsigned int duDebugDraw::areaToCol(unsigned int area) +unsigned int duDebugDraw::areaToFaceCol(const unsigned int area) const { if (area == 0) { @@ -49,6 +49,19 @@ unsigned int duDebugDraw::areaToCol(unsigned int area) } } +unsigned int duDebugDraw::areaToEdgeCol(const unsigned int area) const +{ + if (area == 0) + { + // Treat zero area type as default. + return duRGBA(0, 48, 64, 255); + } + else + { + return duDarkenCol(duIntToCol(area, 255)); + } +} + inline int bit(int a, int b) { return (a & (1 << b)) >> b; diff --git a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp index de830eaf..ed6e0d16 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp @@ -36,11 +36,18 @@ static void drawPolyVerts(duDebugDraw* dd, const dtMeshTile* tile, const float* dd->end(); } -static unsigned int getPolySurfaceColor(const dtPoly* poly, duDebugDraw* dd, const unsigned int alpha) +static unsigned int getPolySurfaceColor(const duDebugDraw* dd, const dtPoly* poly, const unsigned int alpha) { return poly->groupId == DT_UNLINKED_POLY_GROUP - ? duTransCol(duRGBA(240,20,10,255), alpha) - : duTransCol(dd->areaToCol(poly->getArea()), alpha); + ? duRGBA(240,20,10, alpha) + : duTransCol(dd->areaToFaceCol(poly->getArea()), alpha); +} + +static unsigned int getPolyBoundaryColor(const duDebugDraw* dd, const dtPoly* poly, const bool inner) +{ + return poly->groupId == DT_UNLINKED_POLY_GROUP + ? duRGBA(32,24,0, inner ? 32 : 220) + : duTransCol(dd->areaToEdgeCol(poly->getArea()), inner ? 32 : 220); } static void drawPolyMeshFaces(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery* query, const dtMeshTile* tile, const float* offset, unsigned int flags) @@ -70,7 +77,7 @@ static void drawPolyMeshFaces(duDebugDraw* dd, const dtNavMesh& mesh, const dtNa else if (flags & DU_DRAWNAVMESH_POLY_GROUPS) col = duIntToCol(p->groupId, tileAlpha); else - col = getPolySurfaceColor(p, dd, tileAlpha); + col = getPolySurfaceColor(dd, p, tileAlpha); } for (int j = 0; j < pd->triCount; ++j) @@ -125,13 +132,6 @@ static void drawPolyMeshEdges(duDebugDraw* dd, const dtMeshTile* tile, const flo } } -static unsigned int getPolyBoundaryColor(const bool inner, const bool linked) -{ - return linked - ? inner ? duRGBA(0,24,32,32) : duRGBA(0,24,32,220) - : inner ? duRGBA(32,24,0,32) : duRGBA(32,24,0,220); -} - static void drawPolyBoundaries(duDebugDraw* dd, const dtMeshTile* tile, const float linew, const float* offset, const int flags, bool inner) { @@ -152,7 +152,7 @@ static void drawPolyBoundaries(duDebugDraw* dd, const dtMeshTile* tile, for (int j = 0, nj = (int)p->vertCount; j < nj; ++j) { - unsigned int c = getPolyBoundaryColor(inner, isLinked); + unsigned int c = getPolyBoundaryColor(dd, p, inner); if (inner) { if (p->neis[j] == 0) continue; @@ -439,7 +439,7 @@ static void drawOffMeshLinks(duDebugDraw* dd, const dtNavMesh& mesh, const dtNav if (query && query->isInClosedList(base | (dtPolyRef)i)) col = duRGBA(255,196,0,220); else - col = duDarkenCol(duTransCol(dd->areaToCol(p->getArea()), 220)); + col = duDarkenCol(duTransCol(dd->areaToFaceCol(p->getArea()), 220)); const float* va = &tile->verts[p->verts[0]*3]; const float* vb = &tile->verts[p->verts[1]*3]; @@ -905,7 +905,7 @@ void duDebugDrawTileCacheLayerAreas(struct duDebugDraw* dd, const dtTileCacheLay else if (area == 0) col = duLerpCol(color, duRGBA(0,0,0,64), 32); else - col = duLerpCol(color, dd->areaToCol(area), 32); + col = duLerpCol(color, dd->areaToFaceCol(area), 32); const float fx = bmin[0] + x*cs; const float fy = bmin[1] + y*cs; @@ -1089,7 +1089,7 @@ void duDebugDrawTileCachePolyMesh(duDebugDraw* dd, const struct dtTileCachePolyM else if (area == DT_TILECACHE_NULL_AREA) color = duRGBA(0,0,0,64); else - color = dd->areaToCol(area); + color = dd->areaToFaceCol(area); unsigned short vi[3]; for (int j = 2; j < nvp; ++j) diff --git a/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp index 5c0d2297..39f8fecd 100644 --- a/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/RecastDebugDraw.cpp @@ -196,7 +196,7 @@ void duDebugDrawHeightfieldWalkable(duDebugDraw* dd, const rcHeightfield& hf, co else if (s->area == RC_NULL_AREA) fcol[0] = duRGBA(64,64,64,255); else - fcol[0] = duMultCol(dd->areaToCol(s->area), 200); + fcol[0] = duMultCol(dd->areaToFaceCol(s->area), 200); duAppendBox(dd, fx, fy, orig[2] + s->smin*ch, fx+cs, fy+cs, orig[2] + s->smax*ch, fcol); s = s->next; @@ -235,7 +235,7 @@ void duDebugDrawCompactHeightfieldSolid(duDebugDraw* dd, const rcCompactHeightfi else if (area == RC_NULL_AREA) color = duRGBA(0,0,0,64); else - color = dd->areaToCol(area); + color = dd->areaToFaceCol(area); const float fz = chf.bmin[2] + (s.z+1)*ch; dd->vertex(fx, fy, fz, color); @@ -402,7 +402,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, dd->areaToCol(area), 32); + col = duLerpCol(color, dd->areaToFaceCol(area), 32); const float fx = layer.bmin[0] + x*cs; const float fy = layer.bmin[1] + y*cs; @@ -656,7 +656,7 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh, const f else if (area == RC_NULL_AREA) color = duRGBA(0,0,0,64); else - color = duTransCol(dd->areaToCol(area), 170); + color = duTransCol(dd->areaToFaceCol(area), 170); unsigned short vi[3]; for (int j = 2; j < nvp; ++j) @@ -678,11 +678,12 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh, const f dd->end(); // Draw neighbours edges - const unsigned int coln = duRGBA(0,48,64,32); dd->begin(DU_DRAW_LINES, 1.5f, offset); for (int i = 0; i < mesh.npolys; ++i) { const unsigned short* p = &mesh.polys[i*nvp*2]; + const unsigned int coln = duTransCol(dd->areaToEdgeCol(mesh.areas[i]), 32); + for (int j = 0; j < nvp; ++j) { if (p[j] == RD_MESH_NULL_IDX) break; @@ -703,11 +704,11 @@ void duDebugDrawPolyMesh(duDebugDraw* dd, const struct rcPolyMesh& mesh, const f dd->end(); // Draw boundary edges - const unsigned int colb = duRGBA(0,48,64,220); dd->begin(DU_DRAW_LINES, 3.5f, offset); for (int i = 0; i < mesh.npolys; ++i) { const unsigned short* p = &mesh.polys[i*nvp*2]; + const unsigned int colb = duTransCol(dd->areaToEdgeCol(mesh.areas[i]), 220); for (int j = 0; j < nvp; ++j) { if (p[j] == RD_MESH_NULL_IDX) break;