diff --git a/doc/changelog.dox b/doc/changelog.dox index f70c8efeb..094dba107 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -822,6 +822,10 @@ See also: 8 digits for @ref Math::Color4) at compile time to prevent common errors - All mutable getters in @ref Math classes are now marked as @cpp constexpr @ce if compiling for C++14 and later. See also [mosra/magnum#597](https://github.com/mosra/magnum/pull/597). +- @ref Matrix3::projection(), @ref Matrix4::orthographicProjection() and + @ref Matrix4::perspectiveProjection() except for the FoV overload (which + calls a trig function inside) are now marked as @cpp constexpr @ce if + compiling for C++14 and later @subsubsection changelog-latest-changes-meshtools MeshTools library diff --git a/src/Magnum/Math/Matrix3.h b/src/Magnum/Math/Matrix3.h index 09d7ab962..56820da0b 100644 --- a/src/Magnum/Math/Matrix3.h +++ b/src/Magnum/Math/Matrix3.h @@ -229,7 +229,7 @@ template class Matrix3: public Matrix3x3 { * @see @ref Matrix4::orthographicProjection(), * @ref Matrix4::perspectiveProjection() */ - static Matrix3 projection(const Vector2& size) { + CORRADE_CONSTEXPR14 static Matrix3 projection(const Vector2& size) { return scaling(T(2.0)/size); } @@ -256,7 +256,7 @@ template class Matrix3: public Matrix3x3 { * @ref Matrix4::perspectiveProjection(const Vector2&, const Vector2&, T, T) * @m_keywords{gluOrtho2D()} */ - static Matrix3 projection(const Vector2& bottomLeft, const Vector2& topRight); + CORRADE_CONSTEXPR14 static Matrix3 projection(const Vector2& bottomLeft, const Vector2& topRight); /** * @brief Create a matrix from a rotation/scaling part and a translation part @@ -764,7 +764,7 @@ template Matrix3 Matrix3::rotation(const Rad angle) { { T(0), T(0), T(1)}}; } -template Matrix3 Matrix3::projection(const Vector2& bottomLeft, const Vector2& topRight) { +template CORRADE_CONSTEXPR14 Matrix3 Matrix3::projection(const Vector2& bottomLeft, const Vector2& topRight) { const Vector2 difference = topRight - bottomLeft; const Vector2 scale = T(2.0)/difference; const Vector2 offset = (topRight + bottomLeft)/difference; diff --git a/src/Magnum/Math/Matrix4.h b/src/Magnum/Math/Matrix4.h index b3a60e1d3..50ffa988d 100644 --- a/src/Magnum/Math/Matrix4.h +++ b/src/Magnum/Math/Matrix4.h @@ -356,7 +356,7 @@ template class Matrix4: public Matrix4x4 { * @ref orthographicProjectionFar() const, * @ref Matrix3::projection() */ - static Matrix4 orthographicProjection(const Vector2& size, T near, T far); + CORRADE_CONSTEXPR14 static Matrix4 orthographicProjection(const Vector2& size, T near, T far); /** * @brief 3D off-center orthographic projection matrix @@ -388,7 +388,7 @@ template class Matrix4: public Matrix4x4 { * @ref Matrix3::projection(const Vector2&, const Vector2&) * @m_keywords{glOrtho()} */ - static Matrix4 orthographicProjection(const Vector2& bottomLeft, const Vector2& topRight, T near, T far); + CORRADE_CONSTEXPR14 static Matrix4 orthographicProjection(const Vector2& bottomLeft, const Vector2& topRight, T near, T far); /** * @brief 3D perspective projection matrix @@ -423,7 +423,7 @@ template class Matrix4: public Matrix4x4 { * @ref perspectiveProjectionFar() const, * @ref Matrix3::projection(), @ref Constants::inf() */ - static Matrix4 perspectiveProjection(const Vector2& size, T near, T far); + CORRADE_CONSTEXPR14 static Matrix4 perspectiveProjection(const Vector2& size, T near, T far); /** * @brief 3D perspective projection matrix @@ -515,7 +515,7 @@ template class Matrix4: public Matrix4x4 { * @ref Matrix3::projection(), @ref Constants::inf() * @m_keywords{glFrustum()} */ - static Matrix4 perspectiveProjection(const Vector2& bottomLeft, const Vector2& topRight, T near, T far); + CORRADE_CONSTEXPR14 static Matrix4 perspectiveProjection(const Vector2& bottomLeft, const Vector2& topRight, T near, T far); /** * @brief Matrix oriented towards a specific point @@ -1278,7 +1278,7 @@ template Matrix4 Matrix4::reflection(const Vector3& normal) { return from(Matrix3x3() - T(2)*normal*RectangularMatrix<1, 3, T>(normal).transposed(), {}); } -template Matrix4 Matrix4::orthographicProjection(const Vector2& size, const T near, const T far) { +template CORRADE_CONSTEXPR14 Matrix4 Matrix4::orthographicProjection(const Vector2& size, const T near, const T far) { const Vector2 xyScale = T(2.0)/size; const T zScale = T(2.0)/(near-far); @@ -1288,7 +1288,7 @@ template Matrix4 Matrix4::orthographicProjection(const Vector2 { T(0), T(0), near*zScale-T(1), T(1)}}; } -template Matrix4 Matrix4::orthographicProjection(const Vector2& bottomLeft, const Vector2& topRight, const T near, const T far) { +template CORRADE_CONSTEXPR14 Matrix4 Matrix4::orthographicProjection(const Vector2& bottomLeft, const Vector2& topRight, const T near, const T far) { const Vector3 difference{topRight - bottomLeft, near - far}; const Vector3 scale = T(2.0)/difference; const Vector3 offset = Vector3{topRight + bottomLeft, near + far}/difference; @@ -1299,10 +1299,13 @@ template Matrix4 Matrix4::orthographicProjection(const Vector2 {-offset.x(), -offset.y(), offset.z(), T(1)}}; } -template Matrix4 Matrix4::perspectiveProjection(const Vector2& size, const T near, const T far) { +template CORRADE_CONSTEXPR14 Matrix4 Matrix4::perspectiveProjection(const Vector2& size, const T near, const T far) { const Vector2 xyScale = 2*near/size; - T m22, m32; + /* These two have to be initialized on C++14 because otherwise GCC says + "error: uninitialized variable ‘m22’ in ‘constexpr’ context". Lol come + on... */ + T m22{}, m32{}; if(far == Constants::inf()) { m22 = T(-1); m32 = T(-2)*near; @@ -1318,12 +1321,15 @@ template Matrix4 Matrix4::perspectiveProjection(const Vector2& { T(0), T(0), m32, T(0)}}; } -template Matrix4 Matrix4::perspectiveProjection(const Vector2& bottomLeft, const Vector2& topRight, const T near, const T far) { +template CORRADE_CONSTEXPR14 Matrix4 Matrix4::perspectiveProjection(const Vector2& bottomLeft, const Vector2& topRight, const T near, const T far) { const Vector2 xyDifference = topRight - bottomLeft; const Vector2 xyScale = 2*near/xyDifference; const Vector2 xyOffset = (topRight + bottomLeft)/xyDifference; - T m22, m32; + /* These two have to be initialized on C++14 because otherwise GCC says + "error: uninitialized variable ‘m22’ in ‘constexpr’ context". Lol come + on... */ + T m22{}, m32{}; if(far == Constants::inf()) { m22 = T(-1); m32 = T(-2)*near; diff --git a/src/Magnum/Math/Test/CMakeLists.txt b/src/Magnum/Math/Test/CMakeLists.txt index ad25e347b..ce7627e21 100644 --- a/src/Magnum/Math/Test/CMakeLists.txt +++ b/src/Magnum/Math/Test/CMakeLists.txt @@ -124,6 +124,8 @@ if(NOT CMAKE_CXX_FLAGS MATCHES "-std=") corrade_add_test(MathCubicHermiteCpp14Test CubicHermiteCpp14Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathDualCpp14Test DualCpp14Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathFrustumCpp14Test FrustumCpp14Test.cpp LIBRARIES MagnumMathTestLib) + corrade_add_test(MathMatrix3Cpp14Test Matrix3Cpp14Test.cpp LIBRARIES MagnumMathTestLib) + corrade_add_test(MathMatrix4Cpp14Test Matrix4Cpp14Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathQuaternionCpp14Test QuaternionCpp14Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathRangeCpp14Test RangeCpp14Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathRectangularMatrixCpp14Test RectangularMatrixCpp14Test.cpp LIBRARIES MagnumMathTestLib) @@ -139,6 +141,8 @@ if(NOT CMAKE_CXX_FLAGS MATCHES "-std=") MathCubicHermiteCpp14Test MathDualCpp14Test MathFrustumCpp14Test + MathMatrix3Cpp14Test + MathMatrix4Cpp14Test MathQuaternionCpp14Test MathRangeCpp14Test MathRectangularMatrixCpp14Test diff --git a/src/Magnum/Math/Test/Matrix3Cpp14Test.cpp b/src/Magnum/Math/Test/Matrix3Cpp14Test.cpp new file mode 100644 index 000000000..544878fbd --- /dev/null +++ b/src/Magnum/Math/Test/Matrix3Cpp14Test.cpp @@ -0,0 +1,77 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022, 2023, 2024, 2025, 2026 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "Magnum/Math/Matrix3.h" + +namespace Magnum { namespace Math { namespace Test { namespace { + +struct Matrix3Cpp14Test: TestSuite::Tester { + explicit Matrix3Cpp14Test(); + + void projectionConstexpr(); + void projectionOffCenterConstexpr(); +}; + +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ +using Magnum::Matrix3; +using Magnum::Vector2; + +Matrix3Cpp14Test::Matrix3Cpp14Test() { + addTests({&Matrix3Cpp14Test::projectionConstexpr, + &Matrix3Cpp14Test::projectionOffCenterConstexpr}); +} + +void Matrix3Cpp14Test::projectionConstexpr() { + /* Like Matrix3Test::projection(), but testing usability in a constexpr + context */ + + constexpr Matrix3 projection = Matrix3::projection({5.0f, 4.0f}); + CORRADE_COMPARE(projection, (Matrix3{ + {2.0f/5.0f, 0.0f, 0.0f}, + { 0.0f, 2.0f/4.0f, 0.0f}, + { 0.0f, 0.0f, 1.0f}})); +} + +void Matrix3Cpp14Test::projectionOffCenterConstexpr() { + /* Like Matrix3Test::projectionOffCenter(), but testing usability in a + constexpr context */ + + constexpr Matrix3 projection = Matrix3::projection({-3.5f, -2.5f}, {1.5f, 1.5f}); + CORRADE_COMPARE(projection, (Matrix3{ + {0.4f, 0.0f, 0.0f}, + {0.0f, 0.5f, 0.0f}, + {0.4f, 0.25f, 1.0f}})); + + CORRADE_COMPARE(projection.transformPoint({1.5f, 1.5f}), (Vector2{1.0f, 1.0f})); + CORRADE_COMPARE(projection.transformPoint({-3.5f, -2.5f}), (Vector2{-1.0f, -1.0f})); +} + +}}}} + +CORRADE_TEST_MAIN(Magnum::Math::Test::Matrix3Cpp14Test) diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index c74a385da..79ce07679 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -511,6 +511,8 @@ void Matrix3Test::shearingY() { } void Matrix3Test::projection() { + /* C++14 constexpr verified in Matrix3Cpp14Test, keep in sync */ + CORRADE_COMPARE(Matrix3::projection({5.0f, 4.0f}), (Matrix3{ {2.0f/5.0f, 0.0f, 0.0f}, { 0.0f, 2.0f/4.0f, 0.0f}, @@ -518,6 +520,8 @@ void Matrix3Test::projection() { } void Matrix3Test::projectionOffCenter() { + /* C++14 constexpr verified in Matrix3Cpp14Test, keep in sync */ + /* Shifted by (-1, -0.5) compared to the projection() test */ Matrix3 projection = Matrix3::projection({-3.5f, -2.5f}, {1.5f, 1.5f}); CORRADE_COMPARE(projection, (Matrix3{ diff --git a/src/Magnum/Math/Test/Matrix4Cpp14Test.cpp b/src/Magnum/Math/Test/Matrix4Cpp14Test.cpp new file mode 100644 index 000000000..4691f70b7 --- /dev/null +++ b/src/Magnum/Math/Test/Matrix4Cpp14Test.cpp @@ -0,0 +1,157 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022, 2023, 2024, 2025, 2026 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "Magnum/Math/Matrix4.h" + +namespace Magnum { namespace Math { namespace Test { namespace { + +struct Matrix4Cpp14Test: TestSuite::Tester { + explicit Matrix4Cpp14Test(); + + void orthographicProjectionConstexpr(); + void orthographicProjectionOffCenterConstexpr(); + void perspectiveProjectionConstexpr(); + void perspectiveProjectionInfiniteFarConstexpr(); + void perspectiveProjectionOffCenterConstexpr(); + void perspectiveProjectionOffCenterInfiniteFarConstexpr(); + /* The FoV variant of perspectiveProjection() uses trig functions that are + only constexpr since C++26, don't want to bother with that yet */ +}; + +/* What's a typedef and not a using differs from the typedefs in root Magnum + namespace, or is not present there at all */ +using Magnum::Constants; +using Magnum::Matrix4; +using Magnum::Vector3; + +Matrix4Cpp14Test::Matrix4Cpp14Test() { + addTests({&Matrix4Cpp14Test::orthographicProjectionConstexpr, + &Matrix4Cpp14Test::orthographicProjectionOffCenterConstexpr, + &Matrix4Cpp14Test::perspectiveProjectionConstexpr, + &Matrix4Cpp14Test::perspectiveProjectionInfiniteFarConstexpr, + &Matrix4Cpp14Test::perspectiveProjectionOffCenterConstexpr, + &Matrix4Cpp14Test::perspectiveProjectionOffCenterInfiniteFarConstexpr}); +} + +void Matrix4Cpp14Test::orthographicProjectionConstexpr() { + /* Like Matrix4Test::orthographicProjection(), but testing usability in a + constexpr context */ + + constexpr Matrix4 actual = Matrix4::orthographicProjection({5.0f, 4.0f}, 1.0f, 9.0f); + CORRADE_COMPARE(actual, (Matrix4{ + {0.4f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.5f, 0.0f, 0.0f}, + {0.0f, 0.0f, -0.25f, 0.0f}, + {0.0f, 0.0f, -1.25f, 1.0f}})); + + CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -1.0f}), (Vector3{0.0f, 0.0f, -1.0f})); + CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -9.0f}), (Vector3{0.0f, 0.0f, +1.0f})); +} + +void Matrix4Cpp14Test::orthographicProjectionOffCenterConstexpr() { + /* Like Matrix4Test::orthographicProjectionOffCenter(), but testing + usability in a constexpr context */ + + constexpr Matrix4 actual = Matrix4::orthographicProjection({-3.5f, -2.5f}, {1.5f, 1.5f}, 1.0f, 9.0f); + CORRADE_COMPARE(actual, (Matrix4{ + {0.4f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.5f, 0.0f, 0.0f}, + {0.0f, 0.0f, -0.25f, 0.0f}, + {0.4f, 0.25f, -1.25f, 1.0f}})); + + CORRADE_COMPARE(actual.transformPoint({1.5f, 1.5f, -1.0f}), (Vector3{1.0f, 1.0f, -1.0f})); + CORRADE_COMPARE(actual.transformPoint({-3.5f, -2.5f, -9.0f}), (Vector3{-1.0f, -1.0f, +1.0f})); +} + +void Matrix4Cpp14Test::perspectiveProjectionConstexpr() { + /* Like Matrix4Test::perspectiveProjection(), but testing usability in a + constexpr context */ + + Matrix4 expected{{4.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 7.111111f, 0.0f, 0.0f}, + {0.0f, 0.0f, -1.9411764f, -1.0f}, + {0.0f, 0.0f, -94.1176452f, 0.0f}}; + constexpr Matrix4 actual = Matrix4::perspectiveProjection({16.0f, 9.0f}, 32.0f, 100.0f); + CORRADE_COMPARE(actual, expected); + + CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -32.0f}), Vector3(0.0f, 0.0f, -1.0f)); + CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -100.0f}), Vector3(0.0f, 0.0f, +1.0f)); + + CORRADE_COMPARE(Matrix4::perspectiveProjection({-8.0f, -4.5f}, {8.0f, 4.5f}, 32.0f, 100.0f), expected); +} + +void Matrix4Cpp14Test::perspectiveProjectionInfiniteFarConstexpr() { + /* Like Matrix4Test::perspectiveProjectionInfiniteFar(), but testing + usability in a constexpr context */ + + Matrix4 expected{{4.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 7.111111f, 0.0f, 0.0f}, + {0.0f, 0.0f, -1.0f, -1.0f}, + {0.0f, 0.0f, -64.0f, 0.0f}}; + constexpr Matrix4 actual = Matrix4::perspectiveProjection({16.0f, 9.0f}, 32.0f, Constants::inf()); + CORRADE_COMPARE(actual, expected); + + CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -32.0f}), Vector3(0.0f, 0.0f, -1.0f)); + CORRADE_COMPARE(actual.transformVector({0.0f, 0.0f, -1.0f}), Vector3(0.0f, 0.0f, +1.0f)); + + CORRADE_COMPARE(Matrix4::perspectiveProjection({-8.0f, -4.5f}, {8.0f, 4.5f}, 32.0f, Constants::inf()), expected); +} + +void Matrix4Cpp14Test::perspectiveProjectionOffCenterConstexpr() { + /* Like Matrix4Test::perspectiveProjectionOffCenter(), but testing + usability in a constexpr context */ + + constexpr Matrix4 projection = Matrix4::perspectiveProjection({-9.0f, -5.0f}, {7.0f, 4.0f}, 32.0f, 100.0f); + CORRADE_COMPARE(projection, (Matrix4{ + { 4.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 7.111111f, 0.0f, 0.0f}, + {-0.125f, -0.1111111f, -1.9411764f, -1.0f}, + { 0.0f, 0.0f, -94.1176452f, 0.0f}})); + + CORRADE_COMPARE(projection.transformPoint({7.0f, 4.0f, -32.0f}), Vector3(1.0f, 1.0f, -1.0f)); + CORRADE_COMPARE(projection.transformPoint({0.0f, 0.0f, -100.0f}), Vector3(0.125f, 0.1111111f, +1.0f)); +} + +void Matrix4Cpp14Test::perspectiveProjectionOffCenterInfiniteFarConstexpr() { + /* Like Matrix4Test::perspectiveProjectionOffCenterInfiniteFar(), but + testing usability in a constexpr context */ + + constexpr Matrix4 projection = Matrix4::perspectiveProjection({-9.0f, -5.0f}, {7.0f, 4.0f}, 32.0f, Constants::inf()); + CORRADE_COMPARE(projection, (Matrix4{ + { 4.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 7.111111f, 0.0f, 0.0f}, + {-0.125f, -0.1111111f, -1.0f, -1.0f}, + { 0.0f, 0.0f, -64.0f, 0.0f}})); + + CORRADE_COMPARE(projection.transformPoint({-9.0f, -5.0f, -32.0f}), Vector3(-1.0f, -1.0f, -1.0f)); + CORRADE_COMPARE(projection.transformVector({0.0f, 0.0f, -1.0f}), Vector3(0.125f, 0.1111111f, +1.0f)); +} + +}}}} + +CORRADE_TEST_MAIN(Magnum::Math::Test::Matrix4Cpp14Test) diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index 7187e6b5e..3d941f023 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -641,6 +641,8 @@ void Matrix4Test::shearingYZ() { } void Matrix4Test::orthographicProjection() { + /* C++14 constexpr verified in Matrix4Cpp14Test, keep in sync */ + Matrix4 actual = Matrix4::orthographicProjection({5.0f, 4.0f}, 1.0f, 9.0f); CORRADE_COMPARE(actual, (Matrix4{ {0.4f, 0.0f, 0.0f, 0.0f}, @@ -654,6 +656,8 @@ void Matrix4Test::orthographicProjection() { } void Matrix4Test::orthographicProjectionOffCenter() { + /* C++14 constexpr verified in Matrix4Cpp14Test, keep in sync */ + /* Shifted by (-1, -0.5) compared to the orthographicProjection() test */ Matrix4 actual = Matrix4::orthographicProjection({-3.5f, -2.5f}, {1.5f, 1.5f}, 1.0f, 9.0f); CORRADE_COMPARE(actual, (Matrix4{ @@ -670,6 +674,8 @@ void Matrix4Test::orthographicProjectionOffCenter() { } void Matrix4Test::perspectiveProjection() { + /* C++14 constexpr verified in Matrix4Cpp14Test, keep in sync */ + Matrix4 expected{{4.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 7.111111f, 0.0f, 0.0f}, {0.0f, 0.0f, -1.9411764f, -1.0f}, @@ -687,6 +693,8 @@ void Matrix4Test::perspectiveProjection() { } void Matrix4Test::perspectiveProjectionInfiniteFar() { + /* C++14 constexpr verified in Matrix4Cpp14Test, keep in sync */ + Matrix4 expected{{4.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 7.111111f, 0.0f, 0.0f}, {0.0f, 0.0f, -1.0f, -1.0f}, @@ -721,6 +729,8 @@ void Matrix4Test::perspectiveProjectionFovInfiniteFar() { } void Matrix4Test::perspectiveProjectionOffCenter() { + /* C++14 constexpr verified in Matrix4Cpp14Test, keep in sync */ + /* Shifted by (-1, -0.5) compared to the perspectiveProjection() test */ Matrix4 projection = Matrix4::perspectiveProjection({-9.0f, -5.0f}, {7.0f, 4.0f}, 32.0f, 100.0f); CORRADE_COMPARE(projection, (Matrix4{ @@ -737,6 +747,8 @@ void Matrix4Test::perspectiveProjectionOffCenter() { } void Matrix4Test::perspectiveProjectionOffCenterInfiniteFar() { + /* C++14 constexpr verified in Matrix4Cpp14Test, keep in sync */ + /* Shifted by (-1, -0.5) compared to perspectiveProjectionInfiniteFar() */ Matrix4 projection = Matrix4::perspectiveProjection({-9.0f, -5.0f}, {7.0f, 4.0f}, 32.0f, Constants::inf()); CORRADE_COMPARE(projection, (Matrix4{