mirror of
https://github.com/g-truc/glm.git
synced 2024-09-20 00:12:17 +00:00
Merge branch '0.9.5' of https://github.com/g-truc/glm into 0.9.5
This commit is contained in:
commit
f2bce9c8fa
@ -52,6 +52,15 @@ namespace glm
|
|||||||
/// @addtogroup gtx_intersect
|
/// @addtogroup gtx_intersect
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
//! Compute the intersection of a ray and a triangle.
|
||||||
|
//! Ray direction and plane normal must be unit length.
|
||||||
|
//! From GLM_GTX_intersect extension.
|
||||||
|
template <typename genType>
|
||||||
|
bool intersectRayPlane(
|
||||||
|
genType const & orig, genType const & dir,
|
||||||
|
genType const & planeOrig, genType const & planeNormal,
|
||||||
|
typename genType::value_type & intersectionDistance);
|
||||||
|
|
||||||
//! Compute the intersection of a ray and a triangle.
|
//! Compute the intersection of a ray and a triangle.
|
||||||
//! From GLM_GTX_intersect extension.
|
//! From GLM_GTX_intersect extension.
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
|
@ -13,6 +13,26 @@
|
|||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
{
|
{
|
||||||
|
template <typename genType>
|
||||||
|
GLM_FUNC_QUALIFIER bool intersectRayPlane
|
||||||
|
(
|
||||||
|
genType const & orig, genType const & dir,
|
||||||
|
genType const & planeOrig, genType const & planeNormal,
|
||||||
|
typename genType::value_type & intersectionDistance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typename genType::value_type d = glm::dot(dir, planeNormal);
|
||||||
|
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
|
||||||
|
|
||||||
|
if(d < Epsilon)
|
||||||
|
{
|
||||||
|
intersectionDistance = glm::dot(planeOrig - orig, planeNormal) / d;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
GLM_FUNC_QUALIFIER bool intersectRayTriangle
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user