Recast: fix incorrect reachability table buffer size calculation

Reachability table buffers were way larger than they should be due to an incorrect calculation of the buffer size. This bug fix reduced NavMesh sizes significantly (worlds edge '_small' was 200mb, and is now 20mb after this patch).
This commit is contained in:
Kawe Mazidjatari 2024-07-03 10:45:44 +02:00
parent bff572659f
commit c215fcb220

View File

@ -439,7 +439,7 @@ void Editor::saveAll(std::string path, dtNavMesh* mesh)
header.params.disjointPolyGroupCount = linkData.setCount;
header.params.reachabilityTableCount = m_reachabilityTableCount;
header.params.reachabilityTableSize = ((header.params.disjointPolyGroupCount + 31) / 32) * header.params.disjointPolyGroupCount * 32;
header.params.reachabilityTableSize = (linkData.setCount - 1) * ((linkData.setCount + 31) / 32) + (linkData.setCount - 1) / 32;
fwrite(&header, sizeof(NavMeshSetHeader), 1, fp);
@ -458,7 +458,7 @@ void Editor::saveAll(std::string path, dtNavMesh* mesh)
fwrite(tile->data, tile->dataSize, 1, fp);
}
std::vector<int> reachability(tableSize, 0);
std::vector<int> reachability(header.params.reachabilityTableSize, 0);
for (int i = 0; i < linkData.setCount; i++)
setReachable(reachability, linkData.setCount, i, i, true);