Recast: use '0' as null poly group identifier

(unsigned short)-1 (65535) is technically a valid poly group. We also count from 2 as 1 is reserved for unusable poly's, and 0 was reserved kept reserved for simplicity so just use 0 as the null identifier.
This commit is contained in:
Kawe Mazidjatari 2024-07-07 00:00:06 +02:00
parent d7235a799a
commit fc18050b29
3 changed files with 6 additions and 3 deletions

View File

@ -811,7 +811,7 @@ void Editor_TileMesh::buildAllTiles()
} }
// Reserve the first poly groups // Reserve the first poly groups
// 0 = technically usable for normal poly groups, but for possible internal usage we reserve it for now. // 0 = DT_NULL_POLY_GROUP.
// 1 = DT_STRAY_POLY_GROUP. // 1 = DT_STRAY_POLY_GROUP.
dtDisjointSet data(DT_FIRST_USABLE_POLY_GROUP); dtDisjointSet data(DT_FIRST_USABLE_POLY_GROUP);

View File

@ -63,6 +63,9 @@ typedef unsigned int dtTileRef;
/// @ingroup detour /// @ingroup detour
static const int DT_VERTS_PER_POLYGON = 6; static const int DT_VERTS_PER_POLYGON = 6;
/// A value that indicates that this poly hasn't been assigned to a group yet.
static const unsigned short DT_NULL_POLY_GROUP = 0;
/// A poly group that holds all unconnected stray polys (not linked to anything). /// A poly group that holds all unconnected stray polys (not linked to anything).
/// These are considered 'trash' by the game engine; see [r5apex_ds + CA88B2]. /// These are considered 'trash' by the game engine; see [r5apex_ds + CA88B2].
/// For reference, Titanfall 2 single player NavMeshes also marked everything unconnected as '1'. /// For reference, Titanfall 2 single player NavMeshes also marked everything unconnected as '1'.

View File

@ -294,7 +294,7 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint)
for (int j = 0; j < pcount; j++) for (int j = 0; j < pcount; j++)
{ {
dtPoly& poly = tile->polys[j]; dtPoly& poly = tile->polys[j];
poly.groupId = (unsigned short)-1; poly.groupId = DT_NULL_POLY_GROUP;
// NOTE: these fields are unknown and need to be reversed. // NOTE: these fields are unknown and need to be reversed.
// It is possible these are used internally only. // It is possible these are used internally only.
@ -332,7 +332,7 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint)
const dtPoly* p; const dtPoly* p;
nav->getTileAndPolyByRefUnsafe(l.ref, &t, &p); nav->getTileAndPolyByRefUnsafe(l.ref, &t, &p);
if (p->groupId != (unsigned short)-1) if (p->groupId != DT_NULL_POLY_GROUP)
nlabels.insert(p->groupId); nlabels.insert(p->groupId);
plink = l.next; plink = l.next;