mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
reverted
This commit is contained in:
@@ -12,7 +12,7 @@ namespace omath::iw_engine
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace omath::opengl_engine
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace omath::source_engine
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace omath::unity_engine
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace omath::unreal_engine
|
||||
{
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
static ViewAngles calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
static Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
|
||||
|
||||
@@ -36,12 +36,12 @@ namespace omath::projection
|
||||
requires(const Vector3<float>& cam_origin, const Vector3<float>& look_at, const ViewAnglesType& angles,
|
||||
const FieldOfView& fov, const ViewPort& viewport, float znear, float zfar) {
|
||||
// Presence + return types
|
||||
{ T::calc_look_at_mat(cam_origin, look_at) } -> std::same_as<MatType>;
|
||||
{ T::calc_look_at_angle(cam_origin, look_at) } -> std::same_as<ViewAnglesType>;
|
||||
{ T::calc_view_matrix(angles, cam_origin) } -> std::same_as<MatType>;
|
||||
{ T::calc_projection_matrix(fov, viewport, znear, zfar) } -> std::same_as<MatType>;
|
||||
|
||||
// Enforce noexcept as in the trait declaration
|
||||
requires noexcept(T::calc_look_at_mat(cam_origin, look_at));
|
||||
requires noexcept(T::calc_look_at_angle(cam_origin, look_at));
|
||||
requires noexcept(T::calc_view_matrix(angles, cam_origin));
|
||||
requires noexcept(T::calc_projection_matrix(fov, viewport, znear, zfar));
|
||||
};
|
||||
@@ -64,9 +64,8 @@ namespace omath::projection
|
||||
|
||||
void look_at(const Vector3<float>& target)
|
||||
{
|
||||
m_view_projection_matrix = TraitClass::calc_projection_matrix(m_field_of_view, m_view_port,
|
||||
m_near_plane_distance, m_far_plane_distance)
|
||||
* TraitClass::calc_look_at_mat(m_origin, target);
|
||||
m_view_angles = TraitClass::calc_look_at_angle(m_origin, target);
|
||||
m_view_projection_matrix = std::nullopt;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
|
||||
Mat4X4 CameraTrait::calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
ViewAngles CameraTrait::calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
{
|
||||
return mat_look_at_left_handed<float, Mat4X4::get_store_ordering()>(cam_origin, look_at, k_abs_up);
|
||||
const auto distance = cam_origin.distance_to(look_at);
|
||||
const auto delta = look_at - cam_origin;
|
||||
|
||||
return {PitchAngle::from_radians(-std::asin(delta.z / distance)),
|
||||
YawAngle::from_radians(std::atan2(delta.y, delta.x)), RollAngle::from_radians(0.f)};
|
||||
}
|
||||
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||
{
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
|
||||
Mat4X4 CameraTrait::calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
ViewAngles CameraTrait::calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
{
|
||||
return mat_look_at_right_handed<float, Mat4X4::get_store_ordering()>(cam_origin, look_at, k_abs_up);
|
||||
const auto distance = cam_origin.distance_to(look_at);
|
||||
const auto delta = look_at - cam_origin;
|
||||
|
||||
return {PitchAngle::from_radians(std::asin(delta.y / distance)),
|
||||
YawAngle::from_radians(std::atan2(delta.x, -delta.z)), RollAngle::from_radians(0.f)};
|
||||
}
|
||||
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||
{
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
namespace omath::source_engine
|
||||
{
|
||||
|
||||
Mat4X4 CameraTrait::calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
ViewAngles CameraTrait::calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
{
|
||||
return mat_look_at_left_handed<float, Mat4X4::get_store_ordering()>(cam_origin, look_at, k_abs_up);
|
||||
const auto distance = cam_origin.distance_to(look_at);
|
||||
const auto delta = look_at - cam_origin;
|
||||
|
||||
return {PitchAngle::from_radians(-std::asin(delta.z / distance)),
|
||||
YawAngle::from_radians(std::atan2(delta.y, delta.x)), RollAngle::from_radians(0.f)};
|
||||
}
|
||||
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||
{
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
|
||||
Mat4X4 CameraTrait::calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
ViewAngles CameraTrait::calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
{
|
||||
return mat_look_at_left_handed<float, Mat4X4::get_store_ordering()>(cam_origin, look_at, k_abs_up);
|
||||
const auto distance = cam_origin.distance_to(look_at);
|
||||
const auto delta = cam_origin - look_at;
|
||||
|
||||
return {PitchAngle::from_radians(-std::asin(delta.y / distance)),
|
||||
YawAngle::from_radians(std::atan2(delta.z, delta.x)), RollAngle::from_radians(0.f)};
|
||||
}
|
||||
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||
{
|
||||
|
||||
@@ -6,9 +6,13 @@
|
||||
namespace omath::unreal_engine
|
||||
{
|
||||
|
||||
Mat4X4 CameraTrait::calc_look_at_mat(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
ViewAngles CameraTrait::calc_look_at_angle(const Vector3<float>& cam_origin, const Vector3<float>& look_at) noexcept
|
||||
{
|
||||
return mat_look_at_left_handed<float, Mat4X4::get_store_ordering()>(cam_origin, look_at, k_abs_up);
|
||||
const auto distance = cam_origin.distance_to(look_at);
|
||||
const auto delta = cam_origin - look_at;
|
||||
|
||||
return {PitchAngle::from_radians(-std::asin(delta.z / distance)),
|
||||
YawAngle::from_radians(std::atan2(delta.x, delta.y)), RollAngle::from_radians(0.f)};
|
||||
}
|
||||
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user