mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
Fixes namespace and angle calculations
Corrects namespace naming from unity_engine to unreal_engine. Adjusts projectile prediction and angle calculations for accuracy in Unreal Engine environments.
This commit is contained in:
@@ -10,4 +10,4 @@
|
|||||||
namespace omath::unreal_engine
|
namespace omath::unreal_engine
|
||||||
{
|
{
|
||||||
using Camera = projection::Camera<Mat4X4, ViewAngles, CameraTrait>;
|
using Camera = projection::Camera<Mat4X4, ViewAngles, CameraTrait>;
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
@@ -23,4 +23,4 @@ namespace omath::unreal_engine
|
|||||||
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||||
|
|
||||||
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ namespace omath::unreal_engine
|
|||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
|
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ namespace omath::unreal_engine
|
|||||||
float near, float far) noexcept;
|
float near, float far) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
@@ -55,7 +55,7 @@ namespace omath::unreal_engine
|
|||||||
const auto delta2d = calc_vector_2d_distance(predicted_target_position - projectile.m_origin);
|
const auto delta2d = calc_vector_2d_distance(predicted_target_position - projectile.m_origin);
|
||||||
const auto height = delta2d * std::tan(angles::degrees_to_radians(projectile_pitch.value()));
|
const auto height = delta2d * std::tan(angles::degrees_to_radians(projectile_pitch.value()));
|
||||||
|
|
||||||
return {predicted_target_position.x, predicted_target_position.y + height, projectile.m_origin.z};
|
return {predicted_target_position.x, predicted_target_position.y, projectile.m_origin.z + height};
|
||||||
}
|
}
|
||||||
// Due to specification of maybe_calculate_projectile_launch_pitch_angle, pitch angle must be:
|
// Due to specification of maybe_calculate_projectile_launch_pitch_angle, pitch angle must be:
|
||||||
// 89 look up, -89 look down
|
// 89 look up, -89 look down
|
||||||
@@ -65,14 +65,14 @@ namespace omath::unreal_engine
|
|||||||
const auto distance = origin.distance_to(view_to);
|
const auto distance = origin.distance_to(view_to);
|
||||||
const auto delta = view_to - origin;
|
const auto delta = view_to - origin;
|
||||||
|
|
||||||
return angles::radians_to_degrees(std::asin(delta.y / distance));
|
return angles::radians_to_degrees(std::asin(delta.z / distance));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static float calc_direct_yaw_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_yaw_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto delta = view_to - origin;
|
const auto delta = view_to - origin;
|
||||||
|
|
||||||
return angles::radians_to_degrees(std::atan2(delta.z, delta.x));
|
return angles::radians_to_degrees(std::atan2(delta.y, delta.x));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
|
|||||||
@@ -46,4 +46,4 @@ namespace omath::unreal_engine
|
|||||||
{0, 0, -1.f, 0},
|
{0, 0, -1.f, 0},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ namespace omath::unreal_engine
|
|||||||
{
|
{
|
||||||
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far);
|
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near, far);
|
||||||
}
|
}
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unreal_engine
|
||||||
Reference in New Issue
Block a user