diff options
Diffstat (limited to 'src/core/camera.cpp')
| -rw-r--r-- | src/core/camera.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/core/camera.cpp b/src/core/camera.cpp index 9c2b061..35b7a2f 100644 --- a/src/core/camera.cpp +++ b/src/core/camera.cpp @@ -12,7 +12,7 @@ namespace Donut recalculate_view_matrix(); } - void Camera::set_projection(float fov, float aspect_ratio, float near_plane, float far_plane) + auto Camera::set_projection(float fov, float aspect_ratio, float near_plane, float far_plane) -> void { m_fov = fov; m_aspect_ratio = aspect_ratio; @@ -21,13 +21,13 @@ namespace Donut recalculate_projection_matrix(); } - void Camera::recalculate_projection_matrix() + auto Camera::recalculate_projection_matrix() -> void { m_projection_matrix = glm::perspective(glm::radians(m_fov), m_aspect_ratio, m_near_plane, m_far_plane); m_view_projection_matrix = m_projection_matrix * m_view_matrix; } - void Camera::recalculate_view_matrix() + auto Camera::recalculate_view_matrix() -> void { if (m_camera_mode == CameraMode::FPS) { @@ -45,7 +45,7 @@ namespace Donut glm::vec3 right = glm::normalize(glm::cross(front, world_up)); glm::vec3 up = glm::normalize(glm::cross(right, front)); - m_view_matrix = glm::lookAt(m_position, m_position + front, up); + m_view_matrix = glm::lookAt(m_position, m_position + front, up); m_view_projection_matrix = m_projection_matrix * m_view_matrix; } else if (m_camera_mode == CameraMode::Orbital) @@ -53,13 +53,13 @@ namespace Donut glm::vec3 position = get_orbital_position(); glm::vec3 target = m_orbital_target; glm::vec3 up(0.0f, 1.0f, 0.0f); - + m_view_matrix = glm::lookAt(position, target, up); m_view_projection_matrix = m_projection_matrix * m_view_matrix; } } - glm::vec3 Camera::get_forward_direction() const + auto Camera::get_forward_direction() const -> glm::vec3 { float pitch = glm::radians(m_rotation.x); float yaw = glm::radians(m_rotation.y); @@ -72,18 +72,18 @@ namespace Donut return glm::normalize(direction); } - glm::vec3 Camera::get_right_direction() const + auto Camera::get_right_direction() const -> glm::vec3 { glm::vec3 world_up(0.0f, 1.0f, 0.0f); return glm::normalize(glm::cross(get_forward_direction(), world_up)); } - glm::vec3 Camera::get_up_direction() const + auto Camera::get_up_direction() const -> glm::vec3 { return glm::normalize(glm::cross(get_right_direction(), get_forward_direction())); } - void Camera::on_mouse_move(float x_offset, float y_offset, bool constrain_pitch) + auto Camera::on_mouse_move(float x_offset, float y_offset, bool constrain_pitch) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -105,7 +105,7 @@ namespace Donut } } - void Camera::move_forward(float delta_time) + auto Camera::move_forward(float delta_time) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -114,7 +114,7 @@ namespace Donut } } - void Camera::move_backward(float delta_time) + auto Camera::move_backward(float delta_time) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -123,7 +123,7 @@ namespace Donut } } - void Camera::move_right(float delta_time) + auto Camera::move_right(float delta_time) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -132,7 +132,7 @@ namespace Donut } } - void Camera::move_left(float delta_time) + auto Camera::move_left(float delta_time) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -141,7 +141,7 @@ namespace Donut } } - void Camera::move_up(float delta_time) + auto Camera::move_up(float delta_time) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -151,7 +151,7 @@ namespace Donut } } - void Camera::move_down(float delta_time) + auto Camera::move_down(float delta_time) -> void { if (m_camera_mode == CameraMode::FPS) { @@ -161,7 +161,7 @@ namespace Donut } } - glm::vec3 Camera::get_orbital_position() const + auto Camera::get_orbital_position() const -> glm::vec3 { float clamped_elevation = glm::clamp(m_elevation, 0.01f, float(std::numbers::pi) - 0.01f); return glm::vec3 @@ -172,7 +172,7 @@ namespace Donut ); } - void Camera::update_orbital() + auto Camera::update_orbital() -> void { m_orbital_target = glm::vec3(0.0f, 0.0f, 0.0f); if (m_dragging || m_panning) @@ -182,24 +182,24 @@ namespace Donut recalculate_view_matrix(); } - void Camera::process_orbital_mouse_move(double x, double y) + auto Camera::process_orbital_mouse_move(double x, double y) -> void { if (m_dragging && !m_panning) { float dx = float(x - m_last_x_orbital); float dy = float(y - m_last_y_orbital); - + m_azimuth += dx * m_orbital_speed; m_elevation -= dy * m_orbital_speed; m_elevation = glm::clamp(m_elevation, 0.01f, float(std::numbers::pi) - 0.01f); } - + m_last_x_orbital = x; m_last_y_orbital = y; update_orbital(); } - void Camera::process_orbital_mouse_button(int button, int action, int mods) + auto Camera::process_orbital_mouse_button(int button, int action, int mods) -> void { if (button == GLFW_MOUSE_BUTTON_LEFT) { @@ -216,7 +216,7 @@ namespace Donut } } - void Camera::process_orbital_scroll(double x_offset, double y_offset) + auto Camera::process_orbital_scroll(double x_offset, double y_offset) -> void { m_orbital_radius -= y_offset * m_zoom_speed; m_orbital_radius = glm::clamp(m_orbital_radius, m_orbital_min_radius, m_orbital_max_radius); |
