From 1255629fcf5a0b0ca2140309ca891c79e2f24738 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:35:13 +0200 Subject: [PATCH] Recast: fix dtNavMeshQuery regression pointers were also nulled during the memset after the move to the dtQueryStruct in commit 9049e61d34cb3f52627b8ca10f1b7da21e147ad9. Created dedicated 'Reset' method. --- .../Detour/Include/DetourNavMeshQuery.h | 21 +++++++++++++++++++ .../Detour/Source/DetourNavMeshQuery.cpp | 10 ++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h b/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h index 6313d12a..99146faa 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h @@ -561,6 +561,27 @@ private: struct dtQueryData { + void Reset() + { + status = 0; + lastBestNode = nullptr; + lastBestNodeCost = 0.0f; + startRef = 0; endRef = 0; + + startPos[0] = 0.0f; + startPos[1] = 0.0f; + startPos[2] = 0.0f; + + endPos[0] = 0.0f; + endPos[1] = 0.0f; + endPos[2] = 0.0f; + + options = 0; + raycastLimitSqr = 0.0f; + + // NOTE: the nodepool/nodequeue pointers should not be reset !!! + } + dtStatus status; struct dtNode* lastBestNode; float lastBestNodeCost; diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp index 0f11b7bd..dbd411be 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp @@ -1202,7 +1202,7 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef dtAssert(m_query.m_openList); // Init path state. - memset(&m_query, 0, sizeof(dtQueryData)); + m_query.Reset(); m_query.status = DT_FAILURE; m_query.startRef = startRef; m_query.endRef = endRef; @@ -1487,7 +1487,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, if (dtStatusFailed(m_query.status)) { // Reset query. - memset(&m_query, 0, sizeof(dtQueryData)); + m_query.Reset(); return DT_FAILURE; } @@ -1557,7 +1557,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPath(dtPolyRef* path, int* pathCount, const dtStatus details = m_query.status & DT_STATUS_DETAIL_MASK; // Reset query. - memset(&m_query, 0, sizeof(dtQueryData)); + m_query.Reset(); *pathCount = n; @@ -1578,7 +1578,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing if (dtStatusFailed(m_query.status)) { // Reset query. - memset(&m_query, 0, sizeof(dtQueryData)); + m_query.Reset(); return DT_FAILURE; } @@ -1658,7 +1658,7 @@ dtStatus dtNavMeshQuery::finalizeSlicedFindPathPartial(const dtPolyRef* existing const dtStatus details = m_query.status & DT_STATUS_DETAIL_MASK; // Reset query. - memset(&m_query, 0, sizeof(dtQueryData)); + m_query.Reset(); *pathCount = n;