From 7f28f9f46b76ebc1a5471d9147fed5568cca0389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 11 Mar 2021 21:09:38 +0100 Subject: [PATCH] Improve backwards compatibility of the deprecated Array class. Explicitly provide conversion to Vector2 and Vector3 in addition to Vector<2> / Vector<3> as otherwise creating a TextureData from an Array3D will fail, breaking the compilation of TinyGltfImporter. --- src/Magnum/Array.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Magnum/Array.h b/src/Magnum/Array.h index 842222af4..cb115ae1d 100644 --- a/src/Magnum/Array.h +++ b/src/Magnum/Array.h @@ -184,6 +184,11 @@ template class CORRADE_DEPRECATED("use Math::Vector2 instead") Array2D /** @brief Initializer-list constructor */ constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {} + /** @brief Convert to a vector */ + /*implicit*/ operator Math::Vector2() const { + return Math::Vector2::from(Array<2, T>::_data); + } + T& x() { return Array<2, T>::_data[0]; } /**< @brief X component */ constexpr T x() const { return Array<2, T>::_data[0]; } /**< @overload */ T& y() { return Array<2, T>::_data[1]; } /**< @brief Y component */ @@ -214,6 +219,11 @@ template class CORRADE_DEPRECATED("use Math::Vector3 instead") Array3D: /** @brief Initializer-list constructor */ constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {} + /** @brief Convert to a vector */ + /*implicit*/ operator Math::Vector3() const { + return Math::Vector3::from(Array<3, T>::_data); + } + T& x() { return Array<3, T>::_data[0]; } /**< @brief X component */ constexpr T x() const { return Array<3, T>::_data[0]; } /**< @overload */ T& y() { return Array<3, T>::_data[1]; } /**< @brief Y component */