From 3eb9daf10b5dd930619fe68bb5747bf07c423844 Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 23 Apr 2026 02:05:54 +0300 Subject: [PATCH] +90 up -90 down fix for camera view angles --- source/engines/unreal_engine/formulas.cpp | 2 +- source/engines/unreal_engine/traits/camera_trait.cpp | 2 +- tests/engines/unit_test_unreal_engine.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/engines/unreal_engine/formulas.cpp b/source/engines/unreal_engine/formulas.cpp index 0e40b8a..1890a13 100644 --- a/source/engines/unreal_engine/formulas.cpp +++ b/source/engines/unreal_engine/formulas.cpp @@ -32,7 +32,7 @@ namespace omath::unreal_engine { return mat_rotation_axis_x(angles.roll) * mat_rotation_axis_z(angles.yaw) - * mat_rotation_axis_y(angles.pitch); + * mat_rotation_axis_y(-angles.pitch); } Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, const float far, const NDCDepthRange ndc_depth_range) noexcept diff --git a/source/engines/unreal_engine/traits/camera_trait.cpp b/source/engines/unreal_engine/traits/camera_trait.cpp index 0d1d9e1..b676449 100644 --- a/source/engines/unreal_engine/traits/camera_trait.cpp +++ b/source/engines/unreal_engine/traits/camera_trait.cpp @@ -10,7 +10,7 @@ namespace omath::unreal_engine { const auto direction = (look_at - cam_origin).normalized(); - return {PitchAngle::from_radians(-std::asin(direction.z)), + return {PitchAngle::from_radians(std::asin(direction.z)), YawAngle::from_radians(std::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)}; } Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept diff --git a/tests/engines/unit_test_unreal_engine.cpp b/tests/engines/unit_test_unreal_engine.cpp index e831978..2ad6819 100644 --- a/tests/engines/unit_test_unreal_engine.cpp +++ b/tests/engines/unit_test_unreal_engine.cpp @@ -32,7 +32,7 @@ TEST(unit_test_unreal_engine, ForwardVectorRotationPitch) { omath::unreal_engine::ViewAngles angles; - angles.pitch = omath::unreal_engine::PitchAngle::from_degrees(-90.f); + angles.pitch = omath::unreal_engine::PitchAngle::from_degrees(90.f); const auto forward = omath::unreal_engine::forward_vector(angles); EXPECT_NEAR(forward.x, omath::unreal_engine::k_abs_up.x, 0.00001f);