From 2779bae82f886719430fc5ab6d22a7ff0a7651ca Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 15 Jun 2026 20:22:35 +0300 Subject: [PATCH] added nodiscard messages --- include/omath/engines/cry_engine/formulas.hpp | 30 +++++------ .../engines/frostbite_engine/formulas.hpp | 32 ++++++------ include/omath/engines/iw_engine/formulas.hpp | 32 ++++++------ .../omath/engines/opengl_engine/formulas.hpp | 32 ++++++------ .../omath/engines/rage_engine/formulas.hpp | 32 ++++++------ .../omath/engines/source_engine/formulas.hpp | 32 ++++++------ .../omath/engines/unity_engine/formulas.hpp | 32 ++++++------ .../omath/engines/unreal_engine/formulas.hpp | 52 +++++++++---------- 8 files changed, 137 insertions(+), 137 deletions(-) diff --git a/include/omath/engines/cry_engine/formulas.hpp b/include/omath/engines/cry_engine/formulas.hpp index e68e0b0..a494ad4 100644 --- a/include/omath/engines/cry_engine/formulas.hpp +++ b/include/omath/engines/cry_engine/formulas.hpp @@ -7,7 +7,7 @@ namespace omath::cry_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_z(angles.yaw) @@ -15,7 +15,7 @@ namespace omath::cry_engine * mat_rotation_axis_x(angles.pitch); } - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); @@ -23,7 +23,7 @@ namespace omath::cry_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); @@ -31,7 +31,7 @@ namespace omath::cry_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -39,26 +39,26 @@ namespace omath::cry_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -68,7 +68,7 @@ namespace omath::cry_engine RollAngle::from_degrees(angles.y), }; } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, @@ -87,7 +87,7 @@ namespace omath::cry_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { return units / static_cast(100); @@ -95,7 +95,7 @@ namespace omath::cry_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units; @@ -103,7 +103,7 @@ namespace omath::cry_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -111,7 +111,7 @@ namespace omath::cry_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { return centimeters * static_cast(100); @@ -119,7 +119,7 @@ namespace omath::cry_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return meters; @@ -127,7 +127,7 @@ namespace omath::cry_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/frostbite_engine/formulas.hpp b/include/omath/engines/frostbite_engine/formulas.hpp index 6bf6421..d58a7e5 100644 --- a/include/omath/engines/frostbite_engine/formulas.hpp +++ b/include/omath/engines/frostbite_engine/formulas.hpp @@ -7,10 +7,10 @@ namespace omath::frostbite_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); @@ -18,7 +18,7 @@ namespace omath::frostbite_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); @@ -26,7 +26,7 @@ namespace omath::frostbite_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -34,14 +34,14 @@ namespace omath::frostbite_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_z(angles.roll) @@ -49,19 +49,19 @@ namespace omath::frostbite_engine * mat_rotation_axis_x(angles.pitch); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -72,7 +72,7 @@ namespace omath::frostbite_engine }; } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix( const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept @@ -91,7 +91,7 @@ namespace omath::frostbite_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { return units / static_cast(100); @@ -99,7 +99,7 @@ namespace omath::frostbite_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units; @@ -107,7 +107,7 @@ namespace omath::frostbite_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -115,7 +115,7 @@ namespace omath::frostbite_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { return centimeters * static_cast(100); @@ -123,7 +123,7 @@ namespace omath::frostbite_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return meters; @@ -131,7 +131,7 @@ namespace omath::frostbite_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/iw_engine/formulas.hpp b/include/omath/engines/iw_engine/formulas.hpp index faa167d..3e8fa38 100644 --- a/include/omath/engines/iw_engine/formulas.hpp +++ b/include/omath/engines/iw_engine/formulas.hpp @@ -7,10 +7,10 @@ namespace omath::iw_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); @@ -18,7 +18,7 @@ namespace omath::iw_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); @@ -26,7 +26,7 @@ namespace omath::iw_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -34,25 +34,25 @@ namespace omath::iw_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -63,13 +63,13 @@ namespace omath::iw_engine }; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix( const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept @@ -89,7 +89,7 @@ namespace omath::iw_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { constexpr auto centimeter_in_unit = static_cast(2.54); @@ -98,7 +98,7 @@ namespace omath::iw_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units_to_centimeters(units) / static_cast(100); @@ -106,7 +106,7 @@ namespace omath::iw_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -114,7 +114,7 @@ namespace omath::iw_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { constexpr auto centimeter_in_unit = static_cast(2.54); @@ -123,7 +123,7 @@ namespace omath::iw_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return centimeters_to_units(meters * static_cast(100)); @@ -131,7 +131,7 @@ namespace omath::iw_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/opengl_engine/formulas.hpp b/include/omath/engines/opengl_engine/formulas.hpp index e55821a..652c570 100644 --- a/include/omath/engines/opengl_engine/formulas.hpp +++ b/include/omath/engines/opengl_engine/formulas.hpp @@ -6,10 +6,10 @@ namespace omath::opengl_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = @@ -18,7 +18,7 @@ namespace omath::opengl_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = @@ -27,7 +27,7 @@ namespace omath::opengl_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -35,13 +35,13 @@ namespace omath::opengl_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept { return mat_look_at_right_handed(cam_origin, cam_origin + forward_vector(angles), up_vector(angles)); } - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_z(angles.roll) @@ -49,19 +49,19 @@ namespace omath::opengl_engine * mat_rotation_axis_x(angles.pitch); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -72,7 +72,7 @@ namespace omath::opengl_engine }; } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix( const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept @@ -92,7 +92,7 @@ namespace omath::opengl_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { return units / static_cast(100); @@ -100,7 +100,7 @@ namespace omath::opengl_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units; @@ -108,7 +108,7 @@ namespace omath::opengl_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -116,7 +116,7 @@ namespace omath::opengl_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { return centimeters * static_cast(100); @@ -124,7 +124,7 @@ namespace omath::opengl_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return meters; @@ -132,7 +132,7 @@ namespace omath::opengl_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/rage_engine/formulas.hpp b/include/omath/engines/rage_engine/formulas.hpp index 09a6700..a6139df 100644 --- a/include/omath/engines/rage_engine/formulas.hpp +++ b/include/omath/engines/rage_engine/formulas.hpp @@ -8,10 +8,10 @@ namespace omath::rage_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); @@ -19,7 +19,7 @@ namespace omath::rage_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); @@ -27,7 +27,7 @@ namespace omath::rage_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -35,14 +35,14 @@ namespace omath::rage_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_z(angles.yaw) @@ -50,19 +50,19 @@ namespace omath::rage_engine * mat_rotation_axis_x(angles.pitch); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -73,7 +73,7 @@ namespace omath::rage_engine }; } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, @@ -92,7 +92,7 @@ namespace omath::rage_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { return units / static_cast(100); @@ -100,7 +100,7 @@ namespace omath::rage_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units; @@ -108,7 +108,7 @@ namespace omath::rage_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -116,7 +116,7 @@ namespace omath::rage_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { return centimeters * static_cast(100); @@ -124,7 +124,7 @@ namespace omath::rage_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return meters; @@ -132,7 +132,7 @@ namespace omath::rage_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/source_engine/formulas.hpp b/include/omath/engines/source_engine/formulas.hpp index 18fe31f..598e476 100644 --- a/include/omath/engines/source_engine/formulas.hpp +++ b/include/omath/engines/source_engine/formulas.hpp @@ -6,10 +6,10 @@ namespace omath::source_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); @@ -17,25 +17,25 @@ namespace omath::source_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -46,7 +46,7 @@ namespace omath::source_engine }; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); @@ -54,7 +54,7 @@ namespace omath::source_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -62,13 +62,13 @@ namespace omath::source_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix( const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept @@ -88,7 +88,7 @@ namespace omath::source_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { constexpr auto centimeter_in_unit = static_cast(2.54); @@ -97,7 +97,7 @@ namespace omath::source_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units_to_centimeters(units) / static_cast(100); @@ -105,7 +105,7 @@ namespace omath::source_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -113,7 +113,7 @@ namespace omath::source_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { constexpr auto centimeter_in_unit = static_cast(2.54); @@ -122,7 +122,7 @@ namespace omath::source_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return centimeters_to_units(meters * static_cast(100)); @@ -130,7 +130,7 @@ namespace omath::source_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/unity_engine/formulas.hpp b/include/omath/engines/unity_engine/formulas.hpp index ac348a1..ceb4f10 100644 --- a/include/omath/engines/unity_engine/formulas.hpp +++ b/include/omath/engines/unity_engine/formulas.hpp @@ -7,10 +7,10 @@ namespace omath::unity_engine { - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] + [[nodiscard("forward vector result should not be discarded")]] constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); @@ -18,7 +18,7 @@ namespace omath::unity_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("right vector result should not be discarded")]] constexpr Vector3 right_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); @@ -26,7 +26,7 @@ namespace omath::unity_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("up vector result should not be discarded")]] constexpr Vector3 up_vector(const ViewAngles& angles) noexcept { const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); @@ -34,14 +34,14 @@ namespace omath::unity_engine return {vec.at(0, 0), vec.at(1, 0), vec.at(2, 0)}; } - [[nodiscard]] + [[nodiscard("view matrix result should not be discarded")]] constexpr 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); } - [[nodiscard]] + [[nodiscard("rotation matrix result should not be discarded")]] constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept { return mat_rotation_axis_z(angles.roll) @@ -49,19 +49,19 @@ namespace omath::unity_engine * mat_rotation_axis_x(angles.pitch); } - [[nodiscard]] + [[nodiscard("origin result should not be discarded")]] constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] + [[nodiscard("scale result should not be discarded")]] constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] + [[nodiscard("rotation angles result should not be discarded")]] constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); @@ -72,7 +72,7 @@ namespace omath::unity_engine }; } - [[nodiscard]] + [[nodiscard("perspective projection matrix result should not be discarded")]] constexpr Mat4X4 calc_perspective_projection_matrix( const float field_of_view, const float aspect_ratio, const float near_plane, const float far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept @@ -90,7 +90,7 @@ namespace omath::unity_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { return units / static_cast(100); @@ -98,7 +98,7 @@ namespace omath::unity_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units; @@ -106,7 +106,7 @@ namespace omath::unity_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -114,7 +114,7 @@ namespace omath::unity_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { return centimeters * static_cast(100); @@ -122,7 +122,7 @@ namespace omath::unity_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return meters; @@ -130,7 +130,7 @@ namespace omath::unity_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000)); diff --git a/include/omath/engines/unreal_engine/formulas.hpp b/include/omath/engines/unreal_engine/formulas.hpp index f490b08..117f43f 100644 --- a/include/omath/engines/unreal_engine/formulas.hpp +++ b/include/omath/engines/unreal_engine/formulas.hpp @@ -7,62 +7,62 @@ namespace omath::unreal_engine { - [[nodiscard]] - inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; + [[nodiscard("rotation matrix result should not be discarded")]] + constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept; - [[nodiscard]] - inline constexpr Vector3 forward_vector(const ViewAngles& angles) noexcept + [[nodiscard("forward vector result should not be discarded")]] + constexpr 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)}; } - [[nodiscard]] - inline constexpr Vector3 right_vector(const ViewAngles& angles) noexcept + [[nodiscard("right vector result should not be discarded")]] + constexpr 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)}; } - [[nodiscard]] - inline constexpr Vector3 up_vector(const ViewAngles& angles) noexcept + [[nodiscard("up vector result should not be discarded")]] + constexpr 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)}; } - [[nodiscard]] - inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3& cam_origin) noexcept + [[nodiscard("view matrix result should not be discarded")]] + constexpr 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); } - [[nodiscard]] - inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept + [[nodiscard("rotation matrix result should not be discarded")]] + constexpr 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); } - [[nodiscard]] - inline constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept + [[nodiscard("origin result should not be discarded")]] + constexpr Vector3 extract_origin(const Mat4X4& mat) noexcept { return mat_extract_origin(mat); } - [[nodiscard]] - inline constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept + [[nodiscard("scale result should not be discarded")]] + constexpr Vector3 extract_scale(const Mat4X4& mat) noexcept { return mat_extract_scale(mat); } - [[nodiscard]] - inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept + [[nodiscard("rotation angles result should not be discarded")]] + constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept { const auto angles = mat_extract_rotation_zyx(mat); return { @@ -72,8 +72,8 @@ namespace omath::unreal_engine }; } - [[nodiscard]] - inline constexpr Mat4X4 calc_perspective_projection_matrix( + [[nodiscard("perspective projection matrix result should not be discarded")]] + constexpr Mat4X4 calc_perspective_projection_matrix( const double field_of_view, const double aspect_ratio, const double near_plane, const double far_plane, const NDCDepthRange ndc_depth_range = NDCDepthRange::NEGATIVE_ONE_TO_ONE) noexcept { @@ -90,7 +90,7 @@ namespace omath::unreal_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("centimeters value should not be discarded")]] constexpr FloatingType units_to_centimeters(const FloatingType& units) { return units; @@ -98,7 +98,7 @@ namespace omath::unreal_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("meters value should not be discarded")]] constexpr FloatingType units_to_meters(const FloatingType& units) { return units / static_cast(100); @@ -106,7 +106,7 @@ namespace omath::unreal_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("kilometers value should not be discarded")]] constexpr FloatingType units_to_kilometers(const FloatingType& units) { return units_to_meters(units) / static_cast(1000); @@ -114,7 +114,7 @@ namespace omath::unreal_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType centimeters_to_units(const FloatingType& centimeters) { return centimeters; @@ -122,7 +122,7 @@ namespace omath::unreal_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType meters_to_units(const FloatingType& meters) { return meters * static_cast(100); @@ -130,7 +130,7 @@ namespace omath::unreal_engine template requires std::is_floating_point_v - [[nodiscard]] + [[nodiscard("units value should not be discarded")]] constexpr FloatingType kilometers_to_units(const FloatingType& kilometers) { return meters_to_units(kilometers * static_cast(1000));