Browse Source

Math: avoid dependency on Functions.h in DualQuaternion.h.

Is it still justifiable to do things like this or am I too paranoid
about compilation times now?
pull/126/head
Vladimír Vondruš 11 years ago
parent
commit
6e73dee096
  1. 6
      src/Magnum/Math/DualQuaternion.h
  2. 4
      src/Magnum/Math/Functions.h
  3. 4
      src/Magnum/Math/Vector.h

6
src/Magnum/Math/DualQuaternion.h

@ -34,7 +34,6 @@
#include "Magnum/Math/Dual.h" #include "Magnum/Math/Dual.h"
#include "Magnum/Math/Matrix4.h" #include "Magnum/Math/Matrix4.h"
#include "Magnum/Math/Quaternion.h" #include "Magnum/Math/Quaternion.h"
#include "Magnum/Math/Functions.h"
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
@ -70,9 +69,8 @@ template<class T> inline DualQuaternion<T> sclerp(const DualQuaternion<T>& norma
/* Avoid division by zero */ /* Avoid division by zero */
const T cosHalfAngle = dotResult + normalizedA.real().scalar()*normalizedB.real().scalar(); const T cosHalfAngle = dotResult + normalizedA.real().scalar()*normalizedB.real().scalar();
if(std::abs(cosHalfAngle) >= T(1)) { if(std::abs(cosHalfAngle) >= T(1))
return DualQuaternion<T>{normalizedA.real(), Quaternion<T>{Math::lerp(normalizedA.dual().vector(), normalizedB.dual().vector(), t), T(0)}}; return {normalizedA.real(), {Implementation::lerp(normalizedA.dual().vector(), normalizedB.dual().vector(), t), T(0)}};
}
/* l + εm = q_A^**q_B, multiplying with -1 ensures shortest path when dot < 0 */ /* l + εm = q_A^**q_B, multiplying with -1 ensures shortest path when dot < 0 */
const DualQuaternion<T> diff = normalizedA.quaternionConjugated()*(dotResult < T(0) ? -normalizedB : normalizedB); const DualQuaternion<T> diff = normalizedA.quaternionConjugated()*(dotResult < T(0) ? -normalizedB : normalizedB);

4
src/Magnum/Math/Functions.h

@ -437,10 +437,10 @@ The interpolation for vectors is done as in following, similarly for scalars: @f
template<class T, class U> inline T lerp(const T& a, const T& b, U t); template<class T, class U> inline T lerp(const T& a, const T& b, U t);
#else #else
template<class T, class U> inline typename std::enable_if<!Implementation::IsBoolVector<U>::value, T>::type lerp(T a, T b, U t) { template<class T, class U> inline typename std::enable_if<!Implementation::IsBoolVector<U>::value, T>::type lerp(T a, T b, U t) {
return T((U(1) - t)*a + t*b); return T(Implementation::lerp(a, b, t));
} }
template<std::size_t size, class T, class U> inline typename std::enable_if<!Implementation::IsBoolVector<U>::value, Vector<size, T>>::type lerp(const Vector<size, T>& a, const Vector<size, T>& b, U t) { template<std::size_t size, class T, class U> inline typename std::enable_if<!Implementation::IsBoolVector<U>::value, Vector<size, T>>::type lerp(const Vector<size, T>& a, const Vector<size, T>& b, U t) {
return (U(1) - t)*a + t*b; return Implementation::lerp(a, b, t);
} }
#endif #endif

4
src/Magnum/Math/Vector.h

@ -50,6 +50,10 @@ namespace Magnum { namespace Math {
namespace Implementation { namespace Implementation {
template<std::size_t, class, class> struct VectorConverter; template<std::size_t, class, class> struct VectorConverter;
/* Needed by DualQuaternion and Functions.h (to avoid dependency between them) */
template<class T> T lerp(const T& a, const T& b, U t) {
return T((U(1) - t)*a + t*b);
}
} }
/** @relatesalso Vector /** @relatesalso Vector

Loading…
Cancel
Save