Recast: add method for marking cells as occupied

This commit is contained in:
Kawe Mazidjatari 2024-09-01 00:01:51 +02:00
parent 3227208533
commit 66cf9678d2
3 changed files with 5 additions and 5 deletions

View File

@ -377,8 +377,8 @@ static void drawTileCells(duDebugDraw* dd, const dtMeshTile* tile, const float*
#if DT_NAVMESH_SET_VERSION >= 8
for (int i = 0; i < tile->header->maxCellCount; i++)
{
const dtCell& probe = tile->cells[i];
duDebugDrawCross(dd, probe.pos[0], probe.pos[1], probe.pos[2], 25.f, duRGBA(255,0,0,255), 2, offset);
const dtCell& cell = tile->cells[i];
duDebugDrawCross(dd, cell.pos[0], cell.pos[1], cell.pos[2], 25.f, duRGBA(255,0,0,255), 2, offset);
}
#else
rdIgnoreUnused(dd);

View File

@ -322,6 +322,8 @@ unsigned char dtQuantLinkDistance(const float distance);
/// @see dtMeshTile
struct dtCell
{
inline void setOccupied() { *(int*)((uintptr_t)&occupyState & ~0x3) = -1; }
float pos[3]; ///< The position of the cell.
unsigned int polyIndex; ///< The index of the poly this cell is on.
unsigned char pad;

View File

@ -1107,9 +1107,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
rdVcopy(cell.pos, cellItem.pos);
cell.polyIndex = cellItem.polyIndex;
int* state = (int*)((uintptr_t)&cell.occupyState & ~0x3);
*state = -1;
cell.setOccupied();
}
#endif