From 50ddf2d31e9a285e1c3f61152c4d76459a14ef43 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 5 May 2025 01:46:50 +0300 Subject: [PATCH] added more noexcept --- include/omath/3d_primitives/box.hpp | 2 +- include/omath/collision/line_tracer.hpp | 8 ++++---- include/omath/engines/iw_engine/camera.hpp | 4 ++-- include/omath/engines/opengl_engine/camera.hpp | 4 ++-- include/omath/engines/opengl_engine/formulas.hpp | 12 ++++++------ include/omath/engines/source_engine/camera.hpp | 4 ++-- include/omath/engines/source_engine/formulas.hpp | 12 ++++++------ include/omath/engines/unity_engine/camera.hpp | 4 ++-- include/omath/engines/unity_engine/formulas.hpp | 12 ++++++------ .../projectile_prediction/proj_pred_engine_avx2.hpp | 6 +++--- .../proj_pred_engine_legacy.hpp | 7 ++++--- include/omath/projectile_prediction/projectile.hpp | 2 +- include/omath/projectile_prediction/target.hpp | 2 +- include/omath/projection/camera.hpp | 4 ++-- source/3d_primitives/box.cpp | 2 +- source/collision/line_tracer.cpp | 8 ++++---- source/engines/iw_engine/camera.cpp | 4 ++-- source/engines/opengl_engine/camera.cpp | 4 ++-- source/engines/opengl_engine/formulas.cpp | 12 ++++++------ source/engines/source_engine/camera.cpp | 4 ++-- source/engines/source_engine/formulas.cpp | 12 ++++++------ source/engines/unity_engine/camera.cpp | 4 ++-- source/engines/unity_engine/formulas.cpp | 12 ++++++------ .../proj_pred_engine_legacy.cpp | 11 +++++------ source/projectile_prediction/projectile.cpp | 2 +- 25 files changed, 79 insertions(+), 79 deletions(-) diff --git a/include/omath/3d_primitives/box.hpp b/include/omath/3d_primitives/box.hpp index 23a5967..49cc475 100644 --- a/include/omath/3d_primitives/box.hpp +++ b/include/omath/3d_primitives/box.hpp @@ -13,5 +13,5 @@ namespace omath::primitives [[nodiscard]] std::array>, 12> create_box(const Vector3& top, const Vector3& bottom, const Vector3& dir_forward, const Vector3& dir_right, - float ratio = 4.f); + float ratio = 4.f) noexcept; } diff --git a/include/omath/collision/line_tracer.hpp b/include/omath/collision/line_tracer.hpp index 6a655b0..a79a3cf 100644 --- a/include/omath/collision/line_tracer.hpp +++ b/include/omath/collision/line_tracer.hpp @@ -16,10 +16,10 @@ namespace omath::collision bool infinite_length = false; [[nodiscard]] - Vector3 direction_vector() const; + Vector3 direction_vector() const noexcept; [[nodiscard]] - Vector3 direction_vector_normalized() const; + Vector3 direction_vector_normalized() const noexcept; }; class LineTracer { @@ -27,11 +27,11 @@ namespace omath::collision LineTracer() = delete; [[nodiscard]] - static bool can_trace_line(const Ray& ray, const Triangle>& triangle); + static bool can_trace_line(const Ray& ray, const Triangle>& triangle) noexcept; // Realization of Möller–Trumbore intersection algorithm // https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm [[nodiscard]] - static Vector3 get_ray_hit_point(const Ray& ray, const Triangle>& triangle); + static Vector3 get_ray_hit_point(const Ray& ray, const Triangle>& triangle) noexcept; }; } // namespace omath::collision diff --git a/include/omath/engines/iw_engine/camera.hpp b/include/omath/engines/iw_engine/camera.hpp index ea59474..2f530e1 100644 --- a/include/omath/engines/iw_engine/camera.hpp +++ b/include/omath/engines/iw_engine/camera.hpp @@ -16,7 +16,7 @@ namespace omath::iw_engine void look_at(const Vector3& target) override; protected: - [[nodiscard]] Mat4X4 calc_view_matrix() const override; - [[nodiscard]] Mat4X4 calc_projection_matrix() const override; + [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override; + [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override; }; } // namespace omath::iw_engine \ No newline at end of file diff --git a/include/omath/engines/opengl_engine/camera.hpp b/include/omath/engines/opengl_engine/camera.hpp index 605ee44..b4cdd21 100644 --- a/include/omath/engines/opengl_engine/camera.hpp +++ b/include/omath/engines/opengl_engine/camera.hpp @@ -13,7 +13,7 @@ namespace omath::opengl_engine Camera(const Vector3& position, const ViewAngles& view_angles, const projection::ViewPort& view_port, const Angle& fov, float near, float far); void look_at(const Vector3& target) override; - [[nodiscard]] Mat4X4 calc_view_matrix() const override; - [[nodiscard]] Mat4X4 calc_projection_matrix() const override; + [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override; + [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override; }; } // namespace omath::opengl_engine \ No newline at end of file diff --git a/include/omath/engines/opengl_engine/formulas.hpp b/include/omath/engines/opengl_engine/formulas.hpp index dc6ae64..31714f5 100644 --- a/include/omath/engines/opengl_engine/formulas.hpp +++ b/include/omath/engines/opengl_engine/formulas.hpp @@ -8,19 +8,19 @@ namespace omath::opengl_engine { [[nodiscard]] - Vector3 forward_vector(const ViewAngles& angles); + Vector3 forward_vector(const ViewAngles& angles) noexcept; [[nodiscard]] - Vector3 right_vector(const ViewAngles& angles); + Vector3 right_vector(const ViewAngles& angles) noexcept; [[nodiscard]] - Vector3 up_vector(const ViewAngles& angles); + Vector3 up_vector(const ViewAngles& angles) noexcept; - [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin); + [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept; [[nodiscard]] - Mat4X4 rotation_matrix(const ViewAngles& angles); + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; [[nodiscard]] - Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); + Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept; } // namespace omath::opengl_engine diff --git a/include/omath/engines/source_engine/camera.hpp b/include/omath/engines/source_engine/camera.hpp index 0ea1112..cba5c43 100644 --- a/include/omath/engines/source_engine/camera.hpp +++ b/include/omath/engines/source_engine/camera.hpp @@ -15,7 +15,7 @@ namespace omath::source_engine void look_at(const Vector3& target) override; protected: - [[nodiscard]] Mat4X4 calc_view_matrix() const override; - [[nodiscard]] Mat4X4 calc_projection_matrix() const override; + [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override; + [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override; }; } // namespace omath::source_engine \ No newline at end of file diff --git a/include/omath/engines/source_engine/formulas.hpp b/include/omath/engines/source_engine/formulas.hpp index 2b651e0..a51a633 100644 --- a/include/omath/engines/source_engine/formulas.hpp +++ b/include/omath/engines/source_engine/formulas.hpp @@ -7,19 +7,19 @@ namespace omath::source_engine { [[nodiscard]] - Vector3 forward_vector(const ViewAngles& angles); + Vector3 forward_vector(const ViewAngles& angles) noexcept; [[nodiscard]] - Mat4X4 rotation_matrix(const ViewAngles& angles); + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; [[nodiscard]] - Vector3 right_vector(const ViewAngles& angles); + Vector3 right_vector(const ViewAngles& angles) noexcept; [[nodiscard]] - Vector3 up_vector(const ViewAngles& angles); + Vector3 up_vector(const ViewAngles& angles) noexcept; - [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin); + [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept; [[nodiscard]] - Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); + Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept; } // namespace omath::source_engine diff --git a/include/omath/engines/unity_engine/camera.hpp b/include/omath/engines/unity_engine/camera.hpp index 7a96757..568b2a7 100644 --- a/include/omath/engines/unity_engine/camera.hpp +++ b/include/omath/engines/unity_engine/camera.hpp @@ -16,7 +16,7 @@ namespace omath::unity_engine void look_at(const Vector3& target) override; protected: - [[nodiscard]] Mat4X4 calc_view_matrix() const override; - [[nodiscard]] Mat4X4 calc_projection_matrix() const override; + [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override; + [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override; }; } // namespace omath::unity_engine \ No newline at end of file diff --git a/include/omath/engines/unity_engine/formulas.hpp b/include/omath/engines/unity_engine/formulas.hpp index db691d5..be07136 100644 --- a/include/omath/engines/unity_engine/formulas.hpp +++ b/include/omath/engines/unity_engine/formulas.hpp @@ -8,19 +8,19 @@ namespace omath::unity_engine { [[nodiscard]] - Vector3 forward_vector(const ViewAngles& angles); + Vector3 forward_vector(const ViewAngles& angles) noexcept; [[nodiscard]] - Vector3 right_vector(const ViewAngles& angles); + Vector3 right_vector(const ViewAngles& angles) noexcept; [[nodiscard]] - Vector3 up_vector(const ViewAngles& angles); + Vector3 up_vector(const ViewAngles& angles) noexcept; - [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin); + [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept; [[nodiscard]] - Mat4X4 rotation_matrix(const ViewAngles& angles); + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; [[nodiscard]] - Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); + Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept; } // namespace omath::unity_engine diff --git a/include/omath/projectile_prediction/proj_pred_engine_avx2.hpp b/include/omath/projectile_prediction/proj_pred_engine_avx2.hpp index 85e3fc5..59d0592 100644 --- a/include/omath/projectile_prediction/proj_pred_engine_avx2.hpp +++ b/include/omath/projectile_prediction/proj_pred_engine_avx2.hpp @@ -9,8 +9,8 @@ namespace omath::projectile_prediction class ProjPredEngineAvx2 final : public ProjPredEngine { public: - [[nodiscard]] std::optional> maybe_calculate_aim_point(const Projectile& projectile, - const Target& target) const override; + [[nodiscard]] std::optional> + maybe_calculate_aim_point(const Projectile& projectile, const Target& target) const override; ProjPredEngineAvx2(float gravity_constant, float simulation_time_step, float maximum_simulation_time); ~ProjPredEngineAvx2() override = default; @@ -18,7 +18,7 @@ namespace omath::projectile_prediction private: [[nodiscard]] static std::optional calculate_pitch(const Vector3& proj_origin, const Vector3& target_pos, - float bullet_gravity, float v0, float time); + float bullet_gravity, float v0, float time) ; // We use [[maybe_unused]] here since AVX2 is not available for ARM and ARM64 CPU [[maybe_unused]] const float m_gravity_constant; diff --git a/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp b/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp index caa5cf5..44eec14 100644 --- a/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp +++ b/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp @@ -29,11 +29,12 @@ namespace omath::projectile_prediction const float m_distance_tolerance; [[nodiscard]] - std::optional maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile, - const Vector3& target_position) const; + std::optional + maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile, + const Vector3& target_position) const noexcept; [[nodiscard]] bool is_projectile_reached_target(const Vector3& target_position, const Projectile& projectile, - float pitch, float time) const; + float pitch, float time) const noexcept; }; } // namespace omath::projectile_prediction diff --git a/include/omath/projectile_prediction/projectile.hpp b/include/omath/projectile_prediction/projectile.hpp index d1188c5..ee0cafd 100644 --- a/include/omath/projectile_prediction/projectile.hpp +++ b/include/omath/projectile_prediction/projectile.hpp @@ -11,7 +11,7 @@ namespace omath::projectile_prediction { public: [[nodiscard]] - Vector3 predict_position(float pitch, float yaw, float time, float gravity) const; + Vector3 predict_position(float pitch, float yaw, float time, float gravity) const noexcept; Vector3 m_origin; float m_launch_speed{}; diff --git a/include/omath/projectile_prediction/target.hpp b/include/omath/projectile_prediction/target.hpp index 7470717..4dd38b0 100644 --- a/include/omath/projectile_prediction/target.hpp +++ b/include/omath/projectile_prediction/target.hpp @@ -11,7 +11,7 @@ namespace omath::projectile_prediction { public: [[nodiscard]] - constexpr Vector3 predict_position(const float time, const float gravity) const + constexpr Vector3 predict_position(const float time, const float gravity) const noexcept { auto predicted = m_origin + m_velocity * time; diff --git a/include/omath/projection/camera.hpp b/include/omath/projection/camera.hpp index be9a9f8..cf93a78 100644 --- a/include/omath/projection/camera.hpp +++ b/include/omath/projection/camera.hpp @@ -41,9 +41,9 @@ namespace omath::projection protected: virtual void look_at(const Vector3& target) = 0; - [[nodiscard]] virtual Mat4X4Type calc_view_matrix() const = 0; + [[nodiscard]] virtual Mat4X4Type calc_view_matrix() const noexcept = 0; - [[nodiscard]] virtual Mat4X4Type calc_projection_matrix() const = 0; + [[nodiscard]] virtual Mat4X4Type calc_projection_matrix() const noexcept = 0; [[nodiscard]] Mat4X4Type calc_view_projection_matrix() const noexcept { diff --git a/source/3d_primitives/box.cpp b/source/3d_primitives/box.cpp index 81da0bb..9c251b9 100644 --- a/source/3d_primitives/box.cpp +++ b/source/3d_primitives/box.cpp @@ -7,7 +7,7 @@ namespace omath::primitives { std::array>, 12> create_box(const Vector3& top, const Vector3& bottom, const Vector3& dir_forward, - const Vector3& dir_right, const float ratio) + const Vector3& dir_right, const float ratio) noexcept { const auto height = top.distance_to(bottom); const auto side_size = height / ratio; diff --git a/source/collision/line_tracer.cpp b/source/collision/line_tracer.cpp index e60c0de..311c99a 100644 --- a/source/collision/line_tracer.cpp +++ b/source/collision/line_tracer.cpp @@ -5,21 +5,21 @@ namespace omath::collision { - bool LineTracer::can_trace_line(const Ray& ray, const Triangle>& triangle) + bool LineTracer::can_trace_line(const Ray& ray, const Triangle>& triangle) noexcept { return get_ray_hit_point(ray, triangle) == ray.end; } - Vector3 Ray::direction_vector() const + Vector3 Ray::direction_vector() const noexcept { return end - start; } - Vector3 Ray::direction_vector_normalized() const + Vector3 Ray::direction_vector_normalized() const noexcept { return direction_vector().normalized(); } - Vector3 LineTracer::get_ray_hit_point(const Ray& ray, const Triangle>& triangle) + Vector3 LineTracer::get_ray_hit_point(const Ray& ray, const Triangle>& triangle) noexcept { constexpr float k_epsilon = std::numeric_limits::epsilon(); diff --git a/source/engines/iw_engine/camera.cpp b/source/engines/iw_engine/camera.cpp index 77aaf20..27d8ae7 100644 --- a/source/engines/iw_engine/camera.cpp +++ b/source/engines/iw_engine/camera.cpp @@ -21,11 +21,11 @@ namespace omath::iw_engine m_view_angles.yaw = -YawAngle::from_radians(std::atan2(delta.y, delta.x)); m_view_angles.roll = RollAngle::from_radians(0.f); } - Mat4X4 Camera::calc_view_matrix() const + Mat4X4 Camera::calc_view_matrix() const noexcept { return iw_engine::calc_view_matrix(m_view_angles, m_origin); } - Mat4X4 Camera::calc_projection_matrix() const + Mat4X4 Camera::calc_projection_matrix() const noexcept { return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), m_near_plane_distance, m_far_plane_distance); diff --git a/source/engines/opengl_engine/camera.cpp b/source/engines/opengl_engine/camera.cpp index 4b69410..269974c 100644 --- a/source/engines/opengl_engine/camera.cpp +++ b/source/engines/opengl_engine/camera.cpp @@ -21,11 +21,11 @@ namespace omath::opengl_engine m_view_angles.yaw = -YawAngle::from_radians(std::atan2(delta.y, delta.x)); m_view_angles.roll = RollAngle::from_radians(0.f); } - Mat4X4 Camera::calc_view_matrix() const + Mat4X4 Camera::calc_view_matrix() const noexcept { return opengl_engine::calc_view_matrix(m_view_angles, m_origin); } - Mat4X4 Camera::calc_projection_matrix() const + Mat4X4 Camera::calc_projection_matrix() const noexcept { return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), m_near_plane_distance, m_far_plane_distance); diff --git a/source/engines/opengl_engine/formulas.cpp b/source/engines/opengl_engine/formulas.cpp index 79868b5..4a14ab2 100644 --- a/source/engines/opengl_engine/formulas.cpp +++ b/source/engines/opengl_engine/formulas.cpp @@ -6,39 +6,39 @@ namespace omath::opengl_engine { - Vector3 forward_vector(const ViewAngles& angles) + Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Vector3 right_vector(const ViewAngles& angles) + Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Vector3 up_vector(const ViewAngles& angles) + Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) + Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept { return mat_camera_view(-forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin); } - Mat4X4 rotation_matrix(const ViewAngles& angles) + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_x(-angles.pitch) * mat_rotation_axis_y(-angles.yaw) * mat_rotation_axis_z(angles.roll); } Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, - const float far) + const float far) noexcept { const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f); diff --git a/source/engines/source_engine/camera.cpp b/source/engines/source_engine/camera.cpp index 3b550f5..edd4c52 100644 --- a/source/engines/source_engine/camera.cpp +++ b/source/engines/source_engine/camera.cpp @@ -22,12 +22,12 @@ namespace omath::source_engine m_view_angles.roll = RollAngle::from_radians(0.f); } - Mat4X4 Camera::calc_view_matrix() const + Mat4X4 Camera::calc_view_matrix() const noexcept { return source_engine::calc_view_matrix(m_view_angles, m_origin); } - Mat4X4 Camera::calc_projection_matrix() const + Mat4X4 Camera::calc_projection_matrix() const noexcept { return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), m_near_plane_distance, m_far_plane_distance); diff --git a/source/engines/source_engine/formulas.cpp b/source/engines/source_engine/formulas.cpp index fe869e4..326507e 100644 --- a/source/engines/source_engine/formulas.cpp +++ b/source/engines/source_engine/formulas.cpp @@ -5,38 +5,38 @@ namespace omath::source_engine { - Vector3 forward_vector(const ViewAngles& angles) + Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Mat4X4 rotation_matrix(const ViewAngles& angles) + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll); } - Vector3 right_vector(const ViewAngles& angles) + Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Vector3 up_vector(const ViewAngles& angles) + Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) + Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept { return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin); } Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, - const float far) + const float far) noexcept { // NOTE: Need magic number to fix fov calculation, since source inherit Quake proj matrix calculation constexpr auto k_multiply_factor = 0.75f; diff --git a/source/engines/unity_engine/camera.cpp b/source/engines/unity_engine/camera.cpp index f06304d..5455c76 100644 --- a/source/engines/unity_engine/camera.cpp +++ b/source/engines/unity_engine/camera.cpp @@ -15,11 +15,11 @@ namespace omath::unity_engine { throw std::runtime_error("Not implemented"); } - Mat4X4 Camera::calc_view_matrix() const + Mat4X4 Camera::calc_view_matrix() const noexcept { return unity_engine::calc_view_matrix(m_view_angles, m_origin); } - Mat4X4 Camera::calc_projection_matrix() const + Mat4X4 Camera::calc_projection_matrix() const noexcept { return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), m_near_plane_distance, m_far_plane_distance); diff --git a/source/engines/unity_engine/formulas.cpp b/source/engines/unity_engine/formulas.cpp index ed6579f..4560e27 100644 --- a/source/engines/unity_engine/formulas.cpp +++ b/source/engines/unity_engine/formulas.cpp @@ -5,37 +5,37 @@ namespace omath::unity_engine { - Vector3 forward_vector(const ViewAngles& angles) + Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Vector3 right_vector(const ViewAngles& angles) + Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Vector3 up_vector(const ViewAngles& angles) + Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) + Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept { return mat_camera_view(forward_vector(angles), -right_vector(angles), up_vector(angles), cam_origin); } - Mat4X4 rotation_matrix(const ViewAngles& angles) + Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_x(angles.pitch) * mat_rotation_axis_y(angles.yaw) * mat_rotation_axis_z(angles.roll); } Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, - const float far) + const float far) noexcept { const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f); diff --git a/source/projectile_prediction/proj_pred_engine_legacy.cpp b/source/projectile_prediction/proj_pred_engine_legacy.cpp index 5d3c041..b2f5c7d 100644 --- a/source/projectile_prediction/proj_pred_engine_legacy.cpp +++ b/source/projectile_prediction/proj_pred_engine_legacy.cpp @@ -18,8 +18,8 @@ namespace omath::projectile_prediction { const auto predicted_target_position = target.predict_position(time, m_gravity_constant); - const auto projectile_pitch - = maybe_calculate_projectile_launch_pitch_angle(projectile, predicted_target_position); + const auto projectile_pitch = + maybe_calculate_projectile_launch_pitch_angle(projectile, predicted_target_position); if (!projectile_pitch.has_value()) [[unlikely]] continue; @@ -35,9 +35,8 @@ namespace omath::projectile_prediction return std::nullopt; } - std::optional - ProjPredEngineLegacy::maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile, - const Vector3& target_position) const + std::optional ProjPredEngineLegacy::maybe_calculate_projectile_launch_pitch_angle( + const Projectile& projectile, const Vector3& target_position) const noexcept { const auto bullet_gravity = m_gravity_constant * projectile.m_gravity_scale; const auto delta = target_position - projectile.m_origin; @@ -60,7 +59,7 @@ namespace omath::projectile_prediction bool ProjPredEngineLegacy::is_projectile_reached_target(const Vector3& target_position, const Projectile& projectile, const float pitch, - const float time) const + const float time) const noexcept { const auto yaw = projectile.m_origin.view_angle_to(target_position).y; const auto projectile_position = projectile.predict_position(pitch, yaw, time, m_gravity_constant); diff --git a/source/projectile_prediction/projectile.cpp b/source/projectile_prediction/projectile.cpp index 30202db..c37151f 100644 --- a/source/projectile_prediction/projectile.cpp +++ b/source/projectile_prediction/projectile.cpp @@ -8,7 +8,7 @@ namespace omath::projectile_prediction { Vector3 Projectile::predict_position(const float pitch, const float yaw, const float time, - const float gravity) const + const float gravity) const noexcept { auto current_pos = m_origin + source_engine::forward_vector({source_engine::PitchAngle::from_degrees(-pitch),