mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-27 00:03:27 +00:00
improvement
This commit is contained in:
@@ -667,8 +667,8 @@ namespace omath
|
|||||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR,
|
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR,
|
||||||
NDCDepthRange DepthRange = NDCDepthRange::NEGATIVE_ONE_TO_ONE>
|
NDCDepthRange DepthRange = NDCDepthRange::NEGATIVE_ONE_TO_ONE>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat<4, 4, Type, St> mat_perspective_left_handed(const float field_of_view, const float aspect_ratio,
|
Mat<4, 4, Type, St> mat_perspective_left_handed(const Type field_of_view, const Type aspect_ratio,
|
||||||
const float near, const float far) noexcept
|
const Type near, const Type far) noexcept
|
||||||
{
|
{
|
||||||
const auto fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / Type{2});
|
const auto fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / Type{2});
|
||||||
|
|
||||||
@@ -689,8 +689,8 @@ namespace omath
|
|||||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR,
|
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR,
|
||||||
NDCDepthRange DepthRange = NDCDepthRange::NEGATIVE_ONE_TO_ONE>
|
NDCDepthRange DepthRange = NDCDepthRange::NEGATIVE_ONE_TO_ONE>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat<4, 4, Type, St> mat_perspective_right_handed(const float field_of_view, const float aspect_ratio,
|
Mat<4, 4, Type, St> mat_perspective_right_handed(const Type field_of_view, const Type aspect_ratio,
|
||||||
const float near, const float far) noexcept
|
const Type near, const Type far) noexcept
|
||||||
{
|
{
|
||||||
const auto fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / Type{2});
|
const auto fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / Type{2});
|
||||||
|
|
||||||
@@ -748,10 +748,10 @@ namespace omath
|
|||||||
const auto y_axis = inv_tan_half_hfov * aspect_ratio;
|
const auto y_axis = inv_tan_half_hfov * aspect_ratio;
|
||||||
|
|
||||||
if constexpr (DepthRange == NDCDepthRange::ZERO_TO_ONE)
|
if constexpr (DepthRange == NDCDepthRange::ZERO_TO_ONE)
|
||||||
return {{x_axis, Type{0}, Type{0}, Type{0}},
|
return {{x_axis, Type{0}, Type{0}, Type{0}},
|
||||||
{Type{0}, y_axis, Type{0}, Type{0}},
|
{Type{0}, y_axis, Type{0}, Type{0}},
|
||||||
{Type{0}, Type{0}, -far / (far - near), -(near * far) / (far - near)},
|
{Type{0}, Type{0}, -far / (far - near), -(near * far) / (far - near)},
|
||||||
{Type{0}, Type{0}, -Type{1}, Type{0}}};
|
{Type{0}, Type{0}, -Type{1}, Type{0}}};
|
||||||
else if constexpr (DepthRange == NDCDepthRange::NEGATIVE_ONE_TO_ONE)
|
else if constexpr (DepthRange == NDCDepthRange::NEGATIVE_ONE_TO_ONE)
|
||||||
return {{x_axis, Type{0}, Type{0}, Type{0}},
|
return {{x_axis, Type{0}, Type{0}, Type{0}},
|
||||||
{Type{0}, y_axis, Type{0}, Type{0}},
|
{Type{0}, y_axis, Type{0}, Type{0}},
|
||||||
|
|||||||
@@ -220,8 +220,8 @@ TEST(UnitTestMatStandalone, Equanity)
|
|||||||
constexpr omath::Vector3<float> left_handed = {0, 2, 10};
|
constexpr omath::Vector3<float> left_handed = {0, 2, 10};
|
||||||
constexpr omath::Vector3<float> right_handed = {0, 2, -10};
|
constexpr omath::Vector3<float> right_handed = {0, 2, -10};
|
||||||
|
|
||||||
const auto proj_left_handed = omath::mat_perspective_left_handed(90.f, 16.f / 9.f, 0.1, 1000);
|
const auto proj_left_handed = omath::mat_perspective_left_handed(90.f, 16.f / 9.f, 0.1f, 1000.f);
|
||||||
const auto proj_right_handed = omath::mat_perspective_right_handed(90.f, 16.f / 9.f, 0.1, 1000);
|
const auto proj_right_handed = omath::mat_perspective_right_handed(90.f, 16.f / 9.f, 0.1f, 1000.f);
|
||||||
|
|
||||||
auto ndc_left_handed = proj_left_handed * omath::mat_column_from_vector(left_handed);
|
auto ndc_left_handed = proj_left_handed * omath::mat_column_from_vector(left_handed);
|
||||||
auto ndc_right_handed = proj_right_handed * omath::mat_column_from_vector(right_handed);
|
auto ndc_right_handed = proj_right_handed * omath::mat_column_from_vector(right_handed);
|
||||||
|
|||||||
Reference in New Issue
Block a user