Recast: fix a crash during NavMesh load without traverse tables

The sizes still need to be set as the engine at least needs to allocate the traverse table buffer.
This commit is contained in:
Kawe Mazidjatari 2024-10-18 13:29:32 +02:00
parent 5ddc96dc34
commit fc43cbabd9
2 changed files with 3 additions and 16 deletions

View File

@ -191,10 +191,6 @@ int dtCalcTraverseTableCellIndex(const int numPolyGroups,
int dtCalcTraverseTableSize(const int numPolyGroups)
{
// If we only have 2 poly groups, we don't need a traverse table.
if (numPolyGroups < DT_MIN_POLY_GROUP_COUNT)
return 0;
return sizeof(int)*(numPolyGroups*((numPolyGroups+(RD_BITS_PER_BIT_CELL-1))/RD_BITS_PER_BIT_CELL));
}

View File

@ -549,20 +549,8 @@ bool dtCreateDisjointPolyGroups(const dtTraverseTableCreateParams* params)
bool dtCreateTraverseTableData(const dtTraverseTableCreateParams* params)
{
const dtDisjointSet& baseSet = params->sets[0];
const int polyGroupCount = baseSet.getSetCount();
dtNavMesh* nav = params->nav;
if (polyGroupCount < DT_MIN_POLY_GROUP_COUNT)
{
nav->setTraverseTableCount(0);
nav->setTraverseTableSize(0);
nav->setPolyGroupCount(polyGroupCount);
return true;
}
nav->freeTraverseTables();
const int tableCount = params->tableCount;
@ -572,6 +560,9 @@ bool dtCreateTraverseTableData(const dtTraverseTableCreateParams* params)
nav->setTraverseTableCount(tableCount);
copyBaseDisjointSets(params);
const dtDisjointSet& baseSet = params->sets[0];
const int polyGroupCount = baseSet.getSetCount();
const int tableSize = dtCalcTraverseTableSize(polyGroupCount);
nav->setTraverseTableSize(tableSize);