diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index e593b1023..214f8529c 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -532,15 +532,15 @@ template<> struct AbstractTexture::DataHelper<1> { inline constexpr static Target target() { return Target::Texture1D; } inline static void setWrapping(Target target, const Math::Vector& wrapping) { - glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_S, static_cast(wrapping.at(0))); + glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); } template inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image) { - glTexImage1D(static_cast(target), mipLevel, internalFormat, image->dimensions().at(0), 0, static_cast(image->components()), static_cast(image->type()), image->data()); + glTexImage1D(static_cast(target), mipLevel, internalFormat, image->dimensions()[0], 0, static_cast(image->components()), static_cast(image->type()), image->data()); } template inline static void setSub(Target target, GLint mipLevel, const Math::Vector& offset, T* image) { - glTexSubImage1D(static_cast(target), mipLevel, offset.at(0), image->dimensions().at(0), static_cast(image->components()), static_cast(image->type()), image->data()); + glTexSubImage1D(static_cast(target), mipLevel, offset[0], image->dimensions()[0], static_cast(image->components()), static_cast(image->type()), image->data()); } }; template<> struct AbstractTexture::DataHelper<2> { @@ -560,16 +560,16 @@ template<> struct AbstractTexture::DataHelper<2> { inline constexpr static Target target() { return Target::Texture2D; } inline static void setWrapping(Target target, const Math::Vector& wrapping) { - glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_S, static_cast(wrapping.at(0))); - glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_T, static_cast(wrapping.at(1))); + glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); + glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_T, static_cast(wrapping[1])); } template inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image) { - glTexImage2D(static_cast(target), mipLevel, internalFormat, image->dimensions().at(0), image->dimensions().at(1), 0, static_cast(image->components()), static_cast(image->type()), image->data()); + glTexImage2D(static_cast(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(Target target, GLint mipLevel, const Math::Vector& offset, T* image) { - glTexSubImage2D(static_cast(target), mipLevel, offset.at(0), offset.at(1), image->dimensions().at(0), image->dimensions().at(1), static_cast(image->components()), static_cast(image->type()), image->data()); + glTexSubImage2D(static_cast(target), mipLevel, offset[0], offset[1], image->dimensions()[0], image->dimensions()[1], static_cast(image->components()), static_cast(image->type()), image->data()); } }; template<> struct AbstractTexture::DataHelper<3> { @@ -581,17 +581,17 @@ template<> struct AbstractTexture::DataHelper<3> { inline constexpr static Target target() { return Target::Texture3D; } inline static void setWrapping(Target target, const Math::Vector& wrapping) { - glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_S, static_cast(wrapping.at(0))); - glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_T, static_cast(wrapping.at(1))); - glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_R, static_cast(wrapping.at(2))); + glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_S, static_cast(wrapping[0])); + glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_T, static_cast(wrapping[1])); + glTexParameteri(static_cast(target), GL_TEXTURE_WRAP_R, static_cast(wrapping[2])); } template inline static void set(Target target, GLint mipLevel, InternalFormat internalFormat, T* image) { - glTexImage3D(static_cast(target), mipLevel, internalFormat, image->dimensions().at(0), image->dimensions().at(1), image->dimensions().at(2), 0, static_cast(image->components()), static_cast(image->type()), image->data()); + glTexImage3D(static_cast(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(Target target, GLint mipLevel, const Math::Vector& offset, T* image) { - glTexSubImage3D(static_cast(target), mipLevel, offset.at(0), offset.at(1), offset.at(2), image->dimensions().at(0), image->dimensions().at(1), image->dimensions().at(2), static_cast(image->components()), static_cast(image->type()), image->data()); + glTexSubImage3D(static_cast(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()); } }; #endif diff --git a/src/Camera.cpp b/src/Camera.cpp index 00f04b0bb..ed486fc1a 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -57,7 +57,7 @@ void Camera::setPerspective(GLfloat fov, GLfloat near, GLfloat far) { rawProjectionMatrix = Matrix4::scaling({xyScale, xyScale, zScale})*rawProjectionMatrix; /* And... another magic */ - rawProjectionMatrix.set(3, 3, 0); + rawProjectionMatrix[3][3] = 0; fixAspectRatio(); } diff --git a/src/Light.cpp b/src/Light.cpp index 44b59d546..3ce026f86 100644 --- a/src/Light.cpp +++ b/src/Light.cpp @@ -19,7 +19,7 @@ namespace Magnum { void Light::setClean() { if(!isDirty()) return; - _position = absoluteTransformation().at(3); + _position = absoluteTransformation()[3]; Object::setClean(); } diff --git a/src/Math/GeometryUtils.h b/src/Math/GeometryUtils.h index e24741baa..4a5ffb94a 100644 --- a/src/Math/GeometryUtils.h +++ b/src/Math/GeometryUtils.h @@ -65,11 +65,11 @@ template class GeometryUtils { */ static T intersection(const Matrix3& plane, const Vector3& a, const Vector3& b) { /* Cross product of two vectors defining the plane */ - Vector3 crossProduct = Vector3::cross(plane.at(1)-plane.at(0), plane.at(2)-plane.at(0)); + Vector3 crossProduct = Vector3::cross(plane[1]-plane[0], plane[2]-plane[0]); /* Compute f with cross product and one of the points defining the plane */ - T f = crossProduct*plane.at(0); + T f = crossProduct*plane[0]; /* Compute t */ return (f-crossProduct*a)/(crossProduct*(b-a)); diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 28714b6a5..0b6603648 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -86,39 +86,24 @@ template class Matrix { * @return One-dimensional array of `size*size` length in column-major * order. */ - inline constexpr const T* data() const { return _data; } - - /** @brief Value at given position */ - inline constexpr T at(size_t row, size_t col) const { - return _data[col*size+row]; - } + inline T* data() { return _data; } + inline constexpr const T* data() const { return _data; } /**< @copydoc data() */ /** @brief %Matrix column */ - inline constexpr Vector at(size_t col) const { + inline Vector& operator[](size_t col) { return Vector::from(_data+col*size); } - /** @brief Set value at given position */ - inline void set(size_t row, size_t col, T value) { - _data[col*size+row] = value; - } - - /** @brief Set matrix column */ - inline void set(size_t col, const Vector& value) { - Vector::from(_data+col*size) = value; - } - - /** @brief Add value to given position */ - inline void add(size_t row, size_t col, T value) { - _data[col*size+row] += value; + /** @copydoc operator[]() */ + 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 { - for(size_t row = 0; row != size; ++row) { + for(size_t row = 0; row != size; ++row) for(size_t col = 0; col != size; ++col) - if(!TypeTraits::equals(at(row, col), other.at(row, col))) return false; - } + if(!TypeTraits::equals((*this)[col][row], other[col][row])) return false; return true; } @@ -132,12 +117,10 @@ template class Matrix { Matrix operator*(const Matrix& other) const { Matrix out(false); - for(size_t row = 0; row != size; ++row) { - for(size_t col = 0; col != size; ++col) { + for(size_t row = 0; row != size; ++row) + for(size_t col = 0; col != size; ++col) for(size_t pos = 0; pos != size; ++pos) - out.add(row, col, at(row, pos)*other.at(pos, col)); - } - } + out[col][row] += (*this)[pos][row]*other[col][pos]; return out; } @@ -151,10 +134,9 @@ template class Matrix { Vector operator*(const Vector& other) const { Vector out; - for(size_t row = 0; row != size; ++row) { + for(size_t row = 0; row != size; ++row) for(size_t pos = 0; pos != size; ++pos) - out.add(row, at(row, pos)*other.at(pos)); - } + out[row] += (*this)[pos][row]*other[pos]; return out; } @@ -163,23 +145,21 @@ template class Matrix { Matrix transposed() const { Matrix out(false); - for(size_t row = 0; row != size; ++row) { + for(size_t row = 0; row != size; ++row) for(size_t col = 0; col != size; ++col) - out.set(col, row, at(row, col)); - } + out[row][col] = (*this)[col][row]; return out; } - /** @brief %Matrix without given row and column */ - Matrix ij(size_t skipRow, size_t skipCol) const { + /** @brief %Matrix without given column and row */ + Matrix ij(size_t skipCol, size_t skipRow) const { Matrix out(false); - for(size_t row = 0; row != size-1; ++row) { + for(size_t row = 0; row != size-1; ++row) for(size_t col = 0; col != size-1; ++col) - out.set(row, col, at(row + (row >= skipRow), - col + (col >= skipCol))); - } + out[col][row] = (*this)[col + (col >= skipCol)] + [row + (row >= skipRow)]; return out; } @@ -201,10 +181,9 @@ template class Matrix { T _determinant = determinant(); - for(size_t row = 0; row != size; ++row) { + for(size_t row = 0; row != size; ++row) for(size_t col = 0; col != size; ++col) - out.set(row, col, (((row+col) & 1) ? -1 : 1)*ij(col, row).determinant()/_determinant); - } + out[col][row] = (((row+col) & 1) ? -1 : 1)*ij(row, col).determinant()/_determinant; return out; } @@ -223,7 +202,7 @@ template class MatrixDeterminant { T out(0); for(size_t col = 0; col != size; ++col) - out += ((col & 1) ? -1 : 1)*m.at(0, col)*m.ij(0, col).determinant(); + out += ((col & 1) ? -1 : 1)*m[col][0]*m.ij(col, 0).determinant(); return out; } @@ -234,7 +213,7 @@ template class MatrixDeterminant { public: /** @brief Functor */ inline constexpr T operator()(const Matrix& m) { - return m.at(0, 0)*m.at(1, 1) - m.at(0, 1)*m.at(1, 0); + return m[0][0]*m[1][1] - m[1][0]*m[0][1]; } }; @@ -243,7 +222,7 @@ template class MatrixDeterminant { public: /** @brief Functor */ inline constexpr T operator()(const Matrix& m) { - return m.at(0, 0); + return m[0][0]; } }; @@ -257,7 +236,7 @@ template Corrade::Utility::Debug operator<<(Corrade::Utili if(row != 0) debug << ",\n "; for(size_t col = 0; col != size; ++col) { if(col != 0) debug << ", "; - debug << value.at(row, col); + debug << value[col][row]; } } debug << ')'; diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 61a64af80..24e533972 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -58,11 +58,11 @@ template class Matrix3: public Matrix { /** @copydoc Matrix::operator=() */ inline constexpr Matrix3& operator=(const Matrix& other) { return Matrix::operator=(other); } - /** @copydoc Matrix::at(size_t) const */ - inline constexpr Vector3 at(size_t col) const { return Matrix::at(col); } + /** @copydoc Matrix::operator[](size_t) */ + inline Vector3& operator[](size_t col) { return Vector3::from(Matrix::data()+col*3); } - /** @copydoc Matrix::at(size_t, size_t) const */ - inline constexpr T at(size_t row, size_t col) const { return Matrix::at(row, col); } + /** @copydoc Matrix::operator[](size_t) const */ + inline constexpr const Vector3& operator[](size_t col) const { return Vector3::from(Matrix::data()+col*3); } /** @copydoc Matrix::operator*(const Matrix&) const */ inline Matrix3 operator*(const Matrix& other) const { return Matrix::operator*(other); } diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index c31624f38..345fb7d37 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -127,11 +127,11 @@ template class Matrix4: public Matrix { /** @copydoc Matrix::operator=() */ inline constexpr Matrix4& operator=(const Matrix& other) { return Matrix::operator=(other); } - /** @copydoc Matrix::at(size_t) const */ - inline constexpr Vector4 at(size_t col) const { return Matrix::at(col); } + /** @copydoc Matrix::operator[](size_t) */ + inline Vector4& operator[](size_t col) { return Vector4::from(Matrix::data()+col*4); } - /** @copydoc Matrix::at(size_t, size_t) const */ - inline constexpr T at(size_t row, size_t col) const { return Matrix::at(row, col); } + /** @copydoc Matrix::operator[](size_t) const */ + inline constexpr const Vector4& operator[](size_t col) const { return Vector4::from(Matrix::data()+col*4); } /** @copydoc Matrix::operator*(const Matrix&) const */ inline Matrix4 operator*(const Matrix& other) const { return Matrix::operator*(other); } diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 20d38c5da..1d3124a38 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -80,14 +80,13 @@ void MatrixTest::data() { Vector4 vector(4.0f, 5.0f, 6.0f, 7.0f); - m.set(3, vector); - m.set(1, 2, 1.0f); + m[3] = vector; + m[2][1] = 1.0f; - m.set(2, 1, 1.0f); - m.add(2, 1, 0.5f); + m[1][2] = 1.5f; - QVERIFY(m.at(1, 2) == 1.0f); - QVERIFY(m.at(3) == vector); + QVERIFY(m[2][1] == 1.0f); + QVERIFY(m[3] == vector); Matrix4 expected( 0.0f, 0.0f, 0.0f, 0.0f, @@ -102,20 +101,20 @@ void MatrixTest::data() { void MatrixTest::copy() { Matrix4 m1(false); - m1.set(3, 2, 1.0f); + m1[2][3] = 1.0f; /* Copy */ Matrix4 m2(m1); Matrix4 m3; - m3.set(0, 0, 1.0f); /* this line is here so it's not optimized to Matrix4 m3(m1) */ + m3[0][0] = 1.0f; /* this line is here so it's not optimized to Matrix4 m3(m1) */ m3 = m1; /* Change original */ - m1.set(2, 3, 1.0f); + m1[3][2] = 1.0f; /* Verify the copy is the same as original */ Matrix4 original(false); - original.set(3, 2, 1.0f); + original[2][3] = 1.0f; QVERIFY(m2 == original); QVERIFY(m3 == original); @@ -207,7 +206,7 @@ void MatrixTest::ij() { 12.0f, 13.0f, 15.0f ); - QVERIFY(original.ij(2, 1) == skipped); + QVERIFY(original.ij(1, 2) == skipped); } void MatrixTest::determinant() { diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index bb9e98de4..59820d698 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -40,45 +40,29 @@ void VectorTest::construct() { void VectorTest::data() { Vector4 v; - v.set(2, 1.0f); - v.add(2, 0.5f); + v[2] = 1.5f; - v.set(0, 1.0f); + v[0] = 1.0f; QVERIFY(v == Vector4(1.0f, 0.0f, 1.5f, 0.0f)); } -void VectorTest::bracketOperator() { - Vector4 v1, v2; - v1.set(0, 1.0f); - v1.set(1, v1.at(0)); - v1.set(3, 0.5f); - v1.add(3, 2.5f); - - v2[0] = 1.0f; - v2[1] = v2[0]; - v2[3] = 0.5f; - v2[3] += 2.5f; - - QVERIFY(v1 == v2); -} - void VectorTest::copy() { Vector4 v1; - v1.set(3, 1.0f); + v1[3] = 1.0f; Vector4 v2(v1); Vector4 v3; - v3.set(0, 0.0f); /* this line is here so it's not optimized to Vector4 v3(v1) */ + v3[0] = 0.0f; /* this line is here so it's not optimized to Vector4 v3(v1) */ v3 = v1; /* Change original */ - v1.set(2, 1.0f); + v1[2] = 1.0f; /* Verify the copy is the same as original original */ Vector4 original; - original.set(3, 1.0f); + original[3] = 1.0f; QVERIFY(v2 == original); QVERIFY(v3 == original); diff --git a/src/Math/Test/VectorTest.h b/src/Math/Test/VectorTest.h index 7ec8c2edb..70c7222e3 100644 --- a/src/Math/Test/VectorTest.h +++ b/src/Math/Test/VectorTest.h @@ -25,7 +25,6 @@ class VectorTest: public QObject { private slots: void construct(); void data(); - void bracketOperator(); void copy(); void dot(); void multiplyDivide(); diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 5b6e1ad4f..b8673a058 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -91,27 +91,17 @@ template class Vector { * @brief Raw data * @return Array with the same size as the vector */ - inline constexpr const T* data() const { return _data; } + inline T* data() { return _data; } + inline constexpr const T* data() const { return _data; } /**< @copydoc data() */ /** @brief Value at given position */ - inline constexpr T at(size_t pos) const { return _data[pos]; } - - /** @brief Value at given position */ - inline constexpr T operator[](size_t pos) const { return _data[pos]; } - - /** @brief Reference to value at given position */ inline T& operator[](size_t pos) { return _data[pos]; } - - /** @brief Set value at given position */ - inline void set(size_t pos, T value) { _data[pos] = value; } - - /** @brief Add value to given position */ - inline void add(size_t pos, T value) { _data[pos] += value; } + inline constexpr T operator[](size_t pos) const { return _data[pos]; } /**< @copydoc operator[]() */ /** @brief Equality operator */ inline bool operator==(const Vector& other) const { for(size_t pos = 0; pos != size; ++pos) - if(!TypeTraits::equals(at(pos), other.at(pos))) return false; + if(!TypeTraits::equals((*this)[pos], other[pos])) return false; return true; } @@ -126,7 +116,7 @@ template class Vector { T out(0); for(size_t i = 0; i != size; ++i) - out += at(i)*other.at(i); + out += (*this)[i]*other[i]; return out; } @@ -144,7 +134,8 @@ template class Vector { */ Vector& operator*=(T number) { for(size_t i = 0; i != size; ++i) - set(i, at(i)*number); + (*this)[i] *= number; + return *this; } @@ -161,7 +152,8 @@ template class Vector { */ Vector& operator/=(T number) { for(size_t i = 0; i != size; ++i) - set(i, at(i)/number); + (*this)[i] /= number; + return *this; } @@ -178,7 +170,8 @@ template class Vector { */ Vector& operator+=(const Vector& other) { for(size_t i = 0; i != size; ++i) - set(i, at(i)+other.at(i)); + (*this)[i] += other[i]; + return *this; } @@ -195,7 +188,8 @@ template class Vector { */ Vector& operator-=(const Vector& other) { for(size_t i = 0; i != size; ++i) - set(i, at(i)-other.at(i)); + (*this)[i] -= other[i]; + return *this; } @@ -204,7 +198,7 @@ template class Vector { Vector out; for(size_t i = 0; i != size; ++i) - out.set(i, -at(i)); + out[i] = -(*this)[i]; return out; } @@ -224,7 +218,7 @@ template class Vector { T out = 1; for(size_t i = 0; i != size; ++i) - out *= at(i); + out *= (*this)[i]; return out; } @@ -239,7 +233,7 @@ template Corrade::Utility::Debug operator<<(Corrade::Utili debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); for(size_t i = 0; i != size; ++i) { if(i != 0) debug << ", "; - debug << value.at(i); + debug << value[i]; } debug << ')'; debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true); diff --git a/src/Math/Vector2.h b/src/Math/Vector2.h index 7dbba24f4..de7dc7b04 100644 --- a/src/Math/Vector2.h +++ b/src/Math/Vector2.h @@ -49,11 +49,11 @@ template class Vector2: public Vector { */ inline constexpr Vector2(T x, T y): Vector(x, y) {} - inline constexpr T x() const { return Vector::at(0); } /**< @brief X component */ - inline constexpr T y() const { return Vector::at(1); } /**< @brief Y component */ + inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ + inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ - inline void setX(T value) { this->set(0, value); } /**< @brief Set X component */ - inline void setY(T value) { this->set(1, value); } /**< @brief Set Y component */ + inline void setX(T value) { (*this)[0] = value; } /**< @brief Set X component */ + inline void setY(T value) { (*this)[1] = value; } /**< @brief Set Y component */ /** @copydoc Vector::operator=() */ inline Vector2& operator=(const Vector& other) { return Vector::operator=(other); } diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 8c92a5215..9926fa8ba 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -73,21 +73,21 @@ template class Vector3: public Vector { */ inline constexpr Vector3(const Vector& other, T z = T(0)): Vector(other[0], other[1], z) {} - inline constexpr T x() const { return Vector::at(0); } /**< @brief X component */ - inline constexpr T y() const { return Vector::at(1); } /**< @brief Y component */ - inline constexpr T z() const { return Vector::at(2); } /**< @brief Z component */ + inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ + inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ + inline constexpr T z() const { return (*this)[2]; } /**< @brief Z component */ - inline void setX(T value) { this->set(0, value); } /**< @brief Set X component */ - inline void setY(T value) { this->set(1, value); } /**< @brief Set Y component */ - inline void setZ(T value) { this->set(2, value); } /**< @brief Set Z component */ + inline void setX(T value) { (*this)[0] = value; } /**< @brief Set X component */ + inline void setY(T value) { (*this)[1] = value; } /**< @brief Set Y component */ + inline void setZ(T value) { (*this)[2] = value; } /**< @brief Set Z component */ - inline constexpr T r() const { return x(); } /**< @brief R component */ - inline constexpr T g() const { return x(); } /**< @brief G component */ - inline constexpr T b() const { return z(); } /**< @brief B component */ + inline constexpr T r() const { return x(); } /**< @brief R component */ + inline constexpr T g() const { return x(); } /**< @brief G component */ + inline constexpr T b() const { return z(); } /**< @brief B component */ - inline void setR(T value) { setX(value); } /**< @brief Set R component */ - inline void setG(T value) { setY(value); } /**< @brief Set G component */ - inline void setB(T value) { setZ(value); } /**< @brief Set B component */ + inline void setR(T value) { setX(value); } /**< @brief Set R component */ + inline void setG(T value) { setY(value); } /**< @brief Set G component */ + inline void setB(T value) { setZ(value); } /**< @brief Set B component */ /** @copydoc Vector::operator=() */ inline Vector3& operator=(const Vector& other) { return Vector::operator=(other); } diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index 403e08332..2b4505539 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -65,15 +65,15 @@ template class Vector4: public Vector { */ inline constexpr Vector4(const Vector& other, T w = T(1)): Vector(other[0], other[1], other[2], w) {} - inline constexpr T x() const { return Vector::at(0); } /**< @brief X component */ - inline constexpr T y() const { return Vector::at(1); } /**< @brief Y component */ - inline constexpr T z() const { return Vector::at(2); } /**< @brief Z component */ - inline constexpr T w() const { return Vector::at(3); } /**< @brief W component */ + inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ + inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ + inline constexpr T z() const { return (*this)[2]; } /**< @brief Z component */ + inline constexpr T w() const { return (*this)[3]; } /**< @brief W component */ - inline void setX(T value) { this->set(0, value); } /**< @brief Set X component */ - inline void setY(T value) { this->set(1, value); } /**< @brief Set Y component */ - inline void setZ(T value) { this->set(2, value); } /**< @brief Set Z component */ - inline void setW(T value) { this->set(3, value); } /**< @brief Set W component */ + inline void setX(T value) { (*this)[0] = value; } /**< @brief Set X component */ + inline void setY(T value) { (*this)[1] = value; } /**< @brief Set Y component */ + inline void setZ(T value) { (*this)[2] = value; } /**< @brief Set Z component */ + inline void setW(T value) { (*this)[3] = value; } /**< @brief Set W component */ /** * @brief XYZ part of the vector @@ -81,15 +81,15 @@ template class Vector4: public Vector { */ inline constexpr Vector3 xyz() const { return Vector3::from(Vector::data()); } - inline constexpr T r() const { return x(); } /**< @brief R component */ - inline constexpr T g() const { return y(); } /**< @brief G component */ - inline constexpr T b() const { return z(); } /**< @brief B component */ - inline constexpr T a() const { return w(); } /**< @brief A component */ + inline constexpr T r() const { return x(); } /**< @brief R component */ + inline constexpr T g() const { return y(); } /**< @brief G component */ + inline constexpr T b() const { return z(); } /**< @brief B component */ + inline constexpr T a() const { return w(); } /**< @brief A component */ - inline void setR(T value) { setX(value); } /**< @brief Set R component */ - inline void setG(T value) { setY(value); } /**< @brief Set G component */ - inline void setB(T value) { setZ(value); } /**< @brief Set B component */ - inline void setA(T value) { setA(value); } /**< @brief Set A component */ + inline void setR(T value) { setX(value); } /**< @brief Set R component */ + inline void setG(T value) { setY(value); } /**< @brief Set G component */ + inline void setB(T value) { setZ(value); } /**< @brief Set B component */ + inline void setA(T value) { setA(value); } /**< @brief Set A component */ /** * @brief RGB part of the vector