From 9005c02499cffbd9b735302399643239457cac48 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 22 Sep 2025 02:08:58 +0300 Subject: [PATCH] opengl fix --- .../engines/opengl_engine/traits/pred_engine_trait.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/omath/engines/opengl_engine/traits/pred_engine_trait.hpp b/include/omath/engines/opengl_engine/traits/pred_engine_trait.hpp index 9c014ff..ab2e607 100644 --- a/include/omath/engines/opengl_engine/traits/pred_engine_trait.hpp +++ b/include/omath/engines/opengl_engine/traits/pred_engine_trait.hpp @@ -62,17 +62,15 @@ namespace omath::opengl_engine [[nodiscard]] static float calc_direct_pitch_angle(const Vector3& origin, const Vector3& view_to) noexcept { - const auto distance = origin.distance_to(view_to); - const auto delta = view_to - origin; - - return angles::radians_to_degrees(std::asin(delta.y / distance)); + const auto direction = (view_to - origin).normalized(); + return angles::radians_to_degrees(std::asin(direction.y)); } [[nodiscard]] static float calc_direct_yaw_angle(const Vector3& origin, const Vector3& view_to) noexcept { - const auto delta = view_to - origin; + const auto direction = (view_to - origin).normalized(); - return angles::radians_to_degrees(std::atan2(delta.z, delta.x)); + return angles::radians_to_degrees(-std::atan2(direction.x, -direction.z)); }; }; } // namespace omath::opengl_engine