From 324e933c04ff6c9e6c2c7723f69712651c794bd0 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:43:36 +0200 Subject: [PATCH] Recast: properly implement detail mesh edge renderer Previous implementation was incorrect as it was trying to render triangles as lines. --- .../DebugUtils/Source/DetourDebugDraw.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp index c88f94bc..622d4558 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp @@ -101,15 +101,24 @@ static void drawPolyMeshEdges(duDebugDraw* dd, const dtMeshTile* tile, const flo const dtPolyDetail* pd = &tile->detailMeshes[i]; dd->begin(DU_DRAW_LINES, 1.0f, offset); - for (int k = 0; k < pd->triCount; ++k) + for (int j = 0; j < pd->triCount; ++j) { - const unsigned char* t = &tile->detailTris[(pd->triBase+k)*4]; - for (int m = 0; m < 3; ++m) + const unsigned char* t = &tile->detailTris[(pd->triBase+j)*4]; + const float* tv[3]; + for (int k = 0; k < 3; ++k) { - if (t[m] < p->vertCount) - dd->vertex(&tile->verts[p->verts[t[m]]*3], c); + if (t[k] < p->vertCount) + tv[k] = &tile->verts[p->verts[t[k]]*3]; else - dd->vertex(&tile->detailVerts[(pd->vertBase+t[m]-p->vertCount)*3], c); + tv[k] = &tile->detailVerts[(pd->vertBase+(t[k]-p->vertCount))*3]; + } + for (int k = 0, l = 2; k < 3; l = k++) + { + if ((dtGetDetailTriEdgeFlags(t[3], l) & RD_DETAIL_EDGE_BOUNDARY)) + continue; + + dd->vertex(tv[l], c); + dd->vertex(tv[k], c); } } dd->end();