fix camera, broken since f5eb0e0dfa

This commit is contained in:
Green Sky 2022-02-17 00:53:21 +01:00
parent 601e1ca99d
commit 4304701e5e

View File

@ -72,17 +72,18 @@ glm::mat4 Camera3D::getProjection() const {
glm::vec3 Camera3D::getViewDir(void) const {
glm::vec3 front {0,0,0};
{ // TODO: optimize
#if 0
// if y up/down
front.x += up.y * glm::cos(pitch) * glm::cos(-yaw); // TODO: y is yaw inverted??
front.y += up.y * glm::sin(pitch);
front.z += up.y * glm::cos(pitch) * glm::sin(-yaw);
#else
// if z up/down
front.x += up.z * glm::cos(pitch) * glm::cos(yaw);
front.y += up.z * glm::cos(pitch) * glm::sin(yaw);
front.z += up.z * glm::sin(pitch);
#endif
if (up.y != 0.f) {
// if y up/down
front.x += up.y * glm::cos(pitch) * glm::cos(-yaw); // TODO: y is yaw inverted??
front.y += up.y * glm::sin(pitch);
front.z += up.y * glm::cos(pitch) * glm::sin(-yaw);
}
if (up.z != 0.f) {
// if z up/down
front.x += up.z * glm::cos(pitch) * glm::cos(yaw);
front.y += up.z * glm::cos(pitch) * glm::sin(yaw);
front.z += up.z * glm::sin(pitch);
}
}
front = glm::normalize(front);