diff options
Diffstat (limited to 'src/vec4ops/vec4ops.cpp')
-rw-r--r-- | src/vec4ops/vec4ops.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/vec4ops/vec4ops.cpp b/src/vec4ops/vec4ops.cpp index 9bd29e8..cf0900a 100644 --- a/src/vec4ops/vec4ops.cpp +++ b/src/vec4ops/vec4ops.cpp @@ -23,7 +23,6 @@ glm::vec4 Vec4Ops::cross4( result[1] = -(u[0] * f) + (u[2] * c) - (u[3] * b); result[2] = (u[0] * e) - (u[1] * c) + (u[3] * a); result[3] = -(u[0] * d) + (u[1] * b) - (u[2] * a); - return result; } @@ -34,23 +33,23 @@ glm::vec4 Vec4Ops::dot4( } glm::mat4 Vec4Ops::getViewMatrix4( - glm::vec4 upVector, glm::vec4 lookVector, + glm::vec4 upVector, glm::vec4 overVector) { // start with the e3 basis vector, the normalized look vector - glm::vec4 e3 = glm::normalize(lookVector); + glm::vec4 e3 = glm::normalize(-lookVector); // calculate e0 basis vector, from the combinatory cross of up and over with e3 glm::vec4 e0 = cross4(upVector, overVector, e3); e0 = glm::normalize(e0); - if (glm::distance(e0, glm::vec4{0, 0, 0, 0}) < 0.0001f) { + if (glm::isnan(e0[0]) || glm::isnan(e0[1]) || glm::isnan(e0[2]) || glm::isnan(e0[3])) { throw std::runtime_error("invalid up vector"); } // calculate e1 basis vector, from the cross of only the over vector glm::vec4 e1 = cross4(overVector, e3, e0); e1 = glm::normalize(e1); - if (glm::distance(e1, glm::vec4{0, 0, 0, 0}) < 0.0001f) { + if (glm::isnan(e1[0]) || glm::isnan(e1[1]) || glm::isnan(e1[2]) || glm::isnan(e1[3])) { throw std::runtime_error("invalid over vector"); } |