From 66cf9678d2db33723cebe9151c2267c630f4b933 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 1 Sep 2024 00:01:51 +0200 Subject: [PATCH] Recast: add method for marking cells as occupied --- src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp | 4 ++-- src/thirdparty/recast/Detour/Include/DetourNavMesh.h | 2 ++ src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp index e4d22a36..d1aad4bd 100644 --- a/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp +++ b/src/thirdparty/recast/DebugUtils/Source/DetourDebugDraw.cpp @@ -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); diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h index de10dd81..51065b3c 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h @@ -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; diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp index 4521115b..c0cc86fe 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp @@ -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