From 88052ba558387ee55a69dc22b12aacdc14af09d5 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:13:08 +0200 Subject: [PATCH] Recast: fix poly detail height bug when height isn't found The height couldn't be found on some edge case scenarios (typically complex geometry), but in these cases the height was still set to (unsigned short)-1, causing it to return a height very far into positive Z. The vert would therefore appears very far into the sky. This patch fixes this problem. --- src/thirdparty/recast/Recast/Source/RecastMeshDetail.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/thirdparty/recast/Recast/Source/RecastMeshDetail.cpp b/src/thirdparty/recast/Recast/Source/RecastMeshDetail.cpp index 50c34cc6..e6ff5eae 100644 --- a/src/thirdparty/recast/Recast/Source/RecastMeshDetail.cpp +++ b/src/thirdparty/recast/Recast/Source/RecastMeshDetail.cpp @@ -278,6 +278,11 @@ static unsigned short getHeight(const float fx, const float fy, const float fz, y += dy; } } + + // No height found, return a reasonable fall back height. + if (h == RC_UNSET_HEIGHT) + h = (unsigned short)floorf(fz/ch); + return h; }