diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 24dee3c7d..d5a18dad9 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -248,6 +248,9 @@ template class Matrix { return Matrix(first, next...); } + #ifdef MAGNUM_GCC45_COMPATIBILITY + protected: + #endif /* Used internally instead of [][], because GCC does some heavy optimalization in release mode which breaks it */ inline T& operator()(size_t col, size_t row) { @@ -257,6 +260,9 @@ template class Matrix { return _data[col*size+row]; } + #ifdef MAGNUM_GCC45_COMPATIBILITY + private: + #endif T _data[size*size]; }; diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 87e585f92..12bcf7cee 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -120,18 +120,31 @@ template class Matrix4: public Matrix<4, T> { /** @brief Rotation and scaling part of the matrix */ inline Matrix3 rotationScaling() const { + #ifndef MAGNUM_GCC45_COMPATIBILITY /* GCC 4.5 badly optimizes this */ return Matrix3::from( (*this)[0].xyz(), (*this)[1].xyz(), (*this)[2].xyz()); + #else + return Matrix3( + (*this)(0, 0), (*this)(0, 1), (*this)(0, 2), + (*this)(1, 0), (*this)(1, 1), (*this)(1, 2), + (*this)(2, 0), (*this)(2, 1), (*this)(2, 2)); + #endif } /** @brief Rotation part of the matrix */ inline Matrix3 rotation() const { return Matrix3::from( + #ifndef MAGNUM_GCC45_COMPATIBILITY /* GCC 4.5 badly optimizes this */ (*this)[0].xyz().normalized(), (*this)[1].xyz().normalized(), (*this)[2].xyz().normalized()); + #else + Vector3((*this)(0, 0), (*this)(0, 1), (*this)(0, 2)).normalized(), + Vector3((*this)(1, 0), (*this)(1, 1), (*this)(1, 2)).normalized(), + Vector3((*this)(2, 0), (*this)(2, 1), (*this)(2, 2)).normalized()); + #endif } MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(Matrix4, Vector4, 4)