Merge pull request #437 from svenstaro/patch-1

Fix unintentional backface culling in triangle intersect #437
This commit is contained in:
Christophe R 2015-11-17 10:58:15 +01:00
commit 376732e5ae
2 changed files with 2 additions and 38 deletions

View File

@ -49,7 +49,7 @@ namespace glm
typename genType::value_type a = glm::dot(e1, p); typename genType::value_type a = glm::dot(e1, p);
typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon(); typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
if(a < Epsilon) if(a < Epsilon && a > -Epsilon)
return false; return false;
typename genType::value_type f = typename genType::value_type(1.0f) / a; typename genType::value_type f = typename genType::value_type(1.0f) / a;
@ -73,43 +73,6 @@ namespace glm
return baryPosition.z >= typename genType::value_type(0.0f); return baryPosition.z >= typename genType::value_type(0.0f);
} }
//template <typename genType>
//GLM_FUNC_QUALIFIER bool intersectRayTriangle
//(
// genType const & orig, genType const & dir,
// genType const & vert0, genType const & vert1, genType const & vert2,
// genType & position
//)
//{
// typename genType::value_type Epsilon = std::numeric_limits<typename genType::value_type>::epsilon();
//
// genType edge1 = vert1 - vert0;
// genType edge2 = vert2 - vert0;
//
// genType pvec = cross(dir, edge2);
//
// float det = dot(edge1, pvec);
// if(det < Epsilon)
// return false;
//
// genType tvec = orig - vert0;
//
// position.y = dot(tvec, pvec);
// if (position.y < typename genType::value_type(0) || position.y > det)
// return typename genType::value_type(0);
//
// genType qvec = cross(tvec, edge1);
//
// position.z = dot(dir, qvec);
// if (position.z < typename genType::value_type(0) || position.y + position.z > det)
// return typename genType::value_type(0);
//
// position.x = dot(edge2, qvec);
// position *= typename genType::value_type(1) / det;
//
// return typename genType::value_type(1);
//}
template <typename genType> template <typename genType>
GLM_FUNC_QUALIFIER bool intersectLineTriangle GLM_FUNC_QUALIFIER bool intersectLineTriangle
( (

View File

@ -68,6 +68,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
##### Fixes: ##### Fixes:
- Fixed GTX_extended_min_max filename typo #386 - Fixed GTX_extended_min_max filename typo #386
- Fixed intersectRayTriangle to not do any unintentional backface culling
#### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX #### [GLM 0.9.7.2](https://github.com/g-truc/glm/tree/0.9.7) - 2015-XX-XX
##### Fixes: ##### Fixes: