aboutsummaryrefslogtreecommitdiff
path: root/src/Core/Camera.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Camera.h')
-rw-r--r--src/Core/Camera.h193
1 files changed, 97 insertions, 96 deletions
diff --git a/src/Core/Camera.h b/src/Core/Camera.h
index a9aec2a..c997c35 100644
--- a/src/Core/Camera.h
+++ b/src/Core/Camera.h
@@ -16,115 +16,116 @@ namespace Donut
class Camera
{
public:
- Camera(float fov = 45.0f, float aspectRatio = 16.0f / 9.0f,
- float nearPlane = 0.1f, float farPlane = 100.0f);
+ Camera(float fov = 45.0f, float aspect_ratio = 16.0f / 9.0f,
+ float near_plane = 0.1f, float far_plane = 100.0f);
~Camera() = default;
- void SetPosition(const glm::vec3& position) { m_Position = position; RecalculateViewMatrix(); }
- void SetRotation(const glm::vec3& rotation) { m_Rotation = rotation; RecalculateViewMatrix(); }
-
- const glm::vec3& GetPosition() const { return m_Position; }
- const glm::vec3& GetRotation() const { return m_Rotation; }
-
- glm::vec3 GetForwardDirection() const;
- glm::vec3 GetRightDirection() const;
- glm::vec3 GetUpDirection() const;
+ auto set_position(const glm::vec3& position) -> void { m_position = position; recalculate_view_matrix(); }
+ auto set_rotation(const glm::vec3& rotation) -> void { m_rotation = rotation; recalculate_view_matrix(); }
- const glm::mat4& GetProjectionMatrix() const { return m_ProjectionMatrix; }
- const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; }
- const glm::mat4& GetViewProjectionMatrix() const { return m_ViewProjectionMatrix; }
+ auto get_position() const -> const glm::vec3& { return m_position; }
+ auto get_rotation() const -> const glm::vec3& { return m_rotation; }
- void SetProjection(float fov, float aspectRatio, float nearPlane, float farPlane);
- void OnMouseMove(float xOffset, float yOffset, bool constrainPitch = true);
-
- void MoveForward(float deltaTime);
- void MoveBackward(float deltaTime);
- void MoveRight(float deltaTime);
- void MoveLeft(float deltaTime);
- void MoveUp(float deltaTime);
- void MoveDown(float deltaTime);
+ auto get_forward_direction() const -> glm::vec3;
+ auto get_right_direction() const -> glm::vec3;
+ auto get_up_direction() const -> glm::vec3;
- void SetMouseSensitivity(float sensitivity) { m_MouseSensitivity = sensitivity; }
- float GetMouseSensitivity() const { return m_MouseSensitivity; }
+ auto get_projection_matrix() const -> const glm::mat4& { return m_projection_matrix; }
+ auto get_view_matrix() const -> const glm::mat4& { return m_view_matrix; }
+ auto get_view_projection_matrix() const -> const glm::mat4& { return m_view_projection_matrix; }
- void SetMovementSpeed(float speed) { m_MovementSpeed = speed; }
- float GetMovementSpeed() const { return m_MovementSpeed; }
+ auto set_projection(float fov, float aspect_ratio, float near_plane, float far_plane) -> void;
+ auto on_mouse_move(float x_offset, float y_offset, bool constrain_pitch = true) -> void;
- void SetOrbitalTarget(const glm::vec3& target) { m_OrbitalTarget = target; }
- const glm::vec3& GetOrbitalTarget() const { return m_OrbitalTarget; }
-
- void SetOrbitalRadius(double radius) { m_OrbitalRadius = radius; }
- double GetOrbitalRadius() const { return m_OrbitalRadius; }
-
- void SetOrbitalLimits(double minRadius, double maxRadius)
- {
- m_OrbitalMinRadius = minRadius;
- m_OrbitalMaxRadius = maxRadius;
+ auto move_forward(float delta_time) -> void;
+ auto move_backward(float delta_time) -> void;
+ auto move_right(float delta_time) -> void;
+ auto move_left(float delta_time) -> void;
+ auto move_up(float delta_time) -> void;
+ auto move_down(float delta_time) -> void;
+
+ auto set_mouse_sensitivity(float sensitivity) -> void { m_mouse_sensitivity = sensitivity; }
+ auto get_mouse_sensitivity() const -> float { return m_mouse_sensitivity; }
+
+ auto set_movement_speed(float speed) -> void { m_movement_speed = speed; }
+ auto get_movement_speed() const -> float { return m_movement_speed; }
+
+ auto set_orbital_target(const glm::vec3& target) -> void { m_orbital_target = target; }
+ auto get_orbital_target() const -> const glm::vec3& { return m_orbital_target; }
+
+ auto set_orbital_radius(double radius) -> void { m_orbital_radius = radius; }
+ auto get_orbital_radius() const -> double { return m_orbital_radius; }
+
+ auto set_orbital_limits(double min_radius, double max_radius) -> void
+ {
+ m_orbital_min_radius = min_radius;
+ m_orbital_max_radius = max_radius;
}
-
- void SetOrbitalSpeed(float speed) { m_OrbitalSpeed = speed; }
- float GetOrbitalSpeed() const { return m_OrbitalSpeed; }
-
- void SetZoomSpeed(double speed) { m_ZoomSpeed = speed; }
- double GetZoomSpeed() const { return m_ZoomSpeed; }
-
- void SetAzimuth(float azimuth) { m_Azimuth = azimuth; }
- float GetAzimuth() const { return m_Azimuth; }
-
- void SetElevation(float elevation) { m_Elevation = elevation; }
- float GetElevation() const { return m_Elevation; }
-
- glm::vec3 GetOrbitalPosition() const;
- void UpdateOrbital();
- void ProcessOrbitalMouseMove(double x, double y);
- void ProcessOrbitalMouseButton(int button, int action, int mods);
- void ProcessOrbitalScroll(double xoffset, double yoffset);
-
- void SetCameraMode(CameraMode mode) { m_CameraMode = mode; }
- CameraMode GetCameraMode() const { return m_CameraMode; }
-
- bool IsDragging() const { return m_Dragging; }
- bool IsPanning() const { return m_Panning; }
- bool IsMoving() const { return m_Moving; }
- double GetLastX() const { return m_LastX; }
- double GetLastY() const { return m_LastY; }
+
+ auto set_orbital_speed(float speed) -> void { m_orbital_speed = speed; }
+ auto get_orbital_speed() const -> float { return m_orbital_speed; }
+
+ auto set_zoom_speed(double speed) -> void { m_zoom_speed = speed; }
+ auto get_zoom_speed() const -> double { return m_zoom_speed; }
+
+ auto set_azimuth(float azimuth) -> void { m_azimuth = azimuth; }
+ auto get_azimuth() const -> float { return m_azimuth; }
+
+ auto set_elevation(float elevation) -> void { m_elevation = elevation; }
+ auto get_elevation() const -> float { return m_elevation; }
+
+ auto get_orbital_position() const -> glm::vec3;
+ auto update_orbital() -> void;
+ auto process_orbital_mouse_move(double x, double y) -> void;
+ auto process_orbital_mouse_button(int button, int action, int mods) -> void;
+ auto process_orbital_scroll(double x_offset, double y_offset) -> void;
+
+ auto set_camera_mode(CameraMode mode) -> void { m_camera_mode = mode; }
+ auto get_camera_mode() const -> CameraMode { return m_camera_mode; }
+
+ auto is_dragging() const -> bool { return m_dragging; }
+ auto is_panning() const -> bool { return m_panning; }
+ auto is_moving() const -> bool { return m_moving; }
+ auto get_last_x() const -> double { return m_last_x; }
+ auto get_last_y() const -> double { return m_last_y; }
private:
- void RecalculateViewMatrix();
- void RecalculateProjectionMatrix();
+ auto recalculate_view_matrix() -> void;
+ auto recalculate_projection_matrix() -> void;
+
private:
- CameraMode m_CameraMode = CameraMode::FPS;
-
- glm::mat4 m_ProjectionMatrix;
- glm::mat4 m_ViewMatrix;
- glm::mat4 m_ViewProjectionMatrix;
+ CameraMode m_camera_mode = CameraMode::FPS;
+
+ glm::mat4 m_projection_matrix;
+ glm::mat4 m_view_matrix;
+ glm::mat4 m_view_projection_matrix;
+
+ glm::vec3 m_position = { 0.0f, 0.0f, 3.0f };
+ glm::vec3 m_rotation = { 0.0f, 0.0f, 0.0f };
- glm::vec3 m_Position = { 0.0f, 0.0f, 3.0f };
- glm::vec3 m_Rotation = { 0.0f, 0.0f, 0.0f };
+ float m_fov = 45.0f;
+ float m_aspect_ratio = 16.0f / 9.0f;
+ float m_near_plane = 0.1f;
+ float m_far_plane = 100.0f;
- float m_FOV = 45.0f;
- float m_AspectRatio = 16.0f / 9.0f;
- float m_NearPlane = 0.1f;
- float m_FarPlane = 100.0f;
+ float m_mouse_sensitivity = 0.1f;
+ float m_movement_speed = 5.0f;
+ bool m_first_mouse = true;
+ float m_last_x = 0.0f;
+ float m_last_y = 0.0f;
- float m_MouseSensitivity = 0.1f;
- float m_MovementSpeed = 5.0f;
- bool m_FirstMouse = true;
- float m_LastX = 0.0f;
- float m_LastY = 0.0f;
-
- glm::vec3 m_OrbitalTarget = glm::vec3(0.0f, 0.0f, 0.0f);
- double m_OrbitalRadius = 6.34194e10;
- double m_OrbitalMinRadius = 1e10;
- double m_OrbitalMaxRadius = 1e12;
- float m_Azimuth = 0.0f;
- float m_Elevation = static_cast<float>(std::numbers::pi) / 2.0f;
- float m_OrbitalSpeed = 0.01f;
- double m_ZoomSpeed = 25e9f;
- bool m_Dragging = false;
- bool m_Panning = false;
- bool m_Moving = false;
- double m_LastX_Orbital = 0.0;
- double m_LastY_Orbital = 0.0;
+ glm::vec3 m_orbital_target = glm::vec3(0.0f, 0.0f, 0.0f);
+ double m_orbital_radius = 6.34194e10;
+ double m_orbital_min_radius = 1e10;
+ double m_orbital_max_radius = 1e12;
+ float m_azimuth = 0.0f;
+ float m_elevation = static_cast<float>(std::numbers::pi) / 2.0f;
+ float m_orbital_speed = 0.01f;
+ double m_zoom_speed = 25e9f;
+ bool m_dragging = false;
+ bool m_panning = false;
+ bool m_moving = false;
+ double m_last_x_orbital = 0.0;
+ double m_last_y_orbital = 0.0;
};
}