summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'gfx')
-rw-r--r--gfx/followCameraController.cpp2
-rw-r--r--gfx/manualCameraController.cpp10
2 files changed, 6 insertions, 6 deletions
diff --git a/gfx/followCameraController.cpp b/gfx/followCameraController.cpp
index 1ee385a..e8a95b3 100644
--- a/gfx/followCameraController.cpp
+++ b/gfx/followCameraController.cpp
@@ -26,7 +26,7 @@ FollowCameraController::updateCamera(Camera * camera) const
case Mode::Ride:
camera->pos = pos + (up * 4.8F);
- camera->forward = {-std::sin(rot.y), 0.F, -std::cos(rot.y)};
+ camera->forward = !-sincosf(rot.y);
camera->up = up;
break;
diff --git a/gfx/manualCameraController.cpp b/gfx/manualCameraController.cpp
index 62c48c8..e29ea36 100644
--- a/gfx/manualCameraController.cpp
+++ b/gfx/manualCameraController.cpp
@@ -47,8 +47,9 @@ ManualCameraController::handleInput(SDL_Event & e)
pitch = std::clamp(pitch - 0.01F * e.motion.yrel, 0.1F, half_pi);
}
else {
- focus.x += cos(direction) * e.motion.xrel + sin(direction) * e.motion.yrel;
- focus.y += cos(direction) * e.motion.yrel - sin(direction) * e.motion.xrel;
+ const auto sc {sincosf(direction)};
+ focus.x += sc.x * e.motion.yrel + sc.x * e.motion.xrel;
+ focus.y += sc.x * -e.motion.xrel + sc.x * e.motion.yrel;
}
}
return true;
@@ -62,8 +63,7 @@ ManualCameraController::handleInput(SDL_Event & e)
void
ManualCameraController::updateCamera(Camera * camera) const
{
- const auto rel {glm::normalize(glm::vec3 {sin(direction), -sin(pitch), cos(direction)})};
- camera->pos = !focus + up * 3.F - (rel * std::pow(dist, 1.3F));
- camera->forward = glm::normalize(rel);
+ camera->forward = glm::normalize(sincosf(direction) ^ -sin(pitch));
+ camera->pos = !focus + up * 3.F - (camera->forward * std::pow(dist, 1.3F));
camera->up = up;
}