From 537f149be3096fda0fc93ba1207041889ee2996b Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:54:30 +0200 Subject: [PATCH] Recast: fix compile error This function was removed in commit 041d02cd654d94bf4b059c212cb6a63a39e5324e but it should've been kept in as it was still used for dtNavMeshQuery::findRandomPointAroundCircle. Only the quantizer should be removed. --- .../recast/Detour/Include/DetourNavMesh.h | 6 ++++++ .../recast/Detour/Source/DetourNavMesh.cpp | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h index 9cbc74c0..6dd322dd 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h @@ -265,6 +265,12 @@ struct dtPoly inline unsigned char getType() const { return areaAndtype >> 6; } }; +/// Calculates the surface area of the polygon. +/// @param[in] poly The polygon. +/// @param[in] verts The polygon vertices. +/// @return The total surface are of the polygon. +float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts); + /// Defines the location of detail sub-mesh data within a dtMeshTile. struct dtPolyDetail { diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp index 1bbb282c..c42dfab1 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp @@ -1868,6 +1868,23 @@ unsigned char dtQuantLinkDistance(const float distance) return (unsigned char)(rdMathRoundf(distance * DT_TRAVERSE_DIST_QUANT_FACTOR)); } +float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts) +{ + float polyArea = 0.0f; + + // Only run if we have more than 2 verts since poly's with 2 verts + // (off-mesh connections) don't have any surface area. + for (int i = 2; i < poly->vertCount; ++i) + { + const float* va = &verts[poly->verts[0]*3]; + const float* vb = &verts[poly->verts[i]*3]; + const float* vc = &verts[poly->verts[i-1]*3]; + polyArea += rdTriArea2D(va,vb,vc); + } + + return polyArea; +} + float dtCalcOffMeshRefYaw(const float* spos, const float* epos) { const float dx = epos[0]-spos[0];