From bd0e9e7aa83f8fef35321832960dc127ddf5f1f0 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sat, 2 Mar 2019 19:53:46 +0100 Subject: Core/MMaps: Fix infinite loop in Detour Fix another infinite loop in Detour caused by degenerated triangles. Check the result of some previously ignored Detour calls. Update recastnavigation to 3a619d773deb7e3a15ee215217c825995fe71312 and apply some more custom changes (cherry picked from commit c602220e02bed1ad76c9e60064eeec5fd97bfe80) --- dep/PackageList.txt | 3 ++- dep/recastnavigation/Detour/Source/DetourCommon.cpp | 10 +++++++++- dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'dep') diff --git a/dep/PackageList.txt b/dep/PackageList.txt index c68c3912aaf..d84d808a8fe 100644 --- a/dep/PackageList.txt +++ b/dep/PackageList.txt @@ -54,7 +54,8 @@ gSOAP (a portable development toolkit for C and C++ XML Web services and XML dat recastnavigation (Recast is state of the art navigation mesh construction toolset for games) https://github.com/recastnavigation/recastnavigation - Version: 14b2631527c4792e95b2c78ebfa8ac4cd3413363 + Version: 3a619d773deb7e3a15ee215217c825995fe71312 + Custom changes: https://github.com/TrinityCore/recastnavigation/tree/3.3.5 CascLib (An open-source implementation of library for reading CASC storage from Blizzard games since 2014) https://github.com/ladislav-zezula/CascLib diff --git a/dep/recastnavigation/Detour/Source/DetourCommon.cpp b/dep/recastnavigation/Detour/Source/DetourCommon.cpp index 3886f14b04d..e10e6276170 100644 --- a/dep/recastnavigation/Detour/Source/DetourCommon.cpp +++ b/dep/recastnavigation/Detour/Source/DetourCommon.cpp @@ -226,7 +226,15 @@ bool dtClosestHeightPointTriangle(const float* p, const float* a, const float* b // If point lies inside the triangle, return interpolated ycoord. if (u >= epsilon && v >= epsilon && (u+v) <= denom - epsilon) { - h = a[1] + (v0[1]*u + v1[1]*v) / denom; + + if (denom == 0.f && u == 0.f && v == 0.f) + h = a[1]; + else + h = a[1] + (v0[1]*u + v1[1]*v) / denom; + + if (!dtMathIsfinite(h)) + return false; + return true; } return false; diff --git a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp index c18db1c1968..9e470824287 100644 --- a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp +++ b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp @@ -1301,8 +1301,8 @@ dtStatus dtNavMeshQuery::initSlicedFindPath(dtPolyRef startRef, dtPolyRef endRef m_query.raycastLimitSqr = FLT_MAX; // Validate input - if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef) - || !startPos || !dtVisfinite(startPos) || + if (!m_nav->isValidPolyRef(startRef) || !m_nav->isValidPolyRef(endRef) || + !startPos || !dtVisfinite(startPos) || !endPos || !dtVisfinite(endPos) || !filter) { return DT_FAILURE | DT_INVALID_PARAM; -- cgit v1.2.3