removed gcem as dep

This commit is contained in:
2026-06-15 00:37:47 +03:00
parent 75c3f2409d
commit 47dcee037e
38 changed files with 1351 additions and 927 deletions
+12 -11
View File
@@ -8,7 +8,7 @@
namespace omath::cry_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{
return mat_rotation_axis_z<float, MatStoreType::ROW_MAJOR>(angles.yaw)
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.roll)
@@ -16,7 +16,7 @@ namespace omath::cry_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward);
@@ -24,7 +24,7 @@ namespace omath::cry_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> right_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
@@ -32,7 +32,7 @@ namespace omath::cry_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -40,26 +40,26 @@ namespace omath::cry_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_camera_view<float, MatStoreType::ROW_MAJOR>(forward_vector(angles), right_vector(angles),
up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -69,9 +69,10 @@ namespace omath::cry_engine
};
}
[[nodiscard]]
inline OMATH_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::ZERO_TO_ONE) noexcept
inline 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::ZERO_TO_ONE) noexcept
{
if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE)
return mat_perspective_left_handed_vertical_fov<float, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>(
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/cry_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::cry_engine
{
@@ -12,8 +12,8 @@ namespace omath::cry_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
return {PitchAngle::from_radians(internal::asin(direction.z)),
@@ -21,16 +21,15 @@ namespace omath::cry_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
@@ -8,10 +8,10 @@
namespace omath::frostbite_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> 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::frostbite_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> 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::frostbite_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -35,15 +35,14 @@ namespace omath::frostbite_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_camera_view<float, MatStoreType::ROW_MAJOR>(forward_vector(angles), right_vector(angles),
up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{
return mat_rotation_axis_z<float, MatStoreType::ROW_MAJOR>(angles.roll)
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.yaw)
@@ -51,19 +50,19 @@ namespace omath::frostbite_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -74,7 +73,7 @@ namespace omath::frostbite_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix(
inline 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
{
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/frostbite_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::frostbite_engine
@@ -13,8 +13,8 @@ namespace omath::frostbite_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
@@ -23,20 +23,19 @@ namespace omath::frostbite_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
}
};
} // namespace omath::unreal_engine
} // namespace omath::frostbite_engine
+10 -11
View File
@@ -8,10 +8,10 @@
namespace omath::iw_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> 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::iw_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> 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::iw_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -35,25 +35,25 @@ namespace omath::iw_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline 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 OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -64,14 +64,13 @@ namespace omath::iw_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix(
inline 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
{
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/iw_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::iw_engine
@@ -13,8 +13,8 @@ namespace omath::iw_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
@@ -23,16 +23,15 @@ namespace omath::iw_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
@@ -7,10 +7,10 @@
namespace omath::opengl_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{
const auto vec =
rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_forward);
@@ -19,7 +19,7 @@ namespace omath::opengl_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> right_vector(const ViewAngles& angles) noexcept
{
const auto vec =
rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_right);
@@ -28,7 +28,7 @@ namespace omath::opengl_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_up);
@@ -36,14 +36,13 @@ namespace omath::opengl_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_look_at_right_handed(cam_origin, cam_origin + forward_vector(angles), up_vector(angles));
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{
return mat_rotation_axis_z<float, MatStoreType::COLUMN_MAJOR>(angles.roll)
* mat_rotation_axis_y<float, MatStoreType::COLUMN_MAJOR>(angles.yaw)
@@ -51,19 +50,19 @@ namespace omath::opengl_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -74,19 +73,19 @@ namespace omath::opengl_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix(
inline 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
{
if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE)
return mat_perspective_right_handed_vertical_fov<
float, MatStoreType::COLUMN_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>(
return mat_perspective_right_handed_vertical_fov<float, MatStoreType::COLUMN_MAJOR,
NDCDepthRange::NEGATIVE_ONE_TO_ONE>(
field_of_view, aspect_ratio, near_plane, far_plane);
if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE)
return mat_perspective_right_handed_vertical_fov<
float, MatStoreType::COLUMN_MAJOR, NDCDepthRange::ZERO_TO_ONE>(
field_of_view, aspect_ratio, near_plane, far_plane);
return mat_perspective_right_handed_vertical_fov<float, MatStoreType::COLUMN_MAJOR,
NDCDepthRange::ZERO_TO_ONE>(field_of_view, aspect_ratio,
near_plane, far_plane);
std::unreachable();
}
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/opengl_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::opengl_engine
@@ -13,27 +13,25 @@ namespace omath::opengl_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
return {PitchAngle::from_radians(internal::asin(direction.y)),
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]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
+13 -13
View File
@@ -9,10 +9,10 @@
namespace omath::rage_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward);
@@ -20,7 +20,7 @@ namespace omath::rage_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> right_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
@@ -28,7 +28,7 @@ namespace omath::rage_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -36,15 +36,14 @@ namespace omath::rage_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_camera_view<float, MatStoreType::ROW_MAJOR>(forward_vector(angles), right_vector(angles),
up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{
return mat_rotation_axis_z<float, MatStoreType::ROW_MAJOR>(angles.yaw)
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.roll)
@@ -52,19 +51,19 @@ namespace omath::rage_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -75,9 +74,10 @@ namespace omath::rage_engine
}
[[nodiscard]]
inline OMATH_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::ZERO_TO_ONE) noexcept
inline 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::ZERO_TO_ONE) noexcept
{
if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE)
return mat_perspective_left_handed_vertical_fov<float, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>(
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/rage_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::rage_engine
@@ -13,8 +13,8 @@ namespace omath::rage_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
@@ -23,16 +23,15 @@ namespace omath::rage_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
@@ -7,10 +7,10 @@
namespace omath::source_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward);
@@ -18,25 +18,25 @@ namespace omath::source_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline 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 OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -47,7 +47,7 @@ namespace omath::source_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> right_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
@@ -55,7 +55,7 @@ namespace omath::source_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -63,14 +63,13 @@ namespace omath::source_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix(
inline 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
{
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/source_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::source_engine
@@ -13,8 +13,8 @@ namespace omath::source_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
@@ -23,16 +23,15 @@ namespace omath::source_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
+14 -15
View File
@@ -8,10 +8,10 @@
namespace omath::unity_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> 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::unity_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> 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::unity_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<float> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -35,15 +35,14 @@ namespace omath::unity_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<float>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{
return mat_camera_view<float, MatStoreType::ROW_MAJOR>(-forward_vector(angles), right_vector(angles),
up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{
return mat_rotation_axis_z<float, MatStoreType::ROW_MAJOR>(angles.roll)
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.yaw)
@@ -51,19 +50,19 @@ namespace omath::unity_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<float> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<float> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -74,17 +73,17 @@ namespace omath::unity_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix(
inline 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
{
if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE)
return omath::mat_perspective_right_handed_vertical_fov<
float, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>(
return omath::mat_perspective_right_handed_vertical_fov<float, MatStoreType::ROW_MAJOR,
NDCDepthRange::ZERO_TO_ONE>(
field_of_view, aspect_ratio, near_plane, far_plane);
if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE)
return omath::mat_perspective_right_handed_vertical_fov<
float, MatStoreType::ROW_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>(
return omath::mat_perspective_right_handed_vertical_fov<float, MatStoreType::ROW_MAJOR,
NDCDepthRange::NEGATIVE_ONE_TO_ONE>(
field_of_view, aspect_ratio, near_plane, far_plane);
std::unreachable();
}
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/unity_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::unity_engine
@@ -13,8 +13,8 @@ namespace omath::unity_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin,
const Vector3<float>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
@@ -23,16 +23,15 @@ namespace omath::unity_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const float near_plane, const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const float near_plane,
const float far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);
@@ -8,10 +8,10 @@
namespace omath::unreal_engine
{
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<double> forward_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<double> 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::unreal_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<double> right_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<double> 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::unreal_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<double> up_vector(const ViewAngles& angles) noexcept
inline constexpr Vector3<double> up_vector(const ViewAngles& angles) noexcept
{
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
@@ -35,15 +35,14 @@ namespace omath::unreal_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_view_matrix(const ViewAngles& angles,
const Vector3<double>& cam_origin) noexcept
inline constexpr Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<double>& cam_origin) noexcept
{
return mat_camera_view<double, MatStoreType::ROW_MAJOR>(forward_vector(angles), right_vector(angles),
up_vector(angles), cam_origin);
up_vector(angles), cam_origin);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
inline constexpr Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{
return mat_rotation_axis_z<double, MatStoreType::ROW_MAJOR>(angles.yaw)
* mat_rotation_axis_y<double, MatStoreType::ROW_MAJOR>(-angles.pitch)
@@ -51,19 +50,19 @@ namespace omath::unreal_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<double> extract_origin(const Mat4X4& mat) noexcept
inline constexpr Vector3<double> extract_origin(const Mat4X4& mat) noexcept
{
return mat_extract_origin(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR Vector3<double> extract_scale(const Mat4X4& mat) noexcept
inline constexpr Vector3<double> extract_scale(const Mat4X4& mat) noexcept
{
return mat_extract_scale(mat);
}
[[nodiscard]]
inline OMATH_CONSTEXPR ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
inline constexpr ViewAngles extract_rotation_angles(const Mat4X4& mat) noexcept
{
const auto angles = mat_extract_rotation_zyx(mat);
return {
@@ -74,17 +73,17 @@ namespace omath::unreal_engine
}
[[nodiscard]]
inline OMATH_CONSTEXPR Mat4X4 calc_perspective_projection_matrix(
inline 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
{
if (ndc_depth_range == NDCDepthRange::ZERO_TO_ONE)
return mat_perspective_left_handed_horizontal_fov<
double, MatStoreType::ROW_MAJOR, NDCDepthRange::ZERO_TO_ONE>(
field_of_view, aspect_ratio, near_plane, far_plane);
return mat_perspective_left_handed_horizontal_fov<double, MatStoreType::ROW_MAJOR,
NDCDepthRange::ZERO_TO_ONE>(field_of_view, aspect_ratio,
near_plane, far_plane);
if (ndc_depth_range == NDCDepthRange::NEGATIVE_ONE_TO_ONE)
return mat_perspective_left_handed_horizontal_fov<
double, MatStoreType::ROW_MAJOR, NDCDepthRange::NEGATIVE_ONE_TO_ONE>(
return mat_perspective_left_handed_horizontal_fov<double, MatStoreType::ROW_MAJOR,
NDCDepthRange::NEGATIVE_ONE_TO_ONE>(
field_of_view, aspect_ratio, near_plane, far_plane);
std::unreachable();
}
@@ -4,7 +4,7 @@
#pragma once
#include "omath/engines/unreal_engine/formulas.hpp"
#include "omath/internal/optional_constexpr_math.hpp"
#include "omath/internal/constexpr_math.hpp"
#include "omath/projection/camera.hpp"
namespace omath::unreal_engine
@@ -13,8 +13,8 @@ namespace omath::unreal_engine
{
public:
[[nodiscard]]
OMATH_CONSTEXPR static ViewAngles calc_look_at_angle(const Vector3<double>& cam_origin,
const Vector3<double>& look_at) noexcept
constexpr static ViewAngles calc_look_at_angle(const Vector3<double>& cam_origin,
const Vector3<double>& look_at) noexcept
{
const auto direction = (look_at - cam_origin).normalized();
@@ -23,16 +23,15 @@ namespace omath::unreal_engine
}
[[nodiscard]]
OMATH_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);
}
[[nodiscard]]
OMATH_CONSTEXPR static Mat4X4
calc_projection_matrix(const projection::FieldOfView& fov, const projection::ViewPort& view_port,
const double near_plane, const double far_plane,
const NDCDepthRange ndc_depth_range) noexcept
constexpr static Mat4X4 calc_projection_matrix(const projection::FieldOfView& fov,
const projection::ViewPort& view_port, const double near_plane,
const double far_plane,
const NDCDepthRange ndc_depth_range) noexcept
{
return calc_perspective_projection_matrix(fov.as_degrees(), view_port.aspect_ratio(), near_plane, far_plane,
ndc_depth_range);