From c3a9f429be4462d242206b4bf723f3741fd9a9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 5 Jan 2014 20:00:37 +0100 Subject: [PATCH] Math: overload Matrix::diagonal() in subclasses to return proper type. --- src/Math/Matrix.h | 1 + src/Math/Test/MatrixTest.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index f6f998cd4..bcc5c5db3 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -240,6 +240,7 @@ template inline Corrade::Utility::Debug operator<<(Co } \ \ Type transposed() const { return Matrix::transposed(); } \ + constexpr VectorType diagonal() const { return Matrix::diagonal(); } \ Type inverted() const { return Matrix::inverted(); } \ Type invertedOrthogonal() const { \ return Matrix::invertedOrthogonal(); \ diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index ff67f4e30..d0940bc9a 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -314,6 +314,7 @@ void MatrixTest::subclassTypes() { CORRADE_VERIFY((std::is_same::value)); CORRADE_VERIFY((std::is_same::value)); + CORRADE_VERIFY((std::is_same::value)); CORRADE_VERIFY((std::is_same::value)); CORRADE_VERIFY((std::is_same::value)); } @@ -333,6 +334,7 @@ void MatrixTest::subclass() { CORRADE_COMPARE(a.transposed(), Mat2(Vec2(2.0f, 3.0f), Vec2(3.5f, 1.0f))); + CORRADE_COMPARE(a.diagonal(), Vec2(2.0f, 1.0f)); Mat2 c(Vec2(Constants::sqrt2()/2.0f, Constants::sqrt2()/2.0f), Vec2(-Constants::sqrt2()/2.0f, Constants::sqrt2()/2.0f));