30 glm::vec2 offset = event_handler.getCursorOffset();
31 float delta_nanoseconds = std::chrono::duration_cast<std::chrono::duration<float>>(delta).count();
33 static constexpr float min_pitch_angle = -glm::half_pi<float>();
34 static constexpr float max_pitch_angle = glm::half_pi<float>();
36 glm::vec3 forward = camera.
getRotation() * glm::vec3{0.0f, 0.0f, 1.0f};
38 glm::vec3 local_up = glm::vec3{0.0f, -1.0f, 0.0f};
40 glm::vec3 sideway = camera.
getRotation() * glm::vec3{1.0f, 0.0f, 0.0f};
45 float pitch_before = glm::half_pi<float>() - glm::orientedAngle(forward, local_up, sideway);
46 float pitch_after = std::clamp(pitch_before + delta_pitch, min_pitch_angle, max_pitch_angle);
47 delta_pitch = pitch_after - pitch_before;
50 camera.
relativeRotate(glm::angleAxis(delta_yaw, local_up) * glm::angleAxis(delta_pitch, sideway));
64 float front_direction =
static_cast<float>(move_forward) -
static_cast<float>(move_backward);
65 float strafe_direction =
static_cast<float>(move_left) -
static_cast<float>(move_right);
66 float upward_direction =
static_cast<float>(move_upward) -
static_cast<float>(move_downward);
80 float forward_delta = front_direction * camera_speed;
81 float sideway_delta = strafe_direction * camera_speed;
82 float upward_delta = upward_direction * camera_speed;
84 glm::vec3 translation = forward_delta * forward + sideway_delta * sideway + upward_delta * local_up;
94 std::uint32_t forward = core::KeyboardKey::KEY_W;
95 std::uint32_t backward = core::KeyboardKey::KEY_S;
96 std::uint32_t left = core::KeyboardKey::KEY_A;
97 std::uint32_t right = core::KeyboardKey::KEY_D;
98 std::uint32_t up = core::KeyboardKey::KEY_Q;
99 std::uint32_t down = core::KeyboardKey::KEY_Z;
100 std::uint32_t walk = core::KeyboardKey::KEY_LEFT_SHIFT;
101 std::uint32_t run = core::KeyboardKey::KEY_LEFT_CONTROL;