From d7ab730d2a89b6b8ba814b20d4c7e99a6f6721a4 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Tue, 28 Jan 2020 10:30:31 +0700 Subject: [PATCH] clipping mode config for projection matrices --- headers/enduro2d/base/configs.hpp | 21 ++ headers/enduro2d/high/components/camera.hpp | 2 +- headers/enduro2d/math/mat4.hpp | 332 ++++++++++-------- samples/bin/library/scripts/emmy/math/m4f.lua | 32 +- samples/sources/sample_00/sample_00.cpp | 2 +- samples/sources/sample_01/sample_01.cpp | 2 +- samples/sources/sample_02/sample_02.cpp | 2 +- sources/enduro2d/core/dbgui.cpp | 2 +- .../high/bindings/math_binds/mat4_binds.cpp | 36 +- untests/sources/untests_math/mat4.cpp | 8 +- 10 files changed, 226 insertions(+), 213 deletions(-) diff --git a/headers/enduro2d/base/configs.hpp b/headers/enduro2d/base/configs.hpp index f74a6363..2a9ce7f7 100644 --- a/headers/enduro2d/base/configs.hpp +++ b/headers/enduro2d/base/configs.hpp @@ -180,3 +180,24 @@ #ifndef E2D_WINDOW_MODE # error E2D_WINDOW_MODE not detected #endif + +// +// E2D_CLIPPING_MODE +// + +#define E2D_CLIPPING_MODE_ZO 1 +#define E2D_CLIPPING_MODE_NO 2 + +#ifndef E2D_CLIPPING_MODE +# if defined(E2D_RENDER_MODE) && E2D_RENDER_MODE == E2D_RENDER_MODE_NONE +# define E2D_CLIPPING_MODE E2D_CLIPPING_MODE_ZO +# elif defined(E2D_RENDER_MODE) && E2D_RENDER_MODE == E2D_RENDER_MODE_OPENGL +# define E2D_CLIPPING_MODE E2D_CLIPPING_MODE_NO +# elif defined(E2D_RENDER_MODE) && E2D_RENDER_MODE == E2D_RENDER_MODE_OPENGLES +# define E2D_CLIPPING_MODE E2D_CLIPPING_MODE_NO +# endif +#endif + +#ifndef E2D_CLIPPING_MODE +# error E2D_CLIPPING_MODE not detected +#endif diff --git a/headers/enduro2d/high/components/camera.hpp b/headers/enduro2d/high/components/camera.hpp index d7bdbe73..827967b0 100644 --- a/headers/enduro2d/high/components/camera.hpp +++ b/headers/enduro2d/high/components/camera.hpp @@ -148,7 +148,7 @@ namespace e2d::cameras const v2u target_size = camera.target() ? camera.target()->size() : window.real_size(); - return math::make_orthographic_lh_no_matrix4( + return math::make_orthographic_lh_matrix4( target_size.cast_to(), camera.znear(), math::max(camera.zfar(), camera.znear() + math::default_precision())); diff --git a/headers/enduro2d/math/mat4.hpp b/headers/enduro2d/math/mat4.hpp index d0587ed3..b5172993 100644 --- a/headers/enduro2d/math/mat4.hpp +++ b/headers/enduro2d/math/mat4.hpp @@ -521,195 +521,227 @@ namespace e2d::math } // - // make_orthographic_lh_zo_matrix4 + // make_orthographic_lh_matrix4 // - template < typename T > - std::enable_if_t, mat4> - make_orthographic_lh_zo_matrix4(T width, T height, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(width, T(0))); - E2D_ASSERT(!math::is_near_zero(height, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - const T sx = T(2) / width; - const T sy = T(2) / height; - const T sz = T(1) / (zfar - znear); - const T tz = -znear / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(0), - T(0), T(0), tz, T(1)}; + namespace impl + { + template < typename T > + std::enable_if_t, mat4> + make_orthographic_lh_zo_matrix4(T width, T height, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(width, T(0))); + E2D_ASSERT(!math::is_near_zero(height, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + const T sx = T(2) / width; + const T sy = T(2) / height; + const T sz = T(1) / (zfar - znear); + const T tz = -znear / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(0), + T(0), T(0), tz, T(1)}; + } + + template < typename T > + std::enable_if_t, mat4> + make_orthographic_lh_no_matrix4(T width, T height, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(width, T(0))); + E2D_ASSERT(!math::is_near_zero(height, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + const T sx = T(2) / width; + const T sy = T(2) / height; + const T sz = T(2) / (zfar - znear); + const T tz = -(zfar + znear) / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(0), + T(0), T(0), tz, T(1)}; + } } template < typename T > std::enable_if_t, mat4> - make_orthographic_lh_zo_matrix4(const vec2& size, T znear, T zfar) noexcept { - return make_orthographic_lh_zo_matrix4(size.x, size.y, znear, zfar); - } - - // - // make_orthographic_lh_no_matrix4 - // - - template < typename T > - std::enable_if_t, mat4> - make_orthographic_lh_no_matrix4(T width, T height, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(width, T(0))); - E2D_ASSERT(!math::is_near_zero(height, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - const T sx = T(2) / width; - const T sy = T(2) / height; - const T sz = T(2) / (zfar - znear); - const T tz = -(zfar + znear) / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(0), - T(0), T(0), tz, T(1)}; + make_orthographic_lh_matrix4(T width, T height, T znear, T zfar) noexcept { + #if defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_ZO + return impl::make_orthographic_lh_zo_matrix4(width, height, znear, zfar); + #elif defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_NO + return impl::make_orthographic_lh_no_matrix4(width, height, znear, zfar); + #else + # error "E2D_CLIPPING_MODE not detected" + #endif } template < typename T > std::enable_if_t, mat4> - make_orthographic_lh_no_matrix4(const vec2& size, T znear, T zfar) noexcept { - return make_orthographic_lh_no_matrix4(size.x, size.y, znear, zfar); + make_orthographic_lh_matrix4(const vec2& size, T znear, T zfar) noexcept { + return make_orthographic_lh_matrix4(size.x, size.y, znear, zfar); } // - // make_orthographic_rh_zo_matrix4 + // make_orthographic_rh_matrix4 // - template < typename T > - std::enable_if_t, mat4> - make_orthographic_rh_zo_matrix4(T width, T height, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(width, T(0))); - E2D_ASSERT(!math::is_near_zero(height, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - const T sx = T(2) / width; - const T sy = T(2) / height; - const T sz = T(-1) / (zfar - znear); - const T tz = -znear / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(0), - T(0), T(0), tz, T(1)}; + namespace impl + { + template < typename T > + std::enable_if_t, mat4> + make_orthographic_rh_zo_matrix4(T width, T height, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(width, T(0))); + E2D_ASSERT(!math::is_near_zero(height, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + const T sx = T(2) / width; + const T sy = T(2) / height; + const T sz = T(-1) / (zfar - znear); + const T tz = -znear / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(0), + T(0), T(0), tz, T(1)}; + } + + template < typename T > + std::enable_if_t, mat4> + make_orthographic_rh_no_matrix4(T width, T height, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(width, T(0))); + E2D_ASSERT(!math::is_near_zero(height, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + const T sx = T(2) / width; + const T sy = T(2) / height; + const T sz = T(-2) / (zfar - znear); + const T tz = -(zfar + znear) / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(0), + T(0), T(0), tz, T(1)}; + } } template < typename T > std::enable_if_t, mat4> - make_orthographic_rh_zo_matrix4(const vec2& size, T znear, T zfar) noexcept { - return make_orthographic_rh_zo_matrix4(size.x, size.y, znear, zfar); - } - - // - // make_orthographic_rh_no_matrix4 - // - - template < typename T > - std::enable_if_t, mat4> - make_orthographic_rh_no_matrix4(T width, T height, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(width, T(0))); - E2D_ASSERT(!math::is_near_zero(height, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - const T sx = T(2) / width; - const T sy = T(2) / height; - const T sz = T(-2) / (zfar - znear); - const T tz = -(zfar + znear) / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(0), - T(0), T(0), tz, T(1)}; + make_orthographic_rh_matrix4(T width, T height, T znear, T zfar) noexcept { + #if defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_ZO + return impl::make_orthographic_rh_zo_matrix4(width, height, znear, zfar); + #elif defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_NO + return impl::make_orthographic_rh_no_matrix4(width, height, znear, zfar); + #else + # error "E2D_CLIPPING_MODE not detected" + #endif } template < typename T > std::enable_if_t, mat4> - make_orthographic_rh_no_matrix4(const vec2& size, T znear, T zfar) noexcept { - return make_orthographic_rh_no_matrix4(size.x, size.y, znear, zfar); + make_orthographic_rh_matrix4(const vec2& size, T znear, T zfar) noexcept { + return make_orthographic_rh_matrix4(size.x, size.y, znear, zfar); } // - // make_perspective_lh_zo_matrix4 + // make_perspective_lh_matrix4 // + namespace impl + { + template < typename T, typename AngleTag > + std::enable_if_t, mat4> + make_perspective_lh_zo_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(aspect, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); + const T sy = T(1) / math::tan(fov * T(0.5)); + const T sx = sy / aspect; + const T sz = zfar / (zfar - znear); + const T tz = -(zfar * znear) / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(1), + T(0), T(0), tz, T(0)}; + } + + template < typename T, typename AngleTag > + std::enable_if_t, mat4> + make_perspective_lh_no_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(aspect, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); + const T sy = T(1) / math::tan(fov * T(0.5)); + const T sx = sy / aspect; + const T sz = (zfar + znear) / (zfar - znear); + const T tz = -(T(2) * zfar * znear) / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(1), + T(0), T(0), tz, T(0)}; + } + } + template < typename T, typename AngleTag > std::enable_if_t, mat4> - make_perspective_lh_zo_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(aspect, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); - const T sy = T(1) / math::tan(fov * T(0.5)); - const T sx = sy / aspect; - const T sz = zfar / (zfar - znear); - const T tz = -(zfar * znear) / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(1), - T(0), T(0), tz, T(0)}; + make_perspective_lh_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { + #if defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_ZO + return impl::make_perspective_lh_zo_matrix4(fov, aspect, znear, zfar); + #elif defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_NO + return impl::make_perspective_lh_no_matrix4(fov, aspect, znear, zfar); + #else + # error "E2D_CLIPPING_MODE not detected" + #endif } // - // make_perspective_lh_no_matrix4 + // make_perspective_rh_matrix4 // - template < typename T, typename AngleTag > - std::enable_if_t, mat4> - make_perspective_lh_no_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(aspect, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); - const T sy = T(1) / math::tan(fov * T(0.5)); - const T sx = sy / aspect; - const T sz = (zfar + znear) / (zfar - znear); - const T tz = -(T(2) * zfar * znear) / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(1), - T(0), T(0), tz, T(0)}; + namespace impl + { + template < typename T, typename AngleTag > + std::enable_if_t, mat4> + make_perspective_rh_zo_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(aspect, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); + const T sy = T(1) / math::tan(fov * T(0.5)); + const T sx = sy / aspect; + const T sz = zfar / (znear - zfar); + const T tz = -(zfar * znear) / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(-1), + T(0), T(0), tz, T(0)}; + } + + template < typename T, typename AngleTag > + std::enable_if_t, mat4> + make_perspective_rh_no_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { + E2D_ASSERT(!math::is_near_zero(aspect, T(0))); + E2D_ASSERT(!math::approximately(znear, zfar, T(0))); + E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); + const T sy = T(1) / math::tan(fov * T(0.5)); + const T sx = sy / aspect; + const T sz = -(zfar + znear) / (zfar - znear); + const T tz = -(T(2) * zfar * znear) / (zfar - znear); + return { + sx, T(0), T(0), T(0), + T(0), sy, T(0), T(0), + T(0), T(0), sz, T(-1), + T(0), T(0), tz, T(0)}; + } } - // - // make_perspective_rh_zo_matrix4 - // - template < typename T, typename AngleTag > std::enable_if_t, mat4> - make_perspective_rh_zo_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(aspect, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); - const T sy = T(1) / math::tan(fov * T(0.5)); - const T sx = sy / aspect; - const T sz = zfar / (znear - zfar); - const T tz = -(zfar * znear) / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(-1), - T(0), T(0), tz, T(0)}; - } - - // - // make_perspective_rh_no_matrix4 - // - - template < typename T, typename AngleTag > - std::enable_if_t, mat4> - make_perspective_rh_no_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { - E2D_ASSERT(!math::is_near_zero(aspect, T(0))); - E2D_ASSERT(!math::approximately(znear, zfar, T(0))); - E2D_ASSERT(!math::approximately(fov, unit::zero(), T(0))); - const T sy = T(1) / math::tan(fov * T(0.5)); - const T sx = sy / aspect; - const T sz = -(zfar + znear) / (zfar - znear); - const T tz = -(T(2) * zfar * znear) / (zfar - znear); - return { - sx, T(0), T(0), T(0), - T(0), sy, T(0), T(0), - T(0), T(0), sz, T(-1), - T(0), T(0), tz, T(0)}; + make_perspective_rh_matrix4(const unit& fov, T aspect, T znear, T zfar) noexcept { + #if defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_ZO + return impl::make_perspective_rh_zo_matrix4(fov, aspect, znear, zfar); + #elif defined(E2D_CLIPPING_MODE) && E2D_CLIPPING_MODE == E2D_CLIPPING_MODE_NO + return impl::make_perspective_rh_no_matrix4(fov, aspect, znear, zfar); + #else + # error "E2D_CLIPPING_MODE not detected" + #endif } // diff --git a/samples/bin/library/scripts/emmy/math/m4f.lua b/samples/bin/library/scripts/emmy/math/m4f.lua index c4a1feb6..49a982dd 100644 --- a/samples/bin/library/scripts/emmy/math/m4f.lua +++ b/samples/bin/library/scripts/emmy/math/m4f.lua @@ -53,50 +53,26 @@ function m4f.make_look_at_rh(eye, at, up) end ---@overload fun(width: number, height: number, znear: number, zfar: number): m4f ---@overload fun(size: v2f, znear: number, zfar: number): m4f ---@return m4f -function m4f.make_orthographic_lh_zo(...) end +function m4f.make_orthographic_lh(...) end ---@overload fun(width: number, height: number, znear: number, zfar: number): m4f ---@overload fun(size: v2f, znear: number, zfar: number): m4f ---@return m4f -function m4f.make_orthographic_lh_no(...) end - ----@overload fun(width: number, height: number, znear: number, zfar: number): m4f ----@overload fun(size: v2f, znear: number, zfar: number): m4f ----@return m4f -function m4f.make_orthographic_rh_zo(...) end - ----@overload fun(width: number, height: number, znear: number, zfar: number): m4f ----@overload fun(size: v2f, znear: number, zfar: number): m4f ----@return m4f -function m4f.make_orthographic_rh_no(...) end +function m4f.make_orthographic_rh(...) end ---@param angle number ---@param aspect number ---@param znear number ---@param zfar number ---@return m4f -function m4f.make_perspective_lh_zo(angle, aspect, znear, zfar) end +function m4f.make_perspective_lh(angle, aspect, znear, zfar) end ---@param angle number ---@param aspect number ---@param znear number ---@param zfar number ---@return m4f -function m4f.make_perspective_lh_no(angle, aspect, znear, zfar) end - ----@param angle number ----@param aspect number ----@param znear number ----@param zfar number ----@return m4f -function m4f.make_perspective_rh_zo(angle, aspect, znear, zfar) end - ----@param angle number ----@param aspect number ----@param znear number ----@param zfar number ----@return m4f -function m4f.make_perspective_rh_no(angle, aspect, znear, zfar) end +function m4f.make_perspective_rh(angle, aspect, znear, zfar) end ---@param l m4f ---@param r m4f diff --git a/samples/sources/sample_00/sample_00.cpp b/samples/sources/sample_00/sample_00.cpp index b831d8e4..a87367fe 100644 --- a/samples/sources/sample_00/sample_00.cpp +++ b/samples/sources/sample_00/sample_00.cpp @@ -184,7 +184,7 @@ namespace void frame_render() final { const auto framebuffer_size = the().real_size().cast_to(); - const auto projection = math::make_orthographic_lh_no_matrix4( + const auto projection = math::make_orthographic_lh_matrix4( framebuffer_size, 0.f, 1.f); material_.properties() diff --git a/samples/sources/sample_01/sample_01.cpp b/samples/sources/sample_01/sample_01.cpp index 13ec8768..d3287d47 100644 --- a/samples/sources/sample_01/sample_01.cpp +++ b/samples/sources/sample_01/sample_01.cpp @@ -235,7 +235,7 @@ namespace void frame_render() final { const auto framebuffer_size = the().real_size().cast_to(); - const auto projection = math::make_perspective_lh_no_matrix4( + const auto projection = math::make_perspective_lh_matrix4( make_deg(45.f), framebuffer_size.x / framebuffer_size.y, 0.1f, diff --git a/samples/sources/sample_02/sample_02.cpp b/samples/sources/sample_02/sample_02.cpp index fd2b894f..65604ff0 100644 --- a/samples/sources/sample_02/sample_02.cpp +++ b/samples/sources/sample_02/sample_02.cpp @@ -205,7 +205,7 @@ namespace void frame_render() final { const auto framebuffer_size = the().real_size().cast_to(); - const auto projection = math::make_perspective_lh_no_matrix4( + const auto projection = math::make_perspective_lh_matrix4( make_deg(45.f), framebuffer_size.x / framebuffer_size.y, 0.1f, diff --git a/sources/enduro2d/core/dbgui.cpp b/sources/enduro2d/core/dbgui.cpp index b3bf789f..7798be5e 100644 --- a/sources/enduro2d/core/dbgui.cpp +++ b/sources/enduro2d/core/dbgui.cpp @@ -129,7 +129,7 @@ namespace e2d const v2f framebuffer_size = display_size * v2f(draw_data->FramebufferScale); const m4f projection = - math::make_orthographic_lh_no_matrix4(display_size, 0.f, 1.f) * + math::make_orthographic_lh_matrix4(display_size, 0.f, 1.f) * math::make_translation_matrix4(-1.f, 1.f); for ( int i = 0; i < draw_data->CmdListsCount; ++i ) { diff --git a/sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp b/sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp index 5b59b56b..7b670e22 100644 --- a/sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp +++ b/sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp @@ -66,36 +66,20 @@ namespace "make_look_at_rh", sol::resolve< mat4(const vec3&,const vec3&,const vec3&)>(&math::make_look_at_rh_matrix4), - "make_orthographic_lh_zo", sol::overload( - sol::resolve(T,T,T,T)>(&math::make_orthographic_lh_zo_matrix4), - sol::resolve(const vec2&,T,T)>(&math::make_orthographic_lh_zo_matrix4)), + "make_orthographic_lh", sol::overload( + sol::resolve(T,T,T,T)>(&math::make_orthographic_lh_matrix4), + sol::resolve(const vec2&,T,T)>(&math::make_orthographic_lh_matrix4)), - "make_orthographic_lh_no", sol::overload( - sol::resolve(T,T,T,T)>(&math::make_orthographic_lh_no_matrix4), - sol::resolve(const vec2&,T,T)>(&math::make_orthographic_lh_no_matrix4)), + "make_orthographic_rh", sol::overload( + sol::resolve(T,T,T,T)>(&math::make_orthographic_rh_matrix4), + sol::resolve(const vec2&,T,T)>(&math::make_orthographic_rh_matrix4)), - "make_orthographic_rh_zo", sol::overload( - sol::resolve(T,T,T,T)>(&math::make_orthographic_rh_zo_matrix4), - sol::resolve(const vec2&,T,T)>(&math::make_orthographic_rh_zo_matrix4)), - - "make_orthographic_rh_no", sol::overload( - sol::resolve(T,T,T,T)>(&math::make_orthographic_rh_no_matrix4), - sol::resolve(const vec2&,T,T)>(&math::make_orthographic_rh_no_matrix4)), - - "make_perspective_lh_zo", [](T angle, T aspect, T znear, T zfar) -> mat4 { - return math::make_perspective_lh_zo_matrix4(make_rad(angle), aspect, znear, zfar); + "make_perspective_lh", [](T angle, T aspect, T znear, T zfar) -> mat4 { + return math::make_perspective_lh_matrix4(make_rad(angle), aspect, znear, zfar); }, - "make_perspective_lh_no", [](T angle, T aspect, T znear, T zfar) -> mat4 { - return math::make_perspective_lh_no_matrix4(make_rad(angle), aspect, znear, zfar); - }, - - "make_perspective_rh_zo", [](T angle, T aspect, T znear, T zfar) -> mat4 { - return math::make_perspective_rh_zo_matrix4(make_rad(angle), aspect, znear, zfar); - }, - - "make_perspective_rh_no", [](T angle, T aspect, T znear, T zfar) -> mat4 { - return math::make_perspective_rh_no_matrix4(make_rad(angle), aspect, znear, zfar); + "make_perspective_rh", [](T angle, T aspect, T znear, T zfar) -> mat4 { + return math::make_perspective_rh_matrix4(make_rad(angle), aspect, znear, zfar); }, "approximately", [](const mat4& l, const mat4& r) -> bool { diff --git a/untests/sources/untests_math/mat4.cpp b/untests/sources/untests_math/mat4.cpp index 7206f8b7..c86ca3f8 100644 --- a/untests/sources/untests_math/mat4.cpp +++ b/untests/sources/untests_math/mat4.cpp @@ -35,11 +35,11 @@ TEST_CASE("mat4") { REQUIRE(math::make_rotation_matrix4(make_rad(1.f),1.f,1.f,1.f) == math::make_rotation_matrix4(make_rad(1.f), v3f::unit())); REQUIRE(math::make_rotation_matrix4(make_rad(1.f),v3f(1.f,1.f,1.f)) == math::make_rotation_matrix4(make_rad(1.f), v3f::unit())); - REQUIRE(math::make_orthographic_lh_no_matrix4(640.f, 480.f, 0.f, 1.f) == math::make_orthographic_lh_no_matrix4(v2f(640,480), 0.f, 1.f)); - REQUIRE(math::make_orthographic_lh_no_matrix4(640.0, 480.0, 0.0, 1.0) == math::make_orthographic_lh_no_matrix4(v2d(640,480), 0.0, 1.0)); + REQUIRE(math::make_orthographic_lh_matrix4(640.f, 480.f, 0.f, 1.f) == math::make_orthographic_lh_matrix4(v2f(640,480), 0.f, 1.f)); + REQUIRE(math::make_orthographic_lh_matrix4(640.0, 480.0, 0.0, 1.0) == math::make_orthographic_lh_matrix4(v2d(640,480), 0.0, 1.0)); - REQUIRE(math::make_orthographic_lh_zo_matrix4(640.f, 480.f, 0.f, 1.f) == math::make_orthographic_lh_zo_matrix4(v2f(640,480), 0.f, 1.f)); - REQUIRE(math::make_orthographic_lh_zo_matrix4(640.0, 480.0, 0.0, 1.0) == math::make_orthographic_lh_zo_matrix4(v2d(640,480), 0.0, 1.0)); + REQUIRE(math::make_orthographic_lh_matrix4(640.f, 480.f, 0.f, 1.f) == math::make_orthographic_lh_matrix4(v2f(640,480), 0.f, 1.f)); + REQUIRE(math::make_orthographic_lh_matrix4(640.0, 480.0, 0.0, 1.0) == math::make_orthographic_lh_matrix4(v2d(640,480), 0.0, 1.0)); } { REQUIRE(m4f(m4f::identity()) == m4f::identity());