From fa1db8f9958656179de882fd60a2beea2d2a5ba9 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:11:44 +0200 Subject: [PATCH] Recast: clamp the off-mesh connection positions as well Allows for parsing zipline positions from BSP entity partitions and placing them whilst also having it clamp the positions correctly to the polygon the zipliner will end up or start from. --- src/thirdparty/recast/Detour/Include/DetourNavMesh.h | 2 +- src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h index 92e35c0b..223550e0 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMesh.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMesh.h @@ -1015,7 +1015,7 @@ public: /// Builds external polygon links for a tile. dtStatus connectOffMeshLinks(const dtTileRef tileRef); - dtPolyRef clampOffMeshVertToPoly(const dtOffMeshConnection* con, dtMeshTile* conTile, const dtMeshTile* lookupTile, const bool start); + dtPolyRef clampOffMeshVertToPoly(dtOffMeshConnection* con, dtMeshTile* conTile, const dtMeshTile* lookupTile, const bool start); private: /// Returns all polygons in neighbour tile based on portal defined by the segment. diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp index 3955a2cb..ccc6d856 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp @@ -531,7 +531,7 @@ void dtNavMesh::connectExtLinks(dtMeshTile* tile, dtMeshTile* target, int side) } } -dtPolyRef dtNavMesh::clampOffMeshVertToPoly(const dtOffMeshConnection* con, dtMeshTile* conTile, +dtPolyRef dtNavMesh::clampOffMeshVertToPoly(dtOffMeshConnection* con, dtMeshTile* conTile, const dtMeshTile* lookupTile, const bool start) { const float* p = start ? &con->pos[0] : &con->pos[3]; @@ -548,8 +548,12 @@ dtPolyRef dtNavMesh::clampOffMeshVertToPoly(const dtOffMeshConnection* con, dtMe const dtPoly* poly = &conTile->polys[con->poly]; // Make sure the location is on current mesh. - float* v = &conTile->verts[poly->verts[start?0:1]*3]; - rdVcopy(v, nearestPt); + float* polyVert = &conTile->verts[poly->verts[start?0:1]*3]; + rdVcopy(polyVert, nearestPt); + + // Update the off-mesh connection positions as well. + float* conPos = &con->pos[start?0:3]; + rdVcopy(conPos, nearestPt); return ref; }