diff --git a/src/thirdparty/recast/Shared/Include/SharedCommon.h b/src/thirdparty/recast/Shared/Include/SharedCommon.h index b7d53a54..549de778 100644 --- a/src/thirdparty/recast/Shared/Include/SharedCommon.h +++ b/src/thirdparty/recast/Shared/Include/SharedCommon.h @@ -541,6 +541,21 @@ unsigned char rdClassifyPointOutsideBounds(const float* pt, const float* bmin, c unsigned char rdClassifyPointInsideBounds(const float* pt, const float* bmin, const float* bmax); unsigned char rdClassifyDirection(const float* dir, const float* bmin, const float* bmax); +/// Determines if the specified point is inside the axis-aligned bounding box. +/// @param[in] pt The point to check. [(x, y, z)] +/// @param[in] bmin Minimum bounds of the box. [(x, y, z)] +/// @param[in] bmax Maximum bounds of the box. [(x, y, z)] +/// @return True if the point is inside the axis-aligned bounding box. +bool rdPointInAABB(const float* pt, const float* bmin, const float* bmax); + +/// Determines if the specified point is inside the cylinder on the xy-plane. +/// @param[in] pt The point to check. [(x, y, z)] +/// @param[in] pos The position of the cylinder. [(x, y, z)] +/// @param[in] radius The radius of the cylinder. +/// @param[in] height The height of the cylinder. +/// @return True if the point is inside the cylinder. +bool rdPointInCylinder(const float* pt, const float* pos, const float radius, const float height); + /// Determines if the specified point is inside the convex polygon on the xy-plane. /// @param[in] pt The point to check. [(x, y, z)] /// @param[in] verts The polygon vertices. [(x, y, z) * @p nverts] diff --git a/src/thirdparty/recast/Shared/Source/SharedCommon.cpp b/src/thirdparty/recast/Shared/Source/SharedCommon.cpp index c2a49687..95fd8549 100644 --- a/src/thirdparty/recast/Shared/Source/SharedCommon.cpp +++ b/src/thirdparty/recast/Shared/Source/SharedCommon.cpp @@ -329,6 +329,33 @@ bool rdClosestHeightPointTriangle(const float* p, const float* a, const float* b return false; } +bool rdPointInAABB(const float* pt, const float* bmin, const float* bmax) +{ + if (pt[0] >= bmin[0] && pt[0] <= bmax[0] && + pt[1] >= bmin[1] && pt[1] <= bmax[1] && + pt[2] >= bmin[2] && pt[2] <= bmax[2]) + { + return true; + } + + return false; +} + +bool rdPointInCylinder(const float* pt, const float* pos, const float radius, const float height) +{ + const float dx = pt[0] - pos[0]; + const float dy = pt[1] - pos[1]; + const float distSquared = dx*dx + dy*dy; + + if (distSquared <= radius * radius && + pt[2] >= pos[2] && pt[2] <= (pos[2] + height)) + { + return true; + } + + return false; +} + /// @par /// /// All points are projected onto the xy-plane, so the z-values are ignored.