Browse Source

MeshTools: allow views to be passed to the transform*() functions.

Before, the functions didn't accept a r-value view. Now they do, and
they also still accept l-values.

However, for a proper thing I should be making those non-templated,
specialized for Float and Double and implemented using SIMD. Well,
later.
pull/392/head
Vladimír Vondruš 7 years ago
parent
commit
f4e409bfd9
  1. 16
      src/Magnum/MeshTools/Transform.h

16
src/Magnum/MeshTools/Transform.h

@ -55,22 +55,22 @@ Example usage:
@ref Quaternion::transformVectorNormalized() @ref Quaternion::transformVectorNormalized()
@todo GPU transform feedback implementation (otherwise this is only bad joke) @todo GPU transform feedback implementation (otherwise this is only bad joke)
*/ */
template<class T, class U> void transformVectorsInPlace(const Math::Matrix4<T>& matrix, U& vectors) { template<class T, class U> void transformVectorsInPlace(const Math::Matrix4<T>& matrix, U&& vectors) {
for(auto& vector: vectors) vector = matrix.transformVector(vector); for(auto& vector: vectors) vector = matrix.transformVector(vector);
} }
/** @overload */ /** @overload */
template<class T, class U> void transformVectorsInPlace(const Math::Matrix3<T>& matrix, U& vectors) { template<class T, class U> void transformVectorsInPlace(const Math::Matrix3<T>& matrix, U&& vectors) {
for(auto& vector: vectors) vector = matrix.transformVector(vector); for(auto& vector: vectors) vector = matrix.transformVector(vector);
} }
/** @overload */ /** @overload */
template<class T, class U> void transformVectorsInPlace(const Math::Complex<T>& complex, U& vectors) { template<class T, class U> void transformVectorsInPlace(const Math::Complex<T>& complex, U&& vectors) {
for(auto& vector: vectors) vector = complex.transformVector(vector); for(auto& vector: vectors) vector = complex.transformVector(vector);
} }
/** @overload */ /** @overload */
template<class T, class U> void transformVectorsInPlace(const Math::Quaternion<T>& normalizedQuaternion, U& vectors) { template<class T, class U> void transformVectorsInPlace(const Math::Quaternion<T>& normalizedQuaternion, U&& vectors) {
for(auto& vector: vectors) vector = normalizedQuaternion.transformVectorNormalized(vector); for(auto& vector: vectors) vector = normalizedQuaternion.transformVectorNormalized(vector);
} }
@ -106,22 +106,22 @@ Example usage:
@ref Matrix4::transformPoint(), @ref Matrix4::transformPoint(),
@ref DualQuaternion::transformPointNormalized() @ref DualQuaternion::transformPointNormalized()
*/ */
template<class T, class U> void transformPointsInPlace(const Math::Matrix4<T>& matrix, U& points) { template<class T, class U> void transformPointsInPlace(const Math::Matrix4<T>& matrix, U&& points) {
for(auto& point: points) point = matrix.transformPoint(point); for(auto& point: points) point = matrix.transformPoint(point);
} }
/** @overload */ /** @overload */
template<class T, class U> void transformPointsInPlace(const Math::Matrix3<T>& matrix, U& points) { template<class T, class U> void transformPointsInPlace(const Math::Matrix3<T>& matrix, U&& points) {
for(auto& point: points) point = matrix.transformPoint(point); for(auto& point: points) point = matrix.transformPoint(point);
} }
/** @overload */ /** @overload */
template<class T, class U> void transformPointsInPlace(const Math::DualComplex<T>& dualComplex, U& points) { template<class T, class U> void transformPointsInPlace(const Math::DualComplex<T>& dualComplex, U&& points) {
for(auto& point: points) point = dualComplex.transformPoint(point); for(auto& point: points) point = dualComplex.transformPoint(point);
} }
/** @overload */ /** @overload */
template<class T, class U> void transformPointsInPlace(const Math::DualQuaternion<T>& normalizedDualQuaternion, U& points) { template<class T, class U> void transformPointsInPlace(const Math::DualQuaternion<T>& normalizedDualQuaternion, U&& points) {
for(auto& point: points) point = normalizedDualQuaternion.transformPointNormalized(point); for(auto& point: points) point = normalizedDualQuaternion.transformPointNormalized(point);
} }

Loading…
Cancel
Save