Fixed initialisation

This commit is contained in:
Groove 2018-07-21 18:07:24 +02:00
parent 848800b5c4
commit 7e3f42eeda

View File

@ -41,20 +41,20 @@ namespace glm
// if determinant is near zero, ray lies in plane of triangle // if determinant is near zero, ray lies in plane of triangle
T const det = glm::dot(edge1, p); T const det = glm::dot(edge1, p);
vec<3, T, Q> qvec; vec<3, T, Q> qvec(0);
if(det > std::numeric_limits<T>::epsilon()) if(det > std::numeric_limits<T>::epsilon())
{ {
// calculate distance from vert0 to ray origin // calculate distance from vert0 to ray origin
vec<3, T, Q> const tvec = orig - vert0; vec<3, T, Q> const dist = orig - vert0;
// calculate U parameter and test bounds // calculate U parameter and test bounds
baryPosition.x = glm::dot(tvec, p); baryPosition.x = glm::dot(dist, p);
if(baryPosition.x < static_cast<T>(0) || baryPosition.x > det) if(baryPosition.x < static_cast<T>(0) || baryPosition.x > det)
return false; return false;
// prepare to test V parameter // prepare to test V parameter
qvec = glm::cross(tvec, edge1); qvec = glm::cross(dist, edge1);
// calculate V parameter and test bounds // calculate V parameter and test bounds
baryPosition.y = glm::dot(dir, qvec); baryPosition.y = glm::dot(dir, qvec);
@ -64,15 +64,15 @@ namespace glm
else if(det < -std::numeric_limits<T>::epsilon()) else if(det < -std::numeric_limits<T>::epsilon())
{ {
// calculate distance from vert0 to ray origin // calculate distance from vert0 to ray origin
vec<3, T, Q> const tvec = orig - vert0; vec<3, T, Q> const dist = orig - vert0;
// calculate U parameter and test bounds // calculate U parameter and test bounds
baryPosition.x = glm::dot(tvec, p); baryPosition.x = glm::dot(dist, p);
if((baryPosition.x > static_cast<T>(0)) || (baryPosition.x < det)) if((baryPosition.x > static_cast<T>(0)) || (baryPosition.x < det))
return false; return false;
// prepare to test V parameter // prepare to test V parameter
qvec = glm::cross(tvec, edge1); qvec = glm::cross(dist, edge1);
// calculate V parameter and test bounds // calculate V parameter and test bounds
baryPosition.y = glm::dot(dir, qvec); baryPosition.y = glm::dot(dir, qvec);