From 94e2df954262cbbe7dcd50b6c066ee5c9625f9da Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:48:14 +0200 Subject: [PATCH] Recast: add option to render poly's by group id Useful for debugging static pathing data. --- src/naveditor/Editor_TileMesh.cpp | 3 +++ .../recast/DebugUtils/Include/DetourDebugDraw.h | 5 +++-- .../recast/DebugUtils/Source/DetourDebugDraw.cpp | 14 +++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/naveditor/Editor_TileMesh.cpp b/src/naveditor/Editor_TileMesh.cpp index 558b00d5..9903cf0f 100644 --- a/src/naveditor/Editor_TileMesh.cpp +++ b/src/naveditor/Editor_TileMesh.cpp @@ -403,6 +403,9 @@ void Editor_TileMesh::handleDebugMode() if (imguiCheck("Draw Poly Centers", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_POLYCENTERS))) toggleNavMeshDrawFlag(DU_DRAWNAVMESH_POLYCENTERS); + if (imguiCheck("Draw Poly Groups", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_POLYGROUPS))) + toggleNavMeshDrawFlag(DU_DRAWNAVMESH_POLYGROUPS); + if (imguiCheck("Disable NavMesh Depth Mask", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_NO_DEPTH_MASK))) toggleNavMeshDrawFlag(DU_DRAWNAVMESH_NO_DEPTH_MASK); diff --git a/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h b/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h index e5a84816..8376e495 100644 --- a/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h +++ b/src/thirdparty/recast/DebugUtils/Include/DetourDebugDraw.h @@ -32,8 +32,9 @@ enum DrawNavMeshFlags DU_DRAWNAVMESH_INNERBOUND = 1 << 4, // Render inner poly boundaries. DU_DRAWNAVMESH_OUTERBOUND = 1 << 5, // Render outer poly boundaries. DU_DRAWNAVMESH_POLYCENTERS = 1 << 6, // Render poly centers. - DU_DRAWNAVMESH_NO_DEPTH_MASK = 1 << 7, // Disable render depth mask. - DU_DRAWNAVMESH_NO_ALPHA = 1 << 8, // Disable navmesh transparency. + DU_DRAWNAVMESH_POLYGROUPS = 1 << 7, // Render poly group by color. + DU_DRAWNAVMESH_NO_DEPTH_MASK = 1 << 8, // Disable render depth mask. + DU_DRAWNAVMESH_NO_ALPHA = 1 << 9, // Disable navmesh transparency. }; void duDebugDrawNavMesh(struct duDebugDraw* dd, const dtNavMesh& mesh, unsigned char flags); diff --git a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp index 376e45fa..86d5288a 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp @@ -136,14 +136,12 @@ static void drawPolyCenters(duDebugDraw* dd, const dtMeshTile* tile, const unsig static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery* query, const dtMeshTile* tile, unsigned int flags) { - dtPolyRef base = mesh.getPolyRefBase(tile); - int tileNum = mesh.decodePolyIdTile(base); - // If "No Alpha" flag is set, force the colour to be opaque instead of semi-transparent. - const int tileAlpha = flags & DU_DRAWNAVMESH_NO_ALPHA ? 255 : 170; - const unsigned int tileColor = duIntToCol(tileNum, tileAlpha); - + const int tileAlpha = flags & DU_DRAWNAVMESH_NO_ALPHA ? 255 : 170; const bool disableDepthTest = flags & DU_DRAWNAVMESH_NO_DEPTH_MASK; + + dtPolyRef base = mesh.getPolyRefBase(tile); + dd->depthMask(!disableDepthTest); dd->begin(DU_DRAW_TRIS); @@ -161,7 +159,9 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh else { if (flags & DU_DRAWNAVMESH_COLOR_TILES) - col = tileColor; + col = duIntToCol(mesh.decodePolyIdTile(base), tileAlpha); + else if (flags & DU_DRAWNAVMESH_POLYGROUPS) + col = duIntToCol(p->groupId, tileAlpha); else col = getPolySurfaceColor(p, dd, tileAlpha); }