diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index b1f93a472..56eb0083b 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -160,6 +160,11 @@ void VectorTest::lerp() { Vector3 b(3.0f, -2.0f, 11.0f); CORRADE_COMPARE(Vector3::lerp(a, b, 0.25f), Vector3(0.0f, 1.0f, 5.0f)); + + typedef Math::Vector<3, std::int32_t> Vector3ub; + Vector3ub c(0, 128, 64); + Vector3ub d(16, 0, 32); + CORRADE_COMPARE(Vector3ub::lerp(c, d, 0.25f), Vector3ub(4, 96, 56)); } void VectorTest::debug() { diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 6d25c787c..d7b1b6d78 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -79,8 +79,8 @@ template class Vector: public RectangularMatrix<1, si * @todo http://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/ * (when SIMD is in place) */ - inline static Vector lerp(const Vector& a, const Vector& b, T t) { - return (T(1) - t)*a + t*b; + template inline static Vector lerp(const Vector& a, const Vector& b, U t) { + return (U(1) - t)*a + t*b; } /** @brief Default constructor */ @@ -358,7 +358,7 @@ extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utilit template inline constexpr static Type from(const Math::Vector& other) { \ return Math::Vector::from(other); \ } \ - inline static const Type lerp(const Math::Vector& a, const Math::Vector& b, T t) { \ + template inline static const Type lerp(const Math::Vector& a, const Math::Vector& b, U t) { \ return Math::Vector::lerp(a, b, t); \ } \ \