Recast: properly tag unlinked poly's to disable them

In the future we actually want to get rid of unlinked polygons, see https://groups.google.com/g/recastnavigation/c/WLMRcDjsxFc for reference.
This commit is contained in:
Kawe Mazidjatari 2024-08-14 11:59:19 +02:00
parent 06b673dc84
commit 91d36cf007

View File

@ -169,9 +169,13 @@ static void disableUnvisitedPolys(dtNavMesh* nav, NavmeshFlags* flags)
const dtPolyRef ref = base | (unsigned int)j;
if (!flags->getFlags(ref))
{
unsigned short f = 0;
nav->getPolyFlags(ref, &f);
nav->setPolyFlags(ref, f | EDITOR_POLYFLAGS_DISABLED);
const dtMeshTile* targetTile;
dtPoly* targetPoly;
nav->getTileAndPolyByRefUnsafe(ref, &targetTile, (const dtPoly**)&targetPoly);
targetPoly->groupId = DT_UNLINKED_POLY_GROUP;
targetPoly->firstLink = DT_NULL_LINK;
targetPoly->flags = 0;
}
}
}
@ -218,6 +222,7 @@ void NavMeshPruneTool::handleMenu()
if (ImGui::Button("Prune Unselected"))
{
disableUnvisitedPolys(nav, m_flags);
m_editor->updateStaticPathingData();
delete m_flags;
m_flags = 0;
}