//
// Created by slinky on 5/3/26.
//

#ifndef B_ENGINE_CAMERA_H
#define B_ENGINE_CAMERA_H

#include <glm/glm.hpp>

constexpr float MAX_PITCH = 89.f;
constexpr float MIN_PITCH = -89.f;

constexpr glm::vec3 WORLD_UP = {0.0f, 1.0f, 0.0f};

class Camera {
public:
    Camera() = default;
    Camera(const glm::vec3 &pos, float pitch, float yaw, float aspectRatio);

    [[nodiscard]] const glm::mat4&  projection() const;
    [[nodiscard]] const glm::mat4&  view() const;
    [[nodiscard]] const glm::vec3&  position() const;
    [[nodiscard]] glm::vec3  front() const;
    [[nodiscard]] glm::vec3  up() const;
    [[nodiscard]] glm::vec3  right() const;
    [[nodiscard]] float aspect_ratio() const;

    void update_aspect_ratio(float aspectRatio);
    void rotate_yaw(float offset);
    void rotate_pitch(float offset);

    void translate(const glm::vec3& direction);
private:
    void update_camera_vectors();
    void update_projection();
    void update_view();

    glm::vec3 _position{};

    glm::vec3 _front{};
    glm::vec3 _up{};
    glm::vec3 _right{};

    glm::mat4 _view{};
    glm::mat4 _projection{};

    float _yaw = 0;
    float _pitch = 0;

    float _aspectRatio = 0;

    float _sensitivity = 0.1f;
};


#endif //B_ENGINE_CAMERA_H