diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index 0f4dc2b5e..95f9c087f 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -100,14 +100,14 @@ AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components comp } #ifndef DOXYGEN_GENERATING_OUTPUT -void AbstractTexture::DataHelper<2>::setWrapping(GLenum target, const Math::Vector& wrapping) { +void AbstractTexture::DataHelper<2>::setWrapping(GLenum target, const Math::Vector<2, Wrapping>& wrapping) { CORRADE_ASSERT(target != GL_TEXTURE_RECTANGLE || ((wrapping[0] == Wrapping::ClampToEdge || wrapping[0] == Wrapping::ClampToBorder) && (wrapping[0] == Wrapping::ClampToEdge || wrapping[1] == Wrapping::ClampToEdge)), "AbstractTexture: rectangle texture wrapping must either clamp to border or to edge", ) glTexParameteri(target, GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); glTexParameteri(target, GL_TEXTURE_WRAP_T, static_cast(wrapping[1])); } -void AbstractTexture::DataHelper<3>::setWrapping(GLenum target, const Math::Vector& wrapping) { +void AbstractTexture::DataHelper<3>::setWrapping(GLenum target, const Math::Vector<3, Wrapping>& wrapping) { glTexParameteri(target, GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); glTexParameteri(target, GL_TEXTURE_WRAP_T, static_cast(wrapping[1])); glTexParameteri(target, GL_TEXTURE_WRAP_R, static_cast(wrapping[2])); diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 932b5306d..24bcf854f 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -571,7 +571,7 @@ template<> struct AbstractTexture::DataHelper<1> { inline constexpr static Target target() { return Target::Texture1D; } - inline static void setWrapping(GLenum target, const Math::Vector& wrapping) { + inline static void setWrapping(GLenum target, const Math::Vector<1, Wrapping>& wrapping) { glTexParameteri(target, GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); } @@ -579,7 +579,7 @@ template<> struct AbstractTexture::DataHelper<1> { glTexImage1D(target, mipLevel, internalFormat, image->dimensions()[0], 0, static_cast(image->components()), static_cast(image->type()), image->data()); } - template inline static void setSub(GLenum target, GLint mipLevel, const Math::Vector& offset, T* image) { + template inline static void setSub(GLenum target, GLint mipLevel, const Math::Vector<1, GLint>& offset, T* image) { glTexSubImage1D(target, mipLevel, offset[0], image->dimensions()[0], static_cast(image->components()), static_cast(image->type()), image->data()); } }; @@ -592,13 +592,13 @@ template<> struct AbstractTexture::DataHelper<2> { inline constexpr static Target target() { return Target::Texture2D; } - static void setWrapping(GLenum target, const Math::Vector& wrapping); + static void setWrapping(GLenum target, const Math::Vector<2, Wrapping>& wrapping); template inline static void set(GLenum target, GLint mipLevel, InternalFormat internalFormat, T* image) { glTexImage2D(target, mipLevel, internalFormat, image->dimensions()[0], image->dimensions()[1], 0, static_cast(image->components()), static_cast(image->type()), image->data()); } - template inline static void setSub(GLenum target, GLint mipLevel, const Math::Vector& offset, T* image) { + template inline static void setSub(GLenum target, GLint mipLevel, const Math::Vector<2, GLint>& offset, T* image) { glTexSubImage2D(target, mipLevel, offset[0], offset[1], image->dimensions()[0], image->dimensions()[1], static_cast(image->components()), static_cast(image->type()), image->data()); } }; @@ -610,13 +610,13 @@ template<> struct AbstractTexture::DataHelper<3> { inline constexpr static Target target() { return Target::Texture3D; } - static void setWrapping(GLenum target, const Math::Vector& wrapping); + static void setWrapping(GLenum target, const Math::Vector<3, Wrapping>& wrapping); template inline static void set(GLenum target, GLint mipLevel, InternalFormat internalFormat, T* image) { glTexImage3D(target, mipLevel, internalFormat, image->dimensions()[0], image->dimensions()[1], image->dimensions()[2], 0, static_cast(image->components()), static_cast(image->type()), image->data()); } - template inline static void setSub(GLenum target, GLint mipLevel, const Math::Vector& offset, T* image) { + template inline static void setSub(GLenum target, GLint mipLevel, const Math::Vector<3, GLint>& offset, T* image) { glTexSubImage3D(target, mipLevel, offset[0], offset[1], offset[2], image->dimensions()[0], image->dimensions()[1], image->dimensions()[2], static_cast(image->components()), static_cast(image->type()), image->data()); } }; diff --git a/src/BufferedImage.h b/src/BufferedImage.h index aa6799165..c7ada6f3f 100644 --- a/src/BufferedImage.h +++ b/src/BufferedImage.h @@ -46,7 +46,7 @@ template class BufferedImage: public AbstractImage { BufferedImage(Components components, ComponentType type): AbstractImage(components, type), _buffer(Buffer::Target::PixelPack) {} /** @brief %Image dimensions */ - inline Math::Vector dimensions() const { return _dimensions; } + inline Math::Vector dimensions() const { return _dimensions; } /** * @brief Data @@ -74,7 +74,7 @@ template class BufferedImage: public AbstractImage { * Updates the image buffer with given data. The data are not deleted * after filling the buffer. */ - template inline void setData(const Math::Vector& dimensions, Components components, const T* data, Buffer::Usage usage) { + template inline void setData(const Math::Vector& dimensions, Components components, const T* data, Buffer::Usage usage) { setData(dimensions, components, TypeTraits::imageType(), data, usage); } @@ -89,7 +89,7 @@ template class BufferedImage: public AbstractImage { * Updates the image buffer with given data. The data are not deleted * after filling the buffer. */ - void setData(const Math::Vector& dimensions, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage) { + void setData(const Math::Vector& dimensions, Components components, ComponentType type, const GLvoid* data, Buffer::Usage usage) { _components = components; _type = type; _dimensions = dimensions; @@ -97,7 +97,7 @@ template class BufferedImage: public AbstractImage { } protected: - Math::Vector _dimensions; /**< @brief %Image dimensions */ + Math::Vector _dimensions; /**< @brief %Image dimensions */ Buffer _buffer; /**< @brief %Image buffer */ }; diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index cf6c70532..211356bfe 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -77,7 +77,7 @@ class CubeMapTexture: public AbstractTexture { /** * @copydoc Texture::setWrapping() */ - inline void setWrapping(const Math::Vector& wrapping) { + inline void setWrapping(const Math::Vector<3, Wrapping>& wrapping) { bind(); DataHelper<3>::setWrapping(GL_TEXTURE_CUBE_MAP, wrapping); } @@ -92,10 +92,10 @@ class CubeMapTexture: public AbstractTexture { } /** - * @copydoc Texture::setSubData(GLint, const Math::Vector&, T*) + * @copydoc Texture::setSubData(GLint, const Math::Vector&, T*) * @param coordinate Coordinate */ - template inline void setSubData(Coordinate coordinate, GLint mipLevel, const Math::Vector& offset, const T* image) { + template inline void setSubData(Coordinate coordinate, GLint mipLevel, const Math::Vector<2, GLint>& offset, const T* image) { bind(); DataHelper<2>::setSub(static_cast(coordinate), mipLevel, offset, image); } diff --git a/src/Image.h b/src/Image.h index bf75ae010..aaf697122 100644 --- a/src/Image.h +++ b/src/Image.h @@ -45,7 +45,7 @@ template class Image: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - template inline Image(const Math::Vector& dimensions, Components components, T* data): AbstractImage(components, TypeTraits::imageType()), _dimensions(dimensions), _data(data) {} + template inline Image(const Math::Vector& dimensions, Components components, T* data): AbstractImage(components, TypeTraits::imageType()), _dimensions(dimensions), _data(data) {} /** * @brief Constructor @@ -57,7 +57,7 @@ template class Image: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline Image(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data): AbstractImage(components, type), _dimensions(dimensions), _data(reinterpret_cast(data)) {} + inline Image(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data): AbstractImage(components, type), _dimensions(dimensions), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -73,7 +73,7 @@ template class Image: public AbstractImage { inline ~Image() { delete[] _data; } /** @brief %Image dimensions */ - inline const Math::Vector& dimensions() const { return _dimensions; } + inline const Math::Vector& dimensions() const { return _dimensions; } /** @brief Pointer to raw data */ inline const void* data() const { return _data; } @@ -88,7 +88,7 @@ template class Image: public AbstractImage { * Deletes previous data and replaces them with new. Note that the * data are not copied, but they are deleted on destruction. */ - template inline void setData(const Math::Vector& dimensions, Components components, T* data) { + template inline void setData(const Math::Vector& dimensions, Components components, T* data) { setData(dimensions, components, TypeTraits::imageType(), data); } @@ -102,7 +102,7 @@ template class Image: public AbstractImage { * Deletes previous data and replaces them with new. Note that the * data are not copied, but they are deleted on destruction. */ - void setData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data) { + void setData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data) { delete _data; _components = components; _type = type; @@ -111,7 +111,7 @@ template class Image: public AbstractImage { } protected: - Math::Vector _dimensions; /**< @brief %Image dimensions */ + Math::Vector _dimensions; /**< @brief %Image dimensions */ char* _data; /**< @brief %Image data */ }; diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index a329b7a5b..8c8580f90 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -25,7 +25,7 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { - template class MatrixDeterminant; + template class MatrixDeterminant; template struct Sequence {}; @@ -42,11 +42,11 @@ namespace Implementation { /** * @brief %Matrix * - * @todo @c PERFORMANCE - loop unrolling for Matrix and Matrix + * @todo @c PERFORMANCE - loop unrolling for Matrix<3, T> and Matrix<4, T> * @todo first col, then row (cache adjacency) */ -template class Matrix { - friend class Matrix; /* for ij() */ +template class Matrix { + friend class Matrix; /* for ij() */ public: /** @@ -57,13 +57,13 @@ template class Matrix { * @attention Use with caution, the function doesn't check whether the * array is long enough. */ - inline constexpr static Matrix& from(T* data) { - return *reinterpret_cast*>(data); + inline constexpr static Matrix& from(T* data) { + return *reinterpret_cast*>(data); } /** @copydoc from(T*) */ - inline constexpr static const Matrix& from(const T* data) { - return *reinterpret_cast*>(data); + inline constexpr static const Matrix& from(const T* data) { + return *reinterpret_cast*>(data); } /** @@ -71,7 +71,7 @@ template class Matrix { * @param first First column vector * @param next Next column vectors */ - template inline constexpr static Matrix from(const Vector& first, const U&... next) { + template inline constexpr static Matrix from(const Vector& first, const U&... next) { return from(typename Implementation::GenerateSequence::Type(), first, next...); } @@ -118,10 +118,10 @@ template class Matrix { #endif /** @brief Copy constructor */ - inline constexpr Matrix(const Matrix& other) = default; + inline constexpr Matrix(const Matrix& other) = default; /** @brief Assignment operator */ - inline Matrix& operator=(const Matrix& other) = default; + inline Matrix& operator=(const Matrix& other) = default; /** * @brief Raw data @@ -132,17 +132,17 @@ template class Matrix { inline constexpr const T* data() const { return _data; } /**< @copydoc data() */ /** @brief %Matrix column */ - inline Vector& operator[](size_t col) { - return Vector::from(_data+col*size); + inline Vector& operator[](size_t col) { + return Vector::from(_data+col*size); } /** @copydoc operator[]() */ - inline constexpr const Vector& operator[](size_t col) const { - return Vector::from(_data+col*size); + inline constexpr const Vector& operator[](size_t col) const { + return Vector::from(_data+col*size); } /** @brief Equality operator */ - inline bool operator==(const Matrix& other) const { + inline bool operator==(const Matrix& other) const { for(size_t i = 0; i != size*size; ++i) if(!TypeTraits::equals(_data[i], other._data[i])) return false; @@ -150,13 +150,13 @@ template class Matrix { } /** @brief Non-equality operator */ - inline constexpr bool operator!=(const Matrix& other) const { + inline constexpr bool operator!=(const Matrix& other) const { return !operator==(other); } /** @brief Multiply matrix operator */ - Matrix operator*(const Matrix& other) const { - Matrix out(Zero); + Matrix operator*(const Matrix& other) const { + Matrix out(Zero); for(size_t row = 0; row != size; ++row) for(size_t col = 0; col != size; ++col) @@ -167,13 +167,13 @@ template class Matrix { } /** @brief Multiply and assign matrix operator */ - inline Matrix& operator*=(const Matrix& other) { + inline Matrix& operator*=(const Matrix& other) { return (*this = *this*other); } /** @brief Multiply vector operator */ - Vector operator*(const Vector& other) const { - Vector out; + Vector operator*(const Vector& other) const { + Vector out; for(size_t row = 0; row != size; ++row) for(size_t pos = 0; pos != size; ++pos) @@ -183,8 +183,8 @@ template class Matrix { } /** @brief Transposed matrix */ - Matrix transposed() const { - Matrix out(Zero); + Matrix transposed() const { + Matrix out(Zero); for(size_t row = 0; row != size; ++row) for(size_t col = 0; col != size; ++col) @@ -194,8 +194,8 @@ template class Matrix { } /** @brief %Matrix without given column and row */ - Matrix ij(size_t skipCol, size_t skipRow) const { - Matrix out(Matrix::Zero); + Matrix ij(size_t skipCol, size_t skipRow) const { + Matrix out(Matrix::Zero); for(size_t row = 0; row != size-1; ++row) for(size_t col = 0; col != size-1; ++col) @@ -219,7 +219,7 @@ template class Matrix { * \det(A) = a_{0, 0} a_{1, 1} - a_{1, 0} a_{0, 1} * @f] */ - inline T determinant() const { return Implementation::MatrixDeterminant()(*this); } + inline T determinant() const { return Implementation::MatrixDeterminant()(*this); } /** * @brief Inverted matrix @@ -229,8 +229,8 @@ template class Matrix { * A^{-1} = \frac{1}{\det(A)} Adj(A) * @f] */ - Matrix inverted() const { - Matrix out(Zero); + Matrix inverted() const { + Matrix out(Zero); T _determinant = determinant(); @@ -242,12 +242,12 @@ template class Matrix { } private: - template inline constexpr static Matrix from(Implementation::Sequence s, const Vector& first, U... next) { + template inline constexpr static Matrix from(Implementation::Sequence s, const Vector& first, U... next) { return from(s, next..., first[sequence]...); } - template inline constexpr static Matrix from(Implementation::Sequence s, T first, U... next) { - return Matrix(first, next...); + template inline constexpr static Matrix from(Implementation::Sequence s, T first, U... next) { + return Matrix(first, next...); } /* Used internally instead of [][], because GCC does some heavy @@ -265,10 +265,10 @@ template class Matrix { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { -template class MatrixDeterminant { +template class MatrixDeterminant { public: /** @brief Functor */ - T operator()(const Matrix& m) { + T operator()(const Matrix& m) { T out(0); for(size_t col = 0; col != size; ++col) @@ -278,25 +278,25 @@ template class MatrixDeterminant { } }; -template class MatrixDeterminant { +template class MatrixDeterminant<2, T> { public: /** @brief Functor */ - inline constexpr T operator()(const Matrix& m) { + inline constexpr T operator()(const Matrix<2, T>& m) { return m[0][0]*m[1][1] - m[1][0]*m[0][1]; } }; -template class MatrixDeterminant { +template class MatrixDeterminant<1, T> { public: /** @brief Functor */ - inline constexpr T operator()(const Matrix& m) { + inline constexpr T operator()(const Matrix<1, T>& m) { return m[0][0]; } }; } -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix& value) { +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix& value) { debug << "Matrix("; debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); for(size_t row = 0; row != size; ++row) { diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 22f53b37d..b7f0d91d5 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -25,7 +25,7 @@ namespace Magnum { namespace Math { /** @brief 3x3 matrix */ -template class Matrix3: public Matrix { +template class Matrix3: public Matrix<3, T> { public: /** @copydoc Matrix::from(T*) */ inline constexpr static Matrix3& from(T* data) { @@ -37,16 +37,16 @@ template class Matrix3: public Matrix { return *reinterpret_cast*>(data); } - /** @copydoc Matrix::from(const Vector&, const U&...) */ - template inline constexpr static Matrix3 from(const Vector& first, const U&... next) { - return Matrix::from(first, next...); + /** @copydoc Matrix::from(const Vector&, const U&...) */ + template inline constexpr static Matrix3 from(const Vector<3, T>& first, const U&... next) { + return Matrix<3, T>::from(first, next...); } /** @copydoc Matrix::Matrix(ZeroType) */ - inline constexpr explicit Matrix3(typename Matrix::ZeroType): Matrix(Matrix::Zero) {} + inline constexpr explicit Matrix3(typename Matrix<3, T>::ZeroType): Matrix<3, T>(Matrix<3, T>::Zero) {} /** @copydoc Matrix::Matrix(IdentityType, T) */ - inline constexpr explicit Matrix3(typename Matrix::IdentityType = Matrix::Identity, T value = T(1)): Matrix( + inline constexpr explicit Matrix3(typename Matrix<3, T>::IdentityType = Matrix<3, T>::Identity, T value = T(1)): Matrix<3, T>( value, 0.0f, 0.0f, 0.0f, value, 0.0f, 0.0f, 0.0f, value @@ -58,48 +58,48 @@ template class Matrix3: public Matrix { /** @copydoc Matrix::Matrix(T, U...) */ #ifndef DOXYGEN_GENERATING_OUTPUT - template inline constexpr Matrix3(T first, U... next): Matrix(first, next...) {} + template inline constexpr Matrix3(T first, U... next): Matrix<3, T>(first, next...) {} #else template inline constexpr Matrix3(T first, U... next) {} #endif - /** @copydoc Matrix::Matrix(const Matrix&) */ - inline constexpr Matrix3(const Matrix& other): Matrix(other) {} + /** @copydoc Matrix::Matrix(const Matrix&) */ + inline constexpr Matrix3(const Matrix<3, T>& other): Matrix<3, T>(other) {} /** @copydoc Matrix::operator=() */ inline Matrix3& operator=(const Matrix3& other) { - Matrix::operator=(other); + Matrix<3, T>::operator=(other); return *this; } /** @copydoc Matrix::operator[](size_t) */ - inline Vector3& operator[](size_t col) { return Vector3::from(Matrix::data()+col*3); } + inline Vector3& operator[](size_t col) { return Vector3::from(Matrix<3, T>::data()+col*3); } /** @copydoc Matrix::operator[](size_t) const */ - inline constexpr const Vector3& operator[](size_t col) const { return Vector3::from(Matrix::data()+col*3); } + inline constexpr const Vector3& operator[](size_t col) const { return Vector3::from(Matrix<3, T>::data()+col*3); } - /** @copydoc Matrix::operator*(const Matrix&) const */ - inline Matrix3 operator*(const Matrix& other) const { return Matrix::operator*(other); } + /** @copydoc Matrix::operator*(const Matrix&) const */ + inline Matrix3 operator*(const Matrix<3, T>& other) const { return Matrix<3, T>::operator*(other); } /** @copydoc Matrix::operator*=() */ - inline Matrix3& operator*=(const Matrix& other) { - Matrix::operator*=(other); + inline Matrix3& operator*=(const Matrix<3, T>& other) { + Matrix<3, T>::operator*=(other); return *this; } - /** @copydoc Matrix::operator*(const Vector&) const */ - inline Vector3 operator*(const Vector& other) const { return Matrix::operator*(other); } + /** @copydoc Matrix::operator*(const Vector&) const */ + inline Vector3 operator*(const Vector<3, T>& other) const { return Matrix<3, T>::operator*(other); } /** @copydoc Matrix::transposed() */ - inline Matrix3 transposed() const { return Matrix::transposed(); } + inline Matrix3 transposed() const { return Matrix<3, T>::transposed(); } /** @copydoc Matrix::inverted() */ - inline Matrix3 inverted() const { return Matrix::inverted(); } + inline Matrix3 inverted() const { return Matrix<3, T>::inverted(); } }; #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix3& value) { - return debug << static_cast&>(value); + return debug << static_cast&>(value); } #endif diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 776621993..43224a6ef 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -30,7 +30,7 @@ namespace Magnum { namespace Math { @todo Shearing @todo Reflection */ -template class Matrix4: public Matrix { +template class Matrix4: public Matrix<4, T> { public: /** @copydoc Matrix::from(T*) */ inline constexpr static Matrix4& from(T* data) { @@ -42,9 +42,9 @@ template class Matrix4: public Matrix { return *reinterpret_cast*>(data); } - /** @copydoc Matrix::from(const Vector&, const U&...) */ - template inline constexpr static Matrix4 from(const Vector& first, const U&... next) { - return Matrix::from(first, next...); + /** @copydoc Matrix::from(const Vector&, const U&...) */ + template inline constexpr static Matrix4 from(const Vector<4, T>& first, const U&... next) { + return Matrix<4, T>::from(first, next...); } /** @@ -110,10 +110,10 @@ template class Matrix4: public Matrix { } /** @copydoc Matrix::Matrix(ZeroType) */ - inline constexpr explicit Matrix4(typename Matrix::ZeroType): Matrix(Matrix::Zero) {} + inline constexpr explicit Matrix4(typename Matrix<4, T>::ZeroType): Matrix<4, T>(Matrix<4, T>::Zero) {} /** @copydoc Matrix::Matrix(IdentityType, T) */ - inline constexpr explicit Matrix4(typename Matrix::IdentityType = Matrix::Identity, T value = T(1)): Matrix( + inline constexpr explicit Matrix4(typename Matrix<4, T>::IdentityType = Matrix<4, T>::Identity, T value = T(1)): Matrix<4, T>( value, 0.0f, 0.0f, 0.0f, 0.0f, value, 0.0f, 0.0f, 0.0f, 0.0f, value, 0.0f, @@ -126,46 +126,46 @@ template class Matrix4: public Matrix { /** @copydoc Matrix::Matrix(T, U...) */ #ifndef DOXYGEN_GENERATING_OUTPUT - template inline constexpr Matrix4(T first, U... next): Matrix(first, next...) {} + template inline constexpr Matrix4(T first, U... next): Matrix<4, T>(first, next...) {} #else template inline constexpr Matrix4(T first, U... next) {} #endif - /** @copydoc Matrix::Matrix(const Matrix&) */ - inline constexpr Matrix4(const Matrix& other): Matrix(other) {} + /** @copydoc Matrix::Matrix(const Matrix&) */ + inline constexpr Matrix4(const Matrix<4, T>& other): Matrix<4, T>(other) {} /** @copydoc Matrix::operator=() */ inline Matrix4& operator=(const Matrix4& other) { - Matrix::operator=(other); + Matrix<4, T>::operator=(other); return *this; } /** @copydoc Matrix::operator[](size_t) */ - inline Vector4& operator[](size_t col) { return Vector4::from(Matrix::data()+col*4); } + inline Vector4& operator[](size_t col) { return Vector4::from(Matrix<4, T>::data()+col*4); } /** @copydoc Matrix::operator[](size_t) const */ - inline constexpr const Vector4& operator[](size_t col) const { return Vector4::from(Matrix::data()+col*4); } + inline constexpr const Vector4& operator[](size_t col) const { return Vector4::from(Matrix<4, T>::data()+col*4); } - /** @copydoc Matrix::operator*(const Matrix&) const */ - inline Matrix4 operator*(const Matrix& other) const { return Matrix::operator*(other); } + /** @copydoc Matrix::operator*(const Matrix&) const */ + inline Matrix4 operator*(const Matrix<4, T>& other) const { return Matrix<4, T>::operator*(other); } /** @copydoc Matrix::operator*=() */ - inline Matrix4& operator*=(const Matrix& other) { - Matrix::operator*=(other); + inline Matrix4& operator*=(const Matrix<4, T>& other) { + Matrix<4, T>::operator*=(other); return *this; } - /** @copydoc Matrix::operator*(const Vector&) const */ - inline Vector4 operator*(const Vector& other) const { return Matrix::operator*(other); } + /** @copydoc Matrix::operator*(const Vector&) const */ + inline Vector4 operator*(const Vector<4, T>& other) const { return Matrix<4, T>::operator*(other); } /** @copydoc Matrix::transposed() */ - inline Matrix4 transposed() const { return Matrix::transposed(); } + inline Matrix4 transposed() const { return Matrix<4, T>::transposed(); } /** @copydoc Matrix::ij() */ - inline Matrix3 ij(size_t skipRow, size_t skipCol) const { return Matrix::ij(skipRow, skipCol); } + inline Matrix3 ij(size_t skipRow, size_t skipCol) const { return Matrix<4, T>::ij(skipRow, skipCol); } /** @copydoc Matrix::inverted() */ - inline Matrix4 inverted() const { return Matrix::inverted(); } + inline Matrix4 inverted() const { return Matrix<4, T>::inverted(); } /** @brief Rotation and scaling part of the matrix */ inline Matrix3 rotationScaling() const { @@ -186,7 +186,7 @@ template class Matrix4: public Matrix { #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix4& value) { - return debug << static_cast&>(value); + return debug << static_cast&>(value); } #endif diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 76ab3edcd..7f2552089 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -27,9 +27,9 @@ using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { -typedef Matrix Matrix4; -typedef Matrix Matrix3; -typedef Vector Vector4; +typedef Matrix<4, float> Matrix4; +typedef Matrix<3, float> Matrix3; +typedef Vector<4, float> Vector4; void MatrixTest::construct() { float m[] = { @@ -158,7 +158,7 @@ void MatrixTest::multiplyIdentity() { } void MatrixTest::multiply() { - Matrix left( + Matrix<5, int> left( -3, -3, -1, 3, -5, -1, -3, -5, 2, 3, -1, -4, 3, -1, -2, @@ -166,7 +166,7 @@ void MatrixTest::multiply() { 1, 3, -3, -4, -1 ); - Matrix right( + Matrix<5, int> right( 0, 5, 3, 4, 4, 5, 5, 0, 0, -2, 3, 2, -4, -3, 0, @@ -174,7 +174,7 @@ void MatrixTest::multiply() { 0, -1, -4, 4, 3 ); - Matrix expected( + Matrix<5, int> expected( -24, -35, -32, -25, 1, -22, -36, -24, 33, -8, 8, 16, -22, 29, 2, @@ -186,7 +186,7 @@ void MatrixTest::multiply() { } void MatrixTest::multiplyVector() { - Matrix matrix( + Matrix<5, int> matrix( -3, -3, -1, 3, -5, -1, -3, -5, 2, 3, -1, -4, 3, -1, -2, @@ -194,7 +194,7 @@ void MatrixTest::multiplyVector() { 1, 3, -3, -4, -1 ); - bool is = (matrix*Vector(0, 5, 3, 4, 4) == Vector(-24, -35, -32, -25, 1)); + bool is = (matrix*Vector<5, int>(0, 5, 3, 4, 4) == Vector<5, int>(-24, -35, -32, -25, 1)); QVERIFY(is); } @@ -235,7 +235,7 @@ void MatrixTest::ij() { } void MatrixTest::determinant() { - Matrix m( + Matrix<5, int> m( 1, 2, 2, 1, 0, 2, 3, 2, 1, -2, 1, 1, 1, 1, 0, diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index 26287e127..7f7692e60 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -30,7 +30,7 @@ namespace Magnum { namespace Math { namespace Test { typedef Math::Vector2 Vector2; void Vector2Test::construct() { - QVERIFY((Vector2(1, 2) == Vector(1.0f, 2.0f))); + QVERIFY((Vector2(1, 2) == Vector<2, float>(1.0f, 2.0f))); } void Vector2Test::debug() { diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index ef6833074..781dce425 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -30,8 +30,8 @@ namespace Magnum { namespace Math { namespace Test { typedef Math::Vector3 Vector3; void Vector3Test::construct() { - QVERIFY((Vector3(1, 2, 3) == Vector(1.0f, 2.0f, 3.0f))); - QVERIFY((Vector3(Vector(1.0f, 2.0f), 3) == Vector(1.0f, 2.0f, 3.0f))); + QVERIFY((Vector3(1, 2, 3) == Vector<3, float>(1.0f, 2.0f, 3.0f))); + QVERIFY((Vector3(Vector<2, float>(1.0f, 2.0f), 3) == Vector<3, float>(1.0f, 2.0f, 3.0f))); } void Vector3Test::cross() { diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index c3c8aa061..90c739f02 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -32,8 +32,8 @@ typedef Math::Vector3 Vector3; void Vector4Test::construct() { QVERIFY(Vector4() == Vector4(0.0f, 0.0f, 0.0f, 1.0f)); - QVERIFY((Vector4(1, 2, 3, 4) == Vector(1.0f, 2.0f, 3.0f, 4.0f))); - QVERIFY((Vector4(Vector(1.0f, 2.0f, 3.0f), 4) == Vector(1.0f, 2.0f, 3.0f, 4.0f))); + QVERIFY((Vector4(1, 2, 3, 4) == Vector<4, float>(1.0f, 2.0f, 3.0f, 4.0f))); + QVERIFY((Vector4(Vector<3, float>(1.0f, 2.0f, 3.0f), 4) == Vector<4, float>(1.0f, 2.0f, 3.0f, 4.0f))); } void Vector4Test::threeComponent() { diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index 0726925ea..5c7d2e0d8 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -28,8 +28,8 @@ using namespace Corrade::Utility; namespace Magnum { namespace Math { namespace Test { -typedef Vector Vector4; -typedef Vector Vector3; +typedef Vector<4, float> Vector4; +typedef Vector<3, float> Vector3; void VectorTest::construct() { QVERIFY((Vector4() == Vector4(0.0f, 0.0f, 0.0f, 0.0f))); diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 938e3ea2f..85b36a021 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -31,10 +31,10 @@ namespace Magnum { namespace Math { @todo Swizzling */ -template class Vector { +template class Vector { public: - typedef T Type; /**< @brief %Vector data type */ const static size_t Size = size; /**< @brief %Vector size */ + typedef T Type; /**< @brief %Vector data type */ /** * @brief %Vector from array @@ -44,13 +44,13 @@ template class Vector { * @attention Use with caution, the function doesn't check whether the * array is long enough. */ - inline constexpr static Vector& from(T* data) { - return *reinterpret_cast*>(data); + inline constexpr static Vector& from(T* data) { + return *reinterpret_cast*>(data); } /** @copydoc from(T*) */ - inline constexpr static const Vector& from(const T* data) { - return *reinterpret_cast*>(data); + inline constexpr static const Vector& from(const T* data) { + return *reinterpret_cast*>(data); } /** @@ -60,7 +60,7 @@ template class Vector { * a \cdot b = \sum_{i=0}^{n-1} a_ib_i * @f] */ - static T dot(const Vector& a, const Vector& b) { + static T dot(const Vector& a, const Vector& b) { T out(0); for(size_t i = 0; i != size; ++i) @@ -78,7 +78,7 @@ template class Vector { * * @todo optimize - Assume the vectors are normalized? */ - inline static T angle(const Vector& a, const Vector& b) { + inline static T angle(const Vector& a, const Vector& b) { return acos(dot(a, b)/(a.length()*b.length())); } @@ -106,10 +106,10 @@ template class Vector { } /** @brief Copy constructor */ - inline constexpr Vector(const Vector& other) = default; + inline constexpr Vector(const Vector& other) = default; /** @brief Assignment operator */ - inline Vector& operator=(const Vector& other) = default; + inline Vector& operator=(const Vector& other) = default; /** * @brief Raw data @@ -123,7 +123,7 @@ template class Vector { inline constexpr T operator[](size_t pos) const { return _data[pos]; } /**< @copydoc operator[]() */ /** @brief Equality operator */ - inline bool operator==(const Vector& other) const { + inline bool operator==(const Vector& other) const { for(size_t pos = 0; pos != size; ++pos) if(!TypeTraits::equals((*this)[pos], other[pos])) return false; @@ -131,13 +131,13 @@ template class Vector { } /** @brief Non-equality operator */ - inline bool operator!=(const Vector& other) const { + inline bool operator!=(const Vector& other) const { return !operator==(other); } /** @brief Multiply vector */ - inline Vector operator*(T number) const { - return Vector(*this)*=number; + inline Vector operator*(T number) const { + return Vector(*this)*=number; } /** @@ -146,7 +146,7 @@ template class Vector { * More efficient than operator*(), because it does the computation * in-place. */ - Vector& operator*=(T number) { + Vector& operator*=(T number) { for(size_t i = 0; i != size; ++i) (*this)[i] *= number; @@ -154,8 +154,8 @@ template class Vector { } /** @brief Divide vector */ - inline Vector operator/(T number) const { - return Vector(*this)/=number; + inline Vector operator/(T number) const { + return Vector(*this)/=number; } /** @@ -164,7 +164,7 @@ template class Vector { * More efficient than operator/(), because it does the computation * in-place. */ - Vector& operator/=(T number) { + Vector& operator/=(T number) { for(size_t i = 0; i != size; ++i) (*this)[i] /= number; @@ -172,8 +172,8 @@ template class Vector { } /** @brief Add two vectors */ - inline Vector operator+(const Vector& other) const { - return Vector(*this)+=other; + inline Vector operator+(const Vector& other) const { + return Vector(*this)+=other; } /** @@ -182,7 +182,7 @@ template class Vector { * More efficient than operator+(), because it does the computation * in-place. */ - Vector& operator+=(const Vector& other) { + Vector& operator+=(const Vector& other) { for(size_t i = 0; i != size; ++i) (*this)[i] += other[i]; @@ -190,8 +190,8 @@ template class Vector { } /** @brief Substract two vectors */ - inline Vector operator-(const Vector& other) const { - return Vector(*this)-=other; + inline Vector operator-(const Vector& other) const { + return Vector(*this)-=other; } /** @@ -200,7 +200,7 @@ template class Vector { * More efficient than operator-(), because it does the computation * in-place. */ - Vector& operator-=(const Vector& other) { + Vector& operator-=(const Vector& other) { for(size_t i = 0; i != size; ++i) (*this)[i] -= other[i]; @@ -208,8 +208,8 @@ template class Vector { } /** @brief Negative vector */ - Vector operator-() const { - Vector out; + Vector operator-() const { + Vector out; for(size_t i = 0; i != size; ++i) out[i] = -(*this)[i]; @@ -239,7 +239,7 @@ template class Vector { } /** @brief Normalized vector (of length 1) */ - inline Vector normalized() const { + inline Vector normalized() const { return *this/length(); } @@ -258,7 +258,7 @@ template class Vector { }; #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector& value) { +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector& value) { debug << "Vector("; debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); for(size_t i = 0; i != size; ++i) { diff --git a/src/Math/Vector2.h b/src/Math/Vector2.h index 73c9c8465..6fe5687e3 100644 --- a/src/Math/Vector2.h +++ b/src/Math/Vector2.h @@ -24,7 +24,7 @@ namespace Magnum { namespace Math { /** @brief Two-component vector */ -template class Vector2: public Vector { +template class Vector2: public Vector<2, T> { public: /** @copydoc Vector::from(T*) */ inline constexpr static Vector2& from(T* data) { @@ -37,17 +37,17 @@ template class Vector2: public Vector { } /** @copydoc Vector::Vector(T) */ - inline constexpr explicit Vector2(T value = T()): Vector(value, value) {} + inline constexpr explicit Vector2(T value = T()): Vector<2, T>(value, value) {} /** @copydoc Vector::Vector(const Vector&) */ - inline constexpr Vector2(const Vector& other): Vector(other) {} + inline constexpr Vector2(const Vector<2, T>& other): Vector<2, T>(other) {} /** * @brief Constructor * @param x X value * @param y Y value */ - inline constexpr Vector2(T x, T y): Vector(x, y) {} + inline constexpr Vector2(T x, T y): Vector<2, T>(x, y) {} inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ @@ -57,56 +57,56 @@ template class Vector2: public Vector { /** @copydoc Vector::operator=() */ inline Vector2& operator=(const Vector2& other) { - Vector::operator=(other); + Vector<2, T>::operator=(other); return *this; } /** @copydoc Vector::operator*(T) const */ - inline Vector2 operator*(T number) const { return Vector::operator*(number); } + inline Vector2 operator*(T number) const { return Vector<2, T>::operator*(number); } /** @copydoc Vector::operator*=() */ inline Vector2& operator*=(T number) { - Vector::operator*=(number); + Vector<2, T>::operator*=(number); return *this; } /** @copydoc Vector::operator/() */ - inline Vector2 operator/(T number) const { return Vector::operator/(number); } + inline Vector2 operator/(T number) const { return Vector<2, T>::operator/(number); } /** @copydoc Vector::operator/=() */ inline Vector2& operator/=(T number) { - Vector::operator/=(number); + Vector<2, T>::operator/=(number); return *this; } /** @copydoc Vector::operator+() */ - inline Vector2 operator+(const Vector& other) const { return Vector::operator+(other); } + inline Vector2 operator+(const Vector<2, T>& other) const { return Vector<2, T>::operator+(other); } /** @copydoc Vector::operator+=() */ - inline Vector2& operator+=(const Vector& other) { - Vector::operator+=(other); + inline Vector2& operator+=(const Vector<2, T>& other) { + Vector<2, T>::operator+=(other); return *this; } - /** @copydoc Vector::operator-(const Vector&) const */ - inline Vector2 operator-(const Vector& other) const { return Vector::operator-(other); } + /** @copydoc Vector::operator-(const Vector&) const */ + inline Vector2 operator-(const Vector<2, T>& other) const { return Vector<2, T>::operator-(other); } /** @copydoc Vector::operator-=() */ - inline Vector2& operator-=(const Vector& other) { - Vector::operator-=(other); + inline Vector2& operator-=(const Vector<2, T>& other) { + Vector<2, T>::operator-=(other); return *this; } /** @copydoc Vector::operator-() */ - inline Vector2 operator-() const { return Vector::operator-(); } + inline Vector2 operator-() const { return Vector<2, T>::operator-(); } /** @copydoc Vector::normalized() */ - inline Vector2 normalized() const { return Vector::normalized(); } + inline Vector2 normalized() const { return Vector<2, T>::normalized(); } }; #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector2& value) { - return debug << static_cast&>(value); + return debug << static_cast&>(value); } #endif diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 13deae51a..6689fa7d9 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -24,7 +24,7 @@ namespace Magnum { namespace Math { /** @brief Three-component vector */ -template class Vector3: public Vector { +template class Vector3: public Vector<3, T> { public: /** @copydoc Vector::from(T*) */ inline constexpr static Vector3& from(T* data) { @@ -60,10 +60,10 @@ template class Vector3: public Vector { } /** @copydoc Vector::Vector(T) */ - inline constexpr explicit Vector3(T value = T()): Vector(value, value, value) {} + inline constexpr explicit Vector3(T value = T()): Vector<3, T>(value, value, value) {} /** @copydoc Vector::Vector(const Vector&) */ - inline constexpr Vector3(const Vector& other): Vector(other) {} + inline constexpr Vector3(const Vector<3, T>& other): Vector<3, T>(other) {} /** * @brief Constructor @@ -71,14 +71,14 @@ template class Vector3: public Vector { * @param y Y / G value * @param z Z / B value */ - inline constexpr Vector3(T x, T y, T z): Vector(x, y, z) {} + inline constexpr Vector3(T x, T y, T z): Vector<3, T>(x, y, z) {} /** * @brief Constructor * @param other Two component vector * @param z Z / B value */ - inline constexpr Vector3(const Vector& other, T z = T(0)): Vector(other[0], other[1], z) {} + inline constexpr Vector3(const Vector<2, T>& other, T z = T(0)): Vector<3, T>(other[0], other[1], z) {} inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ @@ -98,56 +98,56 @@ template class Vector3: public Vector { /** @copydoc Vector::operator=() */ inline Vector3& operator=(const Vector3& other) { - Vector::operator=(other); + Vector<3, T>::operator=(other); return *this; } /** @copydoc Vector::operator*(T) const */ - inline Vector3 operator*(T number) const { return Vector::operator*(number); } + inline Vector3 operator*(T number) const { return Vector<3, T>::operator*(number); } /** @copydoc Vector::operator*=() */ inline Vector3& operator*=(T number) { - Vector::operator*=(number); + Vector<3, T>::operator*=(number); return *this; } /** @copydoc Vector::operator/() */ - inline Vector3 operator/(T number) const { return Vector::operator/(number); } + inline Vector3 operator/(T number) const { return Vector<3, T>::operator/(number); } /** @copydoc Vector::operator/=() */ inline Vector3& operator/=(T number) { - Vector::operator/=(number); + Vector<3, T>::operator/=(number); return *this; } /** @copydoc Vector::operator+() */ - inline Vector3 operator+(const Vector& other) const { return Vector::operator+(other); } + inline Vector3 operator+(const Vector<3, T>& other) const { return Vector<3, T>::operator+(other); } /** @copydoc Vector::operator+=() */ - inline Vector3& operator+=(const Vector& other) { - Vector::operator+=(other); + inline Vector3& operator+=(const Vector<3, T>& other) { + Vector<3, T>::operator+=(other); return *this; } - /** @copydoc Vector::operator-(const Vector&) const */ - inline Vector3 operator-(const Vector& other) const { return Vector::operator-(other); } + /** @copydoc Vector::operator-(const Vector&) const */ + inline Vector3 operator-(const Vector<3, T>& other) const { return Vector<3, T>::operator-(other); } /** @copydoc Vector::operator-=() */ - inline Vector3& operator-=(const Vector& other) { - Vector::operator-=(other); + inline Vector3& operator-=(const Vector<3, T>& other) { + Vector<3, T>::operator-=(other); return *this; } /** @copydoc Vector::operator-() */ - inline Vector3 operator-() const { return Vector::operator-(); } + inline Vector3 operator-() const { return Vector<3, T>::operator-(); } /** @copydoc Vector::normalized() */ - inline Vector3 normalized() const { return Vector::normalized(); } + inline Vector3 normalized() const { return Vector<3, T>::normalized(); } }; #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector3& value) { - return debug << static_cast&>(value); + return debug << static_cast&>(value); } #endif diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index 316eec53e..0f2fb852a 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -24,7 +24,7 @@ namespace Magnum { namespace Math { /** @brief Four-component vector */ -template class Vector4: public Vector { +template class Vector4: public Vector<4, T> { public: /** @copydoc Vector::from(T*) */ inline constexpr static Vector4& from(T* data) { @@ -41,13 +41,13 @@ template class Vector4: public Vector { * * W / A component is set to one. */ - inline constexpr Vector4(): Vector(T(0), T(0), T(0), T(1)) {} + inline constexpr Vector4(): Vector<4, T>(T(0), T(0), T(0), T(1)) {} /** @copydoc Vector::Vector(T) */ - inline constexpr explicit Vector4(T value): Vector(value, value, value, value) {} + inline constexpr explicit Vector4(T value): Vector<4, T>(value, value, value, value) {} /** @copydoc Vector::Vector(const Vector&) */ - inline constexpr Vector4(const Vector& other): Vector(other) {} + inline constexpr Vector4(const Vector<4, T>& other): Vector<4, T>(other) {} /** * @brief Constructor @@ -56,14 +56,14 @@ template class Vector4: public Vector { * @param z Z / B value * @param w W / A value */ - inline constexpr Vector4(T x, T y, T z, T w = T(1)): Vector(x, y, z, w) {} + inline constexpr Vector4(T x, T y, T z, T w = T(1)): Vector<4, T>(x, y, z, w) {} /** * @brief Constructor * @param other Three component vector * @param w W / A value */ - inline constexpr Vector4(const Vector& other, T w = T(1)): Vector(other[0], other[1], other[2], w) {} + inline constexpr Vector4(const Vector<3, T>& other, T w = T(1)): Vector<4, T>(other[0], other[1], other[2], w) {} inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ @@ -79,7 +79,7 @@ template class Vector4: public Vector { * @brief XYZ part of the vector * @return First three components of the vector */ - inline constexpr Vector3 xyz() const { return Vector3::from(Vector::data()); } + inline constexpr Vector3 xyz() const { return Vector3::from(Vector<4, T>::data()); } inline constexpr T r() const { return x(); } /**< @brief R component */ inline constexpr T g() const { return y(); } /**< @brief G component */ @@ -99,56 +99,56 @@ template class Vector4: public Vector { /** @copydoc Vector::operator=() */ inline Vector4& operator=(const Vector4& other) { - Vector::operator=(other); + Vector<4, T>::operator=(other); return *this; } /** @copydoc Vector::operator*(T) const */ - inline Vector4 operator*(T number) const { return Vector::operator*(number); } + inline Vector4 operator*(T number) const { return Vector<4, T>::operator*(number); } /** @copydoc Vector::operator*=() */ inline Vector4& operator*=(T number) { - Vector::operator*=(number); + Vector<4, T>::operator*=(number); return *this; } /** @copydoc Vector::operator/() */ - inline Vector4 operator/(T number) const { return Vector::operator/(number); } + inline Vector4 operator/(T number) const { return Vector<4, T>::operator/(number); } /** @copydoc Vector::operator/=() */ inline Vector4& operator/=(T number) { - Vector::operator/=(number); + Vector<4, T>::operator/=(number); return *this; } /** @copydoc Vector::operator+() */ - inline Vector4 operator+(const Vector& other) const { return Vector::operator+(other); } + inline Vector4 operator+(const Vector<4, T>& other) const { return Vector<4, T>::operator+(other); } /** @copydoc Vector::operator+=() */ - inline Vector4& operator+=(const Vector& other) { - Vector::operator+=(other); + inline Vector4& operator+=(const Vector<4, T>& other) { + Vector<4, T>::operator+=(other); return *this; } - /** @copydoc Vector::operator-(const Vector&) const */ - inline Vector4 operator-(const Vector& other) const { return Vector::operator-(other); } + /** @copydoc Vector::operator-(const Vector&) const */ + inline Vector4 operator-(const Vector<4, T>& other) const { return Vector<4, T>::operator-(other); } /** @copydoc Vector::operator-=() */ - inline Vector4& operator-=(const Vector& other) { - Vector::operator-=(other); + inline Vector4& operator-=(const Vector<4, T>& other) { + Vector<4, T>::operator-=(other); return *this; } /** @copydoc Vector::operator-() */ - inline Vector4 operator-() const { return Vector::operator-(); } + inline Vector4 operator-() const { return Vector<4, T>::operator-(); } /** @copydoc Vector::normalized() */ - inline Vector4 normalized() const { return Vector::normalized(); } + inline Vector4 normalized() const { return Vector<4, T>::normalized(); } }; #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector4& value) { - return debug << static_cast&>(value); + return debug << static_cast&>(value); } #endif diff --git a/src/MeshTools/Clean.h b/src/MeshTools/Clean.h index 509a8868b..750828003 100644 --- a/src/MeshTools/Clean.h +++ b/src/MeshTools/Clean.h @@ -64,7 +64,7 @@ template class Clean { /* Under each index is pointer to face which contains given vertex and index of vertex in the face. */ - std::unordered_map, HashedVertex, IndexHash> table; + std::unordered_map, HashedVertex, IndexHash> table; /* Reserve space for all vertices */ table.reserve(vertices.size()); @@ -80,7 +80,7 @@ template class Clean { exists, change vertex pointer of the face to already existing vertex */ HashedVertex v(*it, table.size()); - auto result = table.insert(std::pair, HashedVertex>(Math::Vector::from(index), v)); + auto result = table.insert(std::pair, HashedVertex>(Math::Vector::from(index), v)); *it = result.first->second.newIndex; } @@ -101,7 +101,7 @@ template class Clean { private: class IndexHash { public: - inline size_t operator()(const Math::Vector& data) const { + inline size_t operator()(const Math::Vector& data) const { return *reinterpret_cast(Corrade::Utility::MurmurHash2()(reinterpret_cast(&data), sizeof(data)).byteArray()); } }; diff --git a/src/MeshTools/CombineIndexedArrays.h b/src/MeshTools/CombineIndexedArrays.h index 432643cf9..967840fde 100644 --- a/src/MeshTools/CombineIndexedArrays.h +++ b/src/MeshTools/CombineIndexedArrays.h @@ -43,7 +43,7 @@ class CombineIndexedArrays { std::iota(result.begin(), result.end(), 0); /* All index combinations */ - std::vector > indexCombinations(_indexCount); + std::vector > indexCombinations(_indexCount); writeCombinedIndices(indexCombinations, std::get<0>(indexedArrays)...); /* Make the combinations unique */ @@ -62,7 +62,7 @@ class CombineIndexedArrays { return first.size(); } - template static void writeCombinedIndices(std::vector>& output, const std::vector& first, const std::vector&... next) { + template static void writeCombinedIndices(std::vector>& output, const std::vector& first, const std::vector&... next) { /* Copy the data to output */ for(size_t i = 0; i != output.size(); ++i) output[i][size-sizeof...(next)-1] = first[i]; @@ -70,7 +70,7 @@ class CombineIndexedArrays { writeCombinedIndices(output, next...); } - template static void writeCombinedArrays(const std::vector>& combinedIndices, std::vector& first, std::vector&... next) { + template static void writeCombinedArrays(const std::vector>& combinedIndices, std::vector& first, std::vector&... next) { /* Rewrite output array */ std::vector output; for(size_t i = 0; i != combinedIndices.size(); ++i) @@ -82,8 +82,8 @@ class CombineIndexedArrays { /* Terminator functions for recursive calls */ inline static size_t indexCount() { return 0; } - template inline static void writeCombinedIndices(std::vector>&) {} - template inline static void writeCombinedArrays(const std::vector>&) {} + template inline static void writeCombinedIndices(std::vector>&) {} + template inline static void writeCombinedArrays(const std::vector>&) {} }; } diff --git a/src/Texture.h b/src/Texture.h index b68adb235..2b01e6760 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -120,7 +120,7 @@ template class Texture: public AbstractTexture { * see @ref AbstractTexture::Wrapping "Wrapping" documentation for * more information. */ - inline void setWrapping(const Math::Vector& wrapping) { + inline void setWrapping(const Math::Vector& wrapping) { bind(); DataHelper::setWrapping(_target, wrapping); } @@ -150,7 +150,7 @@ template class Texture: public AbstractTexture { * Sets texture subdata from given image. The image is not deleted * afterwards. */ - template inline void setSubData(GLint mipLevel, const Math::Vector& offset, T* image) { + template inline void setSubData(GLint mipLevel, const Math::Vector& offset, T* image) { bind(); DataHelper::setSub(_target, mipLevel, offset, image); } diff --git a/src/Trade/ImageData.h b/src/Trade/ImageData.h index cd4f8422f..b82f65436 100644 --- a/src/Trade/ImageData.h +++ b/src/Trade/ImageData.h @@ -44,7 +44,7 @@ template class ImageData: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - template inline ImageData(const Math::Vector& dimensions, Components components, T* data): AbstractImage(components, TypeTraits::imageType()), _dimensions(dimensions), _data(reinterpret_cast(data)) {} + template inline ImageData(const Math::Vector& dimensions, Components components, T* data): AbstractImage(components, TypeTraits::imageType()), _dimensions(dimensions), _data(reinterpret_cast(data)) {} /** * @brief Constructor @@ -56,19 +56,19 @@ template class ImageData: public AbstractImage { * Note that the image data are not copied on construction, but they * are deleted on class destruction. */ - inline ImageData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data): AbstractImage(components, type), _dimensions(dimensions), _data(reinterpret_cast(data)) {} + inline ImageData(const Math::Vector& dimensions, Components components, ComponentType type, GLvoid* data): AbstractImage(components, type), _dimensions(dimensions), _data(reinterpret_cast(data)) {} /** @brief Destructor */ inline virtual ~ImageData() { delete[] _data; } /** @brief %Image dimensions */ - inline const Math::Vector& dimensions() const { return _dimensions; } + inline const Math::Vector& dimensions() const { return _dimensions; } /** @brief Pointer to raw data */ inline const void* data() const { return _data; } private: - Math::Vector _dimensions; + Math::Vector _dimensions; char* _data; }; diff --git a/src/TypeTraits.h b/src/TypeTraits.h index b50258d16..76e06ae25 100644 --- a/src/TypeTraits.h +++ b/src/TypeTraits.h @@ -210,7 +210,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template struct TypeTraits> { +template struct TypeTraits> { inline constexpr static Type type() { return TypeTraits::type(); } /* Can not be used for indices */ /* Can not be used for images */ @@ -218,11 +218,11 @@ template struct TypeTraits struct TypeTraits>: public TypeTraits> {}; -template struct TypeTraits>: public TypeTraits> {}; -template struct TypeTraits>: public TypeTraits> {}; +template struct TypeTraits>: public TypeTraits> {}; +template struct TypeTraits>: public TypeTraits> {}; +template struct TypeTraits>: public TypeTraits> {}; -template struct TypeTraits> { +template struct TypeTraits> { inline constexpr static Type type() { return TypeTraits::type(); } /* Can not be used for indices */ /* Can not be used for images */ @@ -230,8 +230,8 @@ template struct TypeTraits struct TypeTraits>: public TypeTraits> {}; -template struct TypeTraits>: public TypeTraits> {}; +template struct TypeTraits>: public TypeTraits> {}; +template struct TypeTraits>: public TypeTraits> {}; #endif }