From ca08d290dbaf5df28551464efb9fd7607f3f5ed2 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 7 Jul 2024 01:15:43 +0200 Subject: [PATCH] Recast: improve readability of disjoint poly group builder --- .../Detour/Source/DetourNavMeshBuilder.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp index fabee81a..145763fe 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp @@ -305,7 +305,7 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint) } // First pass to group linked and unlinked poly islands. - std::set nlabels; + std::set linkedGroups; for (int i = 0; i < nav->getMaxTiles(); ++i) { dtMeshTile* tile = nav->getTile(i); @@ -333,15 +333,15 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint) nav->getTileAndPolyByRefUnsafe(l.ref, &t, &p); if (p->groupId != DT_NULL_POLY_GROUP) - nlabels.insert(p->groupId); + linkedGroups.insert(p->groupId); plink = l.next; } } - const bool noLabels = nlabels.empty(); + const bool noLinkedGroups = linkedGroups.empty(); - if (noLabels) + if (noLinkedGroups) { // This poly isn't connected to anything, mark it so the game // won't consider this poly in path generation. @@ -352,15 +352,15 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint) } else { - const int l = *nlabels.begin(); - poly.groupId = (unsigned short)l; + const unsigned short rootGroup = *linkedGroups.begin(); + poly.groupId = rootGroup; - for (const int nl : nlabels) - disjoint.setUnion(l, nl); + for (const int linkedGroup : linkedGroups) + disjoint.setUnion(rootGroup, linkedGroup); } - if (!noLabels) - nlabels.clear(); + if (!noLinkedGroups) + linkedGroups.clear(); } }