| 48 | |
| 49 | namespace { |
| 50 | glm::dvec3 positionFromView(const glm::dmat4& viewMatrix) { |
| 51 | // Back out the world position by multiplying the view matrix translation by |
| 52 | // the rotation transpose (inverse) and negating. |
| 53 | glm::dvec3 position(0.0); |
| 54 | position.x = -glm::dot(glm::dvec3(viewMatrix[0]), glm::dvec3(viewMatrix[3])); |
| 55 | position.y = -glm::dot(glm::dvec3(viewMatrix[1]), glm::dvec3(viewMatrix[3])); |
| 56 | position.z = -glm::dot(glm::dvec3(viewMatrix[2]), glm::dvec3(viewMatrix[3])); |
| 57 | return position; |
| 58 | } |
| 59 | |
| 60 | glm::dvec3 directionFromView(const glm::dmat4& viewMatrix) { |
| 61 | return glm::dvec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]) * |