mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
fix unity
This commit is contained in:
@@ -62,17 +62,15 @@ namespace omath::unity_engine
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
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 direction = (view_to - origin).normalized();
|
||||||
const auto delta = view_to - origin;
|
return angles::radians_to_degrees(std::asin(direction.y));
|
||||||
|
|
||||||
return angles::radians_to_degrees(std::asin(delta.y / distance));
|
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static float calc_direct_yaw_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
static float calc_direct_yaw_angle(const Vector3<float>& origin, const Vector3<float>& view_to) noexcept
|
||||||
{
|
{
|
||||||
const auto delta = view_to - origin;
|
const auto direction = (view_to - origin).normalized();
|
||||||
|
|
||||||
return angles::radians_to_degrees(std::atan2(delta.z, delta.x));
|
return angles::radians_to_degrees(std::atan2(direction.x, direction.z));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace omath::unity_engine
|
} // namespace omath::unity_engine
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ namespace omath::unity_engine
|
|||||||
|
|
||||||
ViewAngles CameraTrait::calc_look_at_angle(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
|
||||||
{
|
{
|
||||||
const auto distance = cam_origin.distance_to(look_at);
|
const auto direction = (look_at - cam_origin).normalized();
|
||||||
const auto delta = look_at - cam_origin;
|
|
||||||
|
|
||||||
return {PitchAngle::from_radians(-std::asin(delta.y / distance)),
|
return {PitchAngle::from_radians(-std::asin(direction.y)),
|
||||||
YawAngle::from_radians(std::atan2(delta.x, delta.z)), RollAngle::from_radians(0.f)};
|
YawAngle::from_radians(std::atan2(direction.x, direction.z)), RollAngle::from_radians(0.f)};
|
||||||
}
|
}
|
||||||
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
Mat4X4 CameraTrait::calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user