diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h b/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h index a4047568..17e4580a 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMeshQuery.h @@ -575,6 +575,26 @@ public: dtStatus getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile, dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile, float* mid) const; + + /// Returns edge normal between two polygons. + /// @param[in] from The reference to the start poly. + /// @param[in] to The reference to the end poly. + /// @param[out] norm The normal of the edge. + /// @returns The status flags for the query. + dtStatus getEdgeNormal(dtPolyRef from, dtPolyRef to, float* norm) const; + + /// Returns edge normal between two polygons. + /// @param[in] from The reference to the start poly. + /// @param[in] fromPoly The start poly. + /// @param[in] fromTile The start tile. + /// @param[in] to The reference to the end poly. + /// @param[in] toPoly The end poly. + /// @param[in] toTile The end tile. + /// @param[out] norm The normal point of the edge. + /// @returns The status flags for the query. + dtStatus getEdgeNormal(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile, + dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile, + float* mid) const; /// @} private: diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp index cab4cbbe..398498d0 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp @@ -2325,9 +2325,7 @@ dtStatus dtNavMeshQuery::getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mi unsigned char fromType, toType; if (dtStatusFailed(getPortalPoints(from, to, left,right, fromType, toType))) return DT_FAILURE | DT_INVALID_PARAM; - mid[0] = (left[0]+right[0])*0.5f; - mid[1] = (left[1]+right[1])*0.5f; - mid[2] = (left[2]+right[2])*0.5f; + rdVsad(mid, left,right, 0.5f); return DT_SUCCESS; } @@ -2338,13 +2336,34 @@ dtStatus dtNavMeshQuery::getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly, float left[3], right[3]; if (dtStatusFailed(getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, left, right))) return DT_FAILURE | DT_INVALID_PARAM; - mid[0] = (left[0]+right[0])*0.5f; - mid[1] = (left[1]+right[1])*0.5f; - mid[2] = (left[2]+right[2])*0.5f; + rdVsad(mid, left,right, 0.5f); return DT_SUCCESS; } +dtStatus dtNavMeshQuery::getEdgeNormal(dtPolyRef from, dtPolyRef to, float* norm) const +{ + float left[3], right[3]; + unsigned char fromType, toType; + if (dtStatusFailed(getPortalPoints(from, to, left,right, fromType, toType))) + return DT_FAILURE | DT_INVALID_PARAM; + float dir[3]; + rdVsub(dir, right,left); + rdPerpDirEdge2D(dir, false, norm); + return DT_SUCCESS; +} +dtStatus dtNavMeshQuery::getEdgeNormal(dtPolyRef from, const dtPoly* fromPoly, const dtMeshTile* fromTile, + dtPolyRef to, const dtPoly* toPoly, const dtMeshTile* toTile, + float* norm) const +{ + float left[3], right[3]; + if (dtStatusFailed(getPortalPoints(from, fromPoly, fromTile, to, toPoly, toTile, left, right))) + return DT_FAILURE | DT_INVALID_PARAM; + float dir[3]; + rdVsub(dir, right,left); + rdPerpDirEdge2D(dir, false, norm); + return DT_SUCCESS; +} /// @par ///