LCOV - code coverage report
Current view: top level - editor/src - camera.hpp (source / functions) Coverage Total Hit
Test: Wren Engine Coverage Lines: 0.0 % 15 0
Test Date: 1980-01-01 00:00:00 Functions: 0.0 % 5 0

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <wren/math/geometry.hpp>
       4              : #include <wren/math/matrix.hpp>
       5              : #include <wren/math/vector.hpp>
       6              : #include <wren/scene/components/transform.hpp>
       7              : 
       8              : namespace editor {
       9              : class Camera {
      10              :  public:
      11              :   Camera() = default;
      12            0 :   Camera(float fov, float aspect_ratio, float z_near, float z_far)
      13            0 :       : fov_(fov), aspect_ratio_(aspect_ratio), z_near_(z_near), z_far_(z_far) {
      14            0 :     transform_.position.z(-5);
      15            0 :     update_projection_matrix();
      16            0 :   }
      17              : 
      18              :   static auto create();
      19              : 
      20            0 :   auto aspect(float aspect) {
      21            0 :     aspect_ratio_ = aspect;
      22            0 :     update_projection_matrix();
      23            0 :   }
      24              :   [[nodiscard]] auto aspect() const { return aspect_ratio_; }
      25              : 
      26            0 :   [[nodiscard]] auto projection() const { return projection_; }
      27              : 
      28            0 :   [[nodiscard]] auto transform() const { return transform_; }
      29              : 
      30              :  private:
      31            0 :   void update_projection_matrix() {
      32            0 :     projection_ = wren::math::perspective(wren::math::radians(fov_),
      33            0 :                                           aspect_ratio_, z_near_, z_far_);
      34            0 :   }
      35              : 
      36              :   wren::scene::components::Transform transform_;
      37              : 
      38              :   float fov_{};
      39              :   float aspect_ratio_{};
      40              :   float z_near_{};
      41              :   float z_far_{};
      42              : 
      43              :   wren::math::Mat4f projection_;
      44              : };
      45              : 
      46              : }  // namespace editor
        

Generated by: LCOV version 2.3.2-1