mirror of
https://github.com/orange-cpp/omath.git
synced 2026-06-16 04:04:34 +00:00
added even more missing nodiscard messages
This commit is contained in:
@@ -11,7 +11,7 @@ namespace omath::cry_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -20,12 +20,12 @@ namespace omath::cry_engine
|
|||||||
YawAngle::from_radians(-internal::atan2(direction.x, direction.y)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(-internal::atan2(direction.x, direction.y)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return cry_engine::calc_view_matrix(angles, cam_origin);
|
return cry_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::cry_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return cry_engine::rotation_matrix(rotation);
|
return cry_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace omath::cry_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
||||||
const float pitch, const float yaw,
|
const float pitch, const float yaw,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
@@ -25,7 +26,7 @@ namespace omath::cry_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -36,19 +37,19 @@ namespace omath::cry_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.z;
|
return vec.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -60,13 +61,13 @@ namespace omath::cry_engine
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
return angles::radians_to_degrees(std::asin(direction.z));
|
return angles::radians_to_degrees(std::asin(direction.z));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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 direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::frostbite_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::frostbite_engine
|
|||||||
YawAngle::from_radians(internal::atan2(direction.x, direction.z)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(internal::atan2(direction.x, direction.z)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return frostbite_engine::calc_view_matrix(angles, cam_origin);
|
return frostbite_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::frostbite_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return frostbite_engine::rotation_matrix(rotation);
|
return frostbite_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace omath::frostbite_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
||||||
const float pitch, const float yaw,
|
const float pitch, const float yaw,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
@@ -25,7 +26,7 @@ namespace omath::frostbite_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -36,19 +37,19 @@ namespace omath::frostbite_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.y;
|
return vec.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -60,13 +61,13 @@ namespace omath::frostbite_engine
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
return angles::radians_to_degrees(std::asin(direction.y));
|
return angles::radians_to_degrees(std::asin(direction.y));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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 direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::iw_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::iw_engine
|
|||||||
YawAngle::from_radians(internal::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(internal::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return iw_engine::calc_view_matrix(angles, cam_origin);
|
return iw_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::iw_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return iw_engine::rotation_matrix(rotation);
|
return iw_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace omath::iw_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
||||||
const float pitch, const float yaw,
|
const float pitch, const float yaw,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
@@ -26,7 +27,7 @@ namespace omath::iw_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -37,19 +38,19 @@ namespace omath::iw_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.z;
|
return vec.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -61,7 +62,7 @@ namespace omath::iw_engine
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto distance = origin.distance_to(view_to);
|
const auto distance = origin.distance_to(view_to);
|
||||||
@@ -69,7 +70,7 @@ namespace omath::iw_engine
|
|||||||
|
|
||||||
return angles::radians_to_degrees(std::asin(delta.z / distance));
|
return angles::radians_to_degrees(std::asin(delta.z / distance));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::opengl_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::opengl_engine
|
|||||||
YawAngle::from_radians(-internal::atan2(direction.x, -direction.z)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(-internal::atan2(direction.x, -direction.z)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return opengl_engine::calc_view_matrix(angles, cam_origin);
|
return opengl_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::opengl_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return opengl_engine::rotation_matrix(rotation);
|
return opengl_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace omath::opengl_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
||||||
const float pitch, const float yaw,
|
const float pitch, const float yaw,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
@@ -25,7 +26,7 @@ namespace omath::opengl_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -36,19 +37,19 @@ namespace omath::opengl_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.y;
|
return vec.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -60,13 +61,13 @@ namespace omath::opengl_engine
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
return angles::radians_to_degrees(std::asin(direction.y));
|
return angles::radians_to_degrees(std::asin(direction.y));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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 direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::rage_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::rage_engine
|
|||||||
YawAngle::from_radians(-internal::atan2(direction.x, direction.y)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(-internal::atan2(direction.x, direction.y)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return rage_engine::calc_view_matrix(angles, cam_origin);
|
return rage_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace omath::rage_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return rage_engine::rotation_matrix(rotation);
|
return rage_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace omath::rage_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float>
|
constexpr static Vector3<float>
|
||||||
predict_projectile_position(const projectile_prediction::Projectile<float>& projectile, const float pitch,
|
predict_projectile_position(const projectile_prediction::Projectile<float>& projectile, const float pitch,
|
||||||
const float yaw, const float time, const float gravity) noexcept
|
const float yaw, const float time, const float gravity) noexcept
|
||||||
@@ -26,7 +27,7 @@ namespace omath::rage_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -37,19 +38,19 @@ namespace omath::rage_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.z;
|
return vec.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -59,13 +60,13 @@ namespace omath::rage_engine
|
|||||||
|
|
||||||
return {predicted_target_position.x, predicted_target_position.y, projectile.m_origin.z + height};
|
return {predicted_target_position.x, predicted_target_position.y, projectile.m_origin.z + height};
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
return angles::radians_to_degrees(std::asin(direction.z));
|
return angles::radians_to_degrees(std::asin(direction.z));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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 direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::source_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::source_engine
|
|||||||
YawAngle::from_radians(internal::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(internal::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return source_engine::calc_view_matrix(angles, cam_origin);
|
return source_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::source_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return source_engine::rotation_matrix(rotation);
|
return source_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace omath::source_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
||||||
const float pitch, const float yaw,
|
const float pitch, const float yaw,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
@@ -26,7 +27,7 @@ namespace omath::source_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -37,19 +38,19 @@ namespace omath::source_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
return std::sqrt(delta.x * delta.x + delta.y * delta.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.z;
|
return vec.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -61,7 +62,7 @@ namespace omath::source_engine
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto distance = origin.distance_to(view_to);
|
const auto distance = origin.distance_to(view_to);
|
||||||
@@ -69,7 +70,7 @@ namespace omath::source_engine
|
|||||||
|
|
||||||
return angles::radians_to_degrees(std::asin(delta.z / distance));
|
return angles::radians_to_degrees(std::asin(delta.z / distance));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::unity_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
|
||||||
const Vector3<float>& look_at) noexcept
|
const Vector3<float>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::unity_engine
|
|||||||
YawAngle::from_radians(internal::atan2(direction.x, direction.z)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(internal::atan2(direction.x, direction.z)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return unity_engine::calc_view_matrix(angles, cam_origin);
|
return unity_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const float near_plane,
|
const projection::ViewPort& view_port, const float near_plane,
|
||||||
const float far_plane,
|
const float far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::unity_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return unity_engine::rotation_matrix(rotation);
|
return unity_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace omath::unity_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
constexpr static Vector3<float> predict_projectile_position(const projectile_prediction::Projectile<float>& projectile,
|
||||||
const float pitch, const float yaw,
|
const float pitch, const float yaw,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
@@ -25,7 +26,7 @@ namespace omath::unity_engine
|
|||||||
|
|
||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
static constexpr Vector3<float> predict_target_position(const projectile_prediction::Target<float>& target,
|
||||||
const float time, const float gravity) noexcept
|
const float time, const float gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -36,19 +37,19 @@ namespace omath::unity_engine
|
|||||||
|
|
||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
static float calc_vector_2d_distance(const Vector3<float>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
constexpr static float get_vector_height_coordinate(const Vector3<float>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.y;
|
return vec.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
static Vector3<float> calc_viewpoint_from_angles(const projectile_prediction::Projectile<float>& projectile,
|
||||||
Vector3<float> predicted_target_position,
|
Vector3<float> predicted_target_position,
|
||||||
const std::optional<float> projectile_pitch) noexcept
|
const std::optional<float> projectile_pitch) noexcept
|
||||||
@@ -60,13 +61,13 @@ namespace omath::unity_engine
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_pitch_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
return angles::radians_to_degrees(std::asin(direction.y));
|
return angles::radians_to_degrees(std::asin(direction.y));
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
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 direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace omath::unreal_engine
|
|||||||
class CameraTrait final
|
class CameraTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("look-at angle result should not be discarded")]]
|
||||||
constexpr static ViewAngles calc_look_at_angle(const Vector3<double>& cam_origin,
|
constexpr static ViewAngles calc_look_at_angle(const Vector3<double>& cam_origin,
|
||||||
const Vector3<double>& look_at) noexcept
|
const Vector3<double>& look_at) noexcept
|
||||||
{
|
{
|
||||||
@@ -22,12 +22,12 @@ namespace omath::unreal_engine
|
|||||||
YawAngle::from_radians(internal::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(internal::atan2(direction.y, direction.x)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("view matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<double>& cam_origin) noexcept
|
constexpr static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<double>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
return unreal_engine::calc_view_matrix(angles, cam_origin);
|
return unreal_engine::calc_view_matrix(angles, cam_origin);
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard("projection matrix result should not be discarded")]]
|
||||||
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
|
||||||
const projection::ViewPort& view_port, const double near_plane,
|
const projection::ViewPort& view_port, const double near_plane,
|
||||||
const double far_plane,
|
const double far_plane,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace omath::unreal_engine
|
|||||||
class MeshTrait final
|
class MeshTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard("rotation matrix result should not be discarded")]]
|
||||||
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
static Mat4X4 rotation_matrix(const ViewAngles& rotation)
|
||||||
{
|
{
|
||||||
return unreal_engine::rotation_matrix(rotation);
|
return unreal_engine::rotation_matrix(rotation);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace omath::unreal_engine
|
|||||||
class PredEngineTrait final
|
class PredEngineTrait final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
[[nodiscard("projectile position result should not be discarded")]]
|
||||||
static Vector3<double> predict_projectile_position(const projectile_prediction::Projectile<double>& projectile,
|
static Vector3<double> predict_projectile_position(const projectile_prediction::Projectile<double>& projectile,
|
||||||
const double pitch, const double yaw,
|
const double pitch, const double yaw,
|
||||||
const double time, const double gravity) noexcept
|
const double time, const double gravity) noexcept
|
||||||
@@ -27,7 +28,7 @@ namespace omath::unreal_engine
|
|||||||
return current_pos;
|
return current_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("target position result should not be discarded")]]
|
||||||
static Vector3<double> predict_target_position(const projectile_prediction::Target<double>& target,
|
static Vector3<double> predict_target_position(const projectile_prediction::Target<double>& target,
|
||||||
const double time, const double gravity) noexcept
|
const double time, const double gravity) noexcept
|
||||||
{
|
{
|
||||||
@@ -39,19 +40,19 @@ namespace omath::unreal_engine
|
|||||||
return predicted;
|
return predicted;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("2d distance result should not be discarded")]]
|
||||||
static double calc_vector_2d_distance(const Vector3<double>& delta) noexcept
|
static double calc_vector_2d_distance(const Vector3<double>& delta) noexcept
|
||||||
{
|
{
|
||||||
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
return std::sqrt(delta.x * delta.x + delta.z * delta.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("height coordinate result should not be discarded")]]
|
||||||
static double get_vector_height_coordinate(const Vector3<double>& vec) noexcept
|
static double get_vector_height_coordinate(const Vector3<double>& vec) noexcept
|
||||||
{
|
{
|
||||||
return vec.y;
|
return vec.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("viewpoint result should not be discarded")]]
|
||||||
static Vector3<double> calc_viewpoint_from_angles(const projectile_prediction::Projectile<double>& projectile,
|
static Vector3<double> calc_viewpoint_from_angles(const projectile_prediction::Projectile<double>& projectile,
|
||||||
Vector3<double> predicted_target_position,
|
Vector3<double> predicted_target_position,
|
||||||
const std::optional<double> projectile_pitch) noexcept
|
const std::optional<double> projectile_pitch) noexcept
|
||||||
@@ -64,7 +65,7 @@ namespace omath::unreal_engine
|
|||||||
|
|
||||||
// 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
|
||||||
[[nodiscard]]
|
[[nodiscard("pitch angle result should not be discarded")]]
|
||||||
static double calc_direct_pitch_angle(const Vector3<double>& origin, const Vector3<double>& view_to) noexcept
|
static double calc_direct_pitch_angle(const Vector3<double>& origin, const Vector3<double>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
@@ -72,7 +73,7 @@ namespace omath::unreal_engine
|
|||||||
return angles::radians_to_degrees(std::asin(direction.z));
|
return angles::radians_to_degrees(std::asin(direction.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard("yaw angle result should not be discarded")]]
|
||||||
static double calc_direct_yaw_angle(const Vector3<double>& origin, const Vector3<double>& view_to) noexcept
|
static double calc_direct_yaw_angle(const Vector3<double>& origin, const Vector3<double>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto direction = (view_to - origin).normalized();
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|||||||
Reference in New Issue
Block a user