diff --git a/src/Magnum/Math/Swizzle.h b/src/Magnum/Math/Swizzle.h index caa3feded..976a1913f 100644 --- a/src/Magnum/Math/Swizzle.h +++ b/src/Magnum/Math/Swizzle.h @@ -38,7 +38,7 @@ namespace Implementation { static_assert(size > position, "swizzle parameter out of range of gather vector"); template constexpr static T value(const Math::Vector& vector) { - return vector[position]; + return vector._data[position]; } }; @@ -70,7 +70,7 @@ namespace Implementation { "swizzle parameter out of range of scatter vector"); template constexpr static T value(const Math::Vector& vector, const T&) { - return vector[i]; + return vector._data[i]; } }; template struct Value { diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index d83712d3a..2a1a3c39e 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -81,6 +81,9 @@ namespace Implementation { /* Used to make friends to speed up debug builds */ template struct MatrixDeterminant; + /* To make gather() / scatter() faster */ + template struct ComponentAtPosition; + template struct ComponentOr; } /** @relatesalso Vector @@ -652,6 +655,9 @@ template class Vector { template friend class RectangularMatrix; template friend class Matrix; template friend struct Implementation::MatrixDeterminant; + /* To make gather() / scatter() faster */ + template friend struct Implementation::ComponentAtPosition; + template friend struct Implementation::ComponentOr; /* So the out-of-class comparators can access data directly to avoid function call overhead */