2
0
Panagiotis Christopoulos Charitos 13 жил өмнө
parent
commit
6b3fe96b06
39 өөрчлөгдсөн 298 нэмэгдсэн , 284 устгасан
  1. 1 1
      include/anki/collision/Sphere.h
  2. 1 1
      include/anki/math/Axisang.h
  3. 14 14
      include/anki/math/Axisang.inl.h
  4. 2 2
      include/anki/math/CommonIncludes.h
  5. 1 2
      include/anki/math/CommonSrc.h
  6. 2 2
      include/anki/math/Euler.h
  7. 5 5
      include/anki/math/Euler.inl.h
  8. 1 1
      include/anki/math/F16.h
  9. 3 3
      include/anki/math/F16.inl.h
  10. 94 0
      include/anki/math/Functions.h
  11. 3 3
      include/anki/math/Mat3.h
  12. 15 15
      include/anki/math/Mat3.inl.h
  13. 4 4
      include/anki/math/Mat4.h
  14. 8 8
      include/anki/math/Mat4.inl.h
  15. 3 55
      include/anki/math/Math.h
  16. 0 70
      include/anki/math/Math.inl.h
  17. 1 1
      include/anki/math/Quat.h
  18. 19 19
      include/anki/math/Quat.inl.h
  19. 0 0
      include/anki/math/Simd.h
  20. 11 2
      include/anki/math/Transform.h
  21. 25 5
      include/anki/math/Transform.inl.h
  22. 2 2
      include/anki/math/Vec2.h
  23. 4 4
      include/anki/math/Vec2.inl.h
  24. 2 2
      include/anki/math/Vec3.h
  25. 6 6
      include/anki/math/Vec3.inl.h
  26. 2 2
      include/anki/math/Vec4.h
  27. 6 6
      include/anki/math/Vec4.inl.h
  28. 4 4
      src/collision/CollisionAlgorithmsMatrix.cpp
  29. 3 3
      src/collision/Frustum.cpp
  30. 1 1
      src/collision/Obb.cpp
  31. 3 3
      src/collision/Plane.cpp
  32. 25 11
      src/math/Functions.cpp
  33. 2 2
      src/renderer/Dbg.cpp
  34. 6 6
      src/renderer/Drawer.cpp
  35. 1 1
      src/resource/MeshLoader.cpp
  36. 3 3
      src/resource/ParticleEmitterRsrc.cpp
  37. 1 1
      src/scene/Light.cpp
  38. 3 3
      src/scene/SkinNode.cpp
  39. 11 11
      testapp/Main.cpp

+ 1 - 1
include/anki/collision/Sphere.h

@@ -155,7 +155,7 @@ void Sphere::set(const Container& container)
 		}
 	}
 
-	radius = Math::sqrt(maxDist);
+	radius = sqrt(maxDist);
 }
 
 } // end namespace

+ 1 - 1
include/anki/math/Axisang.h

@@ -2,7 +2,7 @@
 #define ANKI_MATH_AXISANG_H
 
 #include "anki/math/Vec3.h"
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 

+ 14 - 14
include/anki/math/Axisang.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -25,8 +25,8 @@ inline Axisang::Axisang(const F32 rad, const Vec3& axis_)
 inline Axisang::Axisang(const Quat& q)
 {
 	ang = 2.0 * acos(q.w());
-	F32 length = Math::sqrt(1.0 - q.w() * q.w());
-	if(Math::isZero(length))
+	F32 length = sqrt(1.0 - q.w() * q.w());
+	if(isZero(length))
 	{
 		axis = Vec3(0.0);
 	}
@@ -40,9 +40,9 @@ inline Axisang::Axisang(const Quat& q)
 // constructor [mat3]
 inline Axisang::Axisang(const Mat3& m3)
 {
-	if((fabs(m3(0, 1) - m3(1, 0)) < Math::EPSILON) 
-		&&(fabs(m3(0, 2) - m3(2, 0)) < Math::EPSILON) 
-		&& (fabs(m3(1, 2) - m3(2, 1)) < Math::EPSILON))
+	if((fabs(m3(0, 1) - m3(1, 0)) < getEpsilon<F32>()) 
+		&&(fabs(m3(0, 2) - m3(2, 0)) < getEpsilon<F32>()) 
+		&& (fabs(m3(1, 2) - m3(2, 1)) < getEpsilon<F32>()))
 	{
 
 		if((fabs(m3(0, 1) + m3(1, 0)) < 0.1) 
@@ -55,11 +55,11 @@ inline Axisang::Axisang(const Mat3& m3)
 			return;
 		}
 
-		ang = Math::PI;
+		ang = getPi<F32>();
 		axis.x() = (m3(0, 0)+1) / 2.0;
 		if(axis.x() > 0.0)
 		{
-			axis.x() = Math::sqrt(axis.x());
+			axis.x() = sqrt(axis.x());
 		}
 		else
 		{
@@ -68,7 +68,7 @@ inline Axisang::Axisang(const Mat3& m3)
 		axis.y() = (m3(1, 1)+1)/2;
 		if(axis.y() > 0)
 		{
-			axis.y() = Math::sqrt(axis.y());
+			axis.y() = sqrt(axis.y());
 		}
 		else
 		{
@@ -78,16 +78,16 @@ inline Axisang::Axisang(const Mat3& m3)
 		axis.z() = (m3(2, 2)+1)/2;
 		if(axis.z() > 0)
 		{
-			axis.z() = Math::sqrt(axis.z());
+			axis.z() = sqrt(axis.z());
 		}
 		else
 		{
 			axis.z() = 0.0;
 		}
 
-		Bool xZero = (fabs(axis.x()) < Math::EPSILON);
-		Bool yZero = (fabs(axis.y()) < Math::EPSILON);
-		Bool zZero = (fabs(axis.z()) < Math::EPSILON);
+		Bool xZero = (fabs(axis.x()) < getEpsilon<F32>());
+		Bool yZero = (fabs(axis.y()) < getEpsilon<F32>());
+		Bool zZero = (fabs(axis.z()) < getEpsilon<F32>());
 		Bool xyPositive = (m3(0, 1) > 0);
 		Bool xzPositive = (m3(0, 2) > 0);
 		Bool yzPositive = (m3(1, 2) > 0);
@@ -116,7 +116,7 @@ inline Axisang::Axisang(const Mat3& m3)
 		return;
 	}
 
-	F32 s = Math::sqrt((m3(2, 1) - m3(1, 2)) * (m3(2, 1) - m3(1, 2)) 
+	F32 s = sqrt((m3(2, 1) - m3(1, 2)) * (m3(2, 1) - m3(1, 2)) 
 		+ (m3(0, 2) - m3(2, 0)) * (m3(0, 2) - m3(2, 0)) 
 		+ (m3(1, 0) - m3(0, 1)) * (m3(1, 0) - m3(0, 1)));
 

+ 2 - 2
include/anki/math/MathCommonIncludes.h → include/anki/math/CommonIncludes.h

@@ -1,5 +1,5 @@
 #include "anki/math/Forward.h"
-#include "anki/math/MathSimd.h"
+#include "anki/math/Simd.h"
 #include "anki/util/StdTypes.h"
-#include <array>
+#include "anki/util/Array.h"
 #include <iosfwd>

+ 1 - 2
include/anki/math/MathCommonSrc.h → include/anki/math/CommonSrc.h

@@ -8,8 +8,7 @@
 #include "anki/math/Mat4.h"
 #include "anki/math/Transform.h"
 #include "anki/math/F16.h"
-#include "anki/math/Math.h"
+#include "anki/math/Functions.h"
 
 #include "anki/util/Assert.h"
-#include <cmath>
 #include <iostream>

+ 2 - 2
include/anki/math/Euler.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_EULER_H
 #define ANKI_MATH_EULER_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -54,7 +54,7 @@ private:
 			F32 x, y, z;
 		} vec;
 
-		std::array<F32, 3> arr;
+		Array<F32, 3> arr;
 	};
 	/// @}
 };

+ 5 - 5
include/anki/math/Euler.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -35,14 +35,14 @@ inline Euler::Euler(const Quat& q)
 	if(test > 0.499)
 	{
 		y() = 2.0 * atan2(q.x(), q.w());
-		z() = Math::PI / 2.0;
+		z() = getPi<F32>() / 2.0;
 		x() = 0.0;
 		return;
 	}
 	if(test < -0.499)
 	{
 		y() = -2.0 * atan2(q.x(), q.w());
-		z() = -Math::PI / 2.0;
+		z() = -getPi<F32>() / 2.0;
 		x() = 0.0;
 		return;
 	}
@@ -65,9 +65,9 @@ inline Euler::Euler(const Mat3& m3)
 	F32 cz, sz;
 
 	sy = m3(0, 2);
-	cy = Math::sqrt(1.0 - sy * sy);
+	cy = sqrt(1.0 - sy * sy);
 	// normal case
-	if (!Math::isZero(cy))
+	if (!isZero(cy))
 	{
 		F32 factor = 1.0/cy;
 		sx = -m3(1, 2) * factor;

+ 1 - 1
include/anki/math/F16.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_F16_H
 #define ANKI_MATH_F16_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 

+ 3 - 3
include/anki/math/F16.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -163,13 +163,13 @@ inline F16& F16::operator/=(const F32 b)
 // ==
 inline Bool F16::operator==(const F32 b) const
 {
-	return Math::isZero(toF32() - b);
+	return isZero(toF32() - b);
 }
 
 // !=
 inline Bool F16::operator!=(const F32 b) const
 {
-	return !Math::isZero(toF32() - b);
+	return !isZero(toF32() - b);
 }
 
 //==============================================================================

+ 94 - 0
include/anki/math/Functions.h

@@ -0,0 +1,94 @@
+#ifndef ANKI_MATH_FUNCTIONS_H
+#define ANKI_MATH_FUNCTIONS_H
+
+#include "anki/util/StdTypes.h"
+#include <cmath>
+
+namespace anki {
+
+template<typename Scalar>
+constexpr Scalar getPi();
+
+template<>
+inline constexpr F32 getPi<F32>()
+{
+	return 3.14159265358979323846f;
+}
+
+template<>
+inline constexpr F64 getPi<F64>()
+{
+	return 3.14159265358979323846;
+}
+
+template<typename Scalar>
+constexpr Scalar getEpsilon();
+
+template<>
+constexpr F32 getEpsilon<F32>()
+{
+	return 1.0e-6f;
+}
+
+template<>
+constexpr F64 getEpsilon<F64>()
+{
+	return 1.0e-6;
+}
+
+inline Bool isZero(const F32 f)
+{
+	return fabs(f) < getEpsilon<F32>();
+}
+
+inline Bool isZero(const F64 f)
+{
+	return fabs(f) < getEpsilon<F64>();
+}
+
+inline F32 toRad(const F32 degrees)
+{
+	return degrees * (getPi<F32>() / 180.0f);
+}
+
+inline F64 toRad(const F64 degrees)
+{
+	return degrees * (getPi<F64>() / 180.0);
+}
+
+inline F32 toDegrees(const F32 rad)
+{
+	return rad * (180.0f / getPi<F32>());
+}
+
+inline F64 toDegrees(const F64 rad)
+{
+	return rad * (180.0 / getPi<F64>());
+}
+
+inline F32 sin(const F32 rad)
+{
+	return ::sin(rad);
+}
+
+inline F64 sin(const F64 rad)
+{
+	return ::sin(rad);
+}
+
+inline F32 cos(const F32 rad)
+{
+	return ::cos(rad);
+}
+
+inline F64 cos(const F64 rad)
+{
+	return ::cos(rad);
+}
+
+void sinCos(const F32 a, F32& sina, F32& cosa);
+void sinCos(const F64 a, F64& sina, F64& cosa);
+
+} // end namespace anki
+
+#endif

+ 3 - 3
include/anki/math/Mat3.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_MAT3_H
 #define ANKI_MATH_MAT3_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -118,8 +118,8 @@ private:
 	/// @{
 	union
 	{
-		std::array<F32, 9> arr1;
-		std::array<std::array<F32, 3>, 3> arr2;
+		Array<F32, 9> arr1;
+		Array<Array<F32, 3>, 3> arr2;
 		F32 carr1[9]; ///< For gdb
 		F32 carr2[3][3]; ///< For gdb
 	};

+ 15 - 15
include/anki/math/Mat3.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -87,9 +87,9 @@ inline Mat3::Mat3(const Quat& q)
 inline Mat3::Mat3(const Euler& e)
 {
 	F32 ch, sh, ca, sa, cb, sb;
-	Math::sinCos(e.y(), sh, ch);
-	Math::sinCos(e.z(), sa, ca);
-	Math::sinCos(e.x(), sb, cb);
+	sinCos(e.y(), sh, ch);
+	sinCos(e.z(), sa, ca);
+	sinCos(e.x(), sb, cb);
 
 	(*this)(0, 0) = ch * ca;
 	(*this)(0, 1) = sh * sb - ch * sa * cb;
@@ -106,10 +106,10 @@ inline Mat3::Mat3(const Euler& e)
 inline Mat3::Mat3(const Axisang& axisang)
 {
 	// Not normalized axis
-	ANKI_ASSERT(Math::isZero(1.0 - axisang.getAxis().getLength()));
+	ANKI_ASSERT(isZero(1.0 - axisang.getAxis().getLength()));
 
 	F32 c, s;
-	Math::sinCos(axisang.getAngle(), s, c);
+	sinCos(axisang.getAngle(), s, c);
 	F32 t = 1.0 - c;
 
 	const Vec3& axis = axisang.getAxis();
@@ -248,7 +248,7 @@ inline Bool Mat3::operator==(const Mat3& b) const
 {
 	for(U i = 0; i < 9; i++)
 	{
-		if(!Math::isZero((*this)[i] - b[i]))
+		if(!isZero((*this)[i] - b[i]))
 		{
 			return false;
 		}
@@ -261,7 +261,7 @@ inline Bool Mat3::operator!=(const Mat3& b) const
 {
 	for(U i = 0; i < 9; i++)
 	{
-		if(!Math::isZero((*this)[i] - b[i]))
+		if(!isZero((*this)[i] - b[i]))
 		{
 			return true;
 		}
@@ -498,7 +498,7 @@ inline void Mat3::setZAxis(const Vec3& v3)
 inline void Mat3::setRotationX(const F32 rad)
 {
 	F32 sintheta, costheta;
-	Math::sinCos(rad, sintheta, costheta);
+	sinCos(rad, sintheta, costheta);
 
 	(*this)(0, 0) = 1.0;
 	(*this)(0, 1) = 0.0;
@@ -515,7 +515,7 @@ inline void Mat3::setRotationX(const F32 rad)
 inline void Mat3::setRotationY(const F32 rad)
 {
 	F32 sintheta, costheta;
-	Math::sinCos(rad, sintheta, costheta);
+	sinCos(rad, sintheta, costheta);
 
 	(*this)(0, 0) = costheta;
 	(*this)(0, 1) = 0.0;
@@ -532,7 +532,7 @@ inline void Mat3::setRotationY(const F32 rad)
 inline void Mat3::setRotationZ(const F32 rad)
 {
 	F32 sintheta, costheta;
-	Math::sinCos(rad, sintheta, costheta);
+	sinCos(rad, sintheta, costheta);
 
 	(*this)(0, 0) = costheta;
 	(*this)(0, 1) = -sintheta;
@@ -555,7 +555,7 @@ inline void Mat3::rotateXAxis(const F32 rad)
 	// NOTE: See the clean code from < r664
 
 	F32 sina, cosa;
-	Math::sinCos(rad, sina, cosa);
+	sinCos(rad, sina, cosa);
 
 	// zAxis = zAxis*cosa - yAxis*sina;
 	(*this)(0, 2) = (*this)(0, 2) * cosa - (*this)(0, 1) * sina;
@@ -585,7 +585,7 @@ inline void Mat3::rotateYAxis(const F32 rad)
 {
 	// NOTE: See the clean code from < r664
 	F32 sina, cosa;
-	Math::sinCos(rad, sina, cosa);
+	sinCos(rad, sina, cosa);
 
 	// zAxis = zAxis*cosa + xAxis*sina;
 	(*this)(0, 2) = (*this)(0, 2) * cosa + (*this)(0, 0) * sina;
@@ -613,7 +613,7 @@ inline void Mat3::rotateZAxis(const F32 rad)
 {
 	// NOTE: See the clean code from < r664
 	F32 sina, cosa;
-	Math::sinCos(rad, sina, cosa);
+	sinCos(rad, sina, cosa);
 
 	// xAxis = xAxis*cosa + yAxis*sina;
 	(*this)(0, 0) = (*this)(0, 0) * cosa + (*this)(0, 1) * sina;
@@ -710,7 +710,7 @@ inline Mat3 Mat3::getInverse() const
 	F32 det = (*this)(0, 0) * cofactor0 + (*this)(1, 0) * cofactor3
 		+ (*this)(2, 0) * cofactor6;
 
-	ANKI_ASSERT(!Math::isZero(det)); // Cannot invert det == 0
+	ANKI_ASSERT(!isZero(det)); // Cannot invert det == 0
 
 	// create adjoint matrix and multiply by 1/det to get inverse
 	F32 invDet = 1.0 / det;

+ 4 - 4
include/anki/math/Mat4.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_MAT4_H
 #define ANKI_MATH_MAT4_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -121,12 +121,12 @@ private:
 	/// @{
 	union
 	{
-		std::array<F32, 16> arr1;
-		std::array<std::array<F32, 4>, 4> arr2;
+		Array<F32, 16> arr1;
+		Array<Array<F32, 4>, 4> arr2;
 		F32 carr1[16]; ///< For gdb
 		F32 carr2[4][4]; ///< For gdb
 #if defined(ANKI_MATH_SIMD_SSE)
-		std::array<__m128, 4> arrMm;
+		Array<__m128, 4> arrMm;
 #endif
 	};
 	/// @}

+ 8 - 8
include/anki/math/Mat4.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -148,7 +148,7 @@ inline Mat4::Mat4(const Vec3& transl, const Mat3& rot)
 // Vec3, Mat3, F32
 inline Mat4::Mat4(const Vec3& translate, const Mat3& rotate, const F32 scale)
 {
-	if(!Math::isZero(scale - 1.0))
+	if(!isZero(scale - 1.0))
 	{
 		setRotationPart(rotate * scale);
 	}
@@ -335,7 +335,7 @@ inline Bool Mat4::operator==(const Mat4& b) const
 {
 	for(U i = 0; i < 16; i++)
 	{
-		if(!Math::isZero((*this)[i] - b[i]))
+		if(!isZero((*this)[i] - b[i]))
 		{
 			return false;
 		}
@@ -348,7 +348,7 @@ inline Bool Mat4::operator!=(const Mat4& b) const
 {
 	for(U i = 0; i < 16; i++)
 	{
-		if(!Math::isZero((*this)[i]-b[i]))
+		if(!isZero((*this)[i]-b[i]))
 		{
 			return true;
 		}
@@ -777,7 +777,7 @@ inline F32 Mat4::getDet() const
 // getInverse
 inline Mat4 Mat4::getInverse() const
 {
-	std::array<F32, 12> tmp;
+	Array<F32, 12> tmp;
 	const Mat4& in = (*this);
 	Mat4 m4;
 
@@ -844,7 +844,7 @@ inline Mat4 Mat4::getInverse() const
 	F32 det = in(0, 0) * m4(0, 0) + in(1, 0) * m4(0, 1) 
 		+ in(2, 0) * m4(0, 2) + in(3, 0) * m4(0, 3);
 
-	ANKI_ASSERT(!Math::isZero(det)); // Cannot invert, det == 0
+	ANKI_ASSERT(!isZero(det)); // Cannot invert, det == 0
 	det = 1.0 / det;
 	m4 *= det;
 	return m4;
@@ -883,8 +883,8 @@ inline Mat4 Mat4::combineTransformations(const Mat4& m0, const Mat4& m1)
 	// See the clean code in < r664
 
 	// one of the 2 mat4 doesnt represent transformation
-	ANKI_ASSERT(Math::isZero(m0(3, 0) + m0(3, 1) + m0(3, 2) + m0(3, 3) - 1.0)
-		&& Math::isZero(m1(3, 0) + m1(3, 1) + m1(3, 2) + m1(3, 3) - 1.0));
+	ANKI_ASSERT(isZero(m0(3, 0) + m0(3, 1) + m0(3, 2) + m0(3, 3) - 1.0)
+		&& isZero(m1(3, 0) + m1(3, 1) + m1(3, 2) + m1(3, 3) - 1.0));
 
 	Mat4 m4;
 

+ 3 - 55
include/anki/math/Math.h

@@ -1,60 +1,8 @@
 #ifndef ANKI_MATH_MATH_H
 #define ANKI_MATH_MATH_H
 
-#include "anki/math/MathCommonIncludes.h"
-
-namespace anki {
-
-/// @addtogroup Math
-/// @{
-
-/// Useful and optimized math functions
-class Math
-{
-public:
-	static constexpr F32 PI = 3.14159265358979323846;
-	static constexpr F32 EPSILON = 1.0e-6;
-
-	/// A fast func that given the angle in rads it returns the sin and cos
-	static void sinCos(const F32 rad, F32& sin_, F32& cos_);
-
-	/// Optimized square root
-	static F32 sqrt(const F32 f);
-
-	/// Convert
-	static F32 toRad(const F32 degrees);
-
-	/// Convert
-	static F32 toDegrees(const F32 rad);
-
-	/// Optimized sine
-	static F32 sin(const F32 rad);
-
-	/// Optimized cosine
-	static F32 cos(const F32 rad);
-
-	/// The proper way to test if a F32 is zero
-	static Bool isZero(const F32 f);
-
-	/// Mat4(t0,r0,s0) * Mat4(t1, r1, s1) == Mat4(tf, rf, sf)
-	static void combineTransformations(
-		const Vec3& t0, const Mat3& r0, const F32 s0, // in 0
-		const Vec3& t1, const Mat3& r1, const F32 s1, // in 1
-		Vec3& tf, Mat3& rf, F32& sf); // out
-
-	/// Mat4(t0, r0, 1.0) * Mat4(t1, r1, 1.0) == Mat4(tf, rf, sf)
-	static void combineTransformations(
-		const Vec3& t0, const Mat3& r0, // in 0
-		const Vec3& t1, const Mat3& r1, // in 1
-		Vec3& tf, Mat3& rf); // out
-
-private:
-	static F32 polynomialSinQuadrant(const F32 a);
-};
-/// @}
-
-} // end namespace
-
-#include "anki/math/Math.inl.h"
+#include "anki/math/CommonIncludes.h"
+#include "anki/math/CommonSrc.h"
+#include "anki/math/Functions.h"
 
 #endif

+ 0 - 70
include/anki/math/Math.inl.h

@@ -1,70 +0,0 @@
-#include "anki/math/MathCommonSrc.h"
-
-namespace anki {
-
-//==============================================================================
-inline F32 Math::sqrt(const F32 f)
-{
-#if defined(ANKI_MATH_SIMD_SSE)
-	__m128 mm = _mm_set_ss(f);
-	mm = _mm_sqrt_ss(mm);
-	F32 o;
-	_mm_store_ss(&o, mm);
-	return o;
-#else
-	return ::sqrtf(f);
-#endif
-}
-
-//==============================================================================
-inline F32 Math::toRad(const F32 degrees)
-{
-	return degrees * (Math::PI / 180.0);
-}
-
-//==============================================================================
-inline F32 Math::toDegrees(const F32 rad)
-{
-	return rad * (180.0 / Math::PI);
-}
-
-//==============================================================================
-inline F32 Math::sin(const F32 rad)
-{
-	return ::sin(rad);
-}
-
-//==============================================================================
-inline F32 Math::cos(const F32 rad)
-{
-	return ::cos(rad);
-}
-
-//==============================================================================
-inline Bool Math::isZero(const F32 f)
-{
-	return fabs(f) < EPSILON;
-}
-
-//==============================================================================
-inline void Math::combineTransformations(
-	const Vec3& t0, const Mat3& r0, const F32 s0,
-	const Vec3& t1, const Mat3& r1, const F32 s1,
-	Vec3& tf, Mat3& rf, F32& sf)
-{
-	tf = t1.getTransformed(t0, r0, s0);
-	rf = r0 * r1;
-	sf = s0 * s1;
-}
-
-//==============================================================================
-inline void Math::combineTransformations(
-	const Vec3& t0, const Mat3& r0,
-	const Vec3& t1, const Mat3& r1,
-	Vec3& tf, Mat3& rf)
-{
-	tf = t1.getTransformed(t0, r0);
-	rf = r0 * r1;
-}
-
-} // end namespace

+ 1 - 1
include/anki/math/Quat.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_QUAT_H
 #define ANKI_MATH_QUAT_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 

+ 19 - 19
include/anki/math/Quat.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -68,7 +68,7 @@ inline Quat::Quat(const Quat& b)
 inline Quat::Quat(const Mat3& m3)
 {
 	F32 trace = m3(0, 0) + m3(1, 1) + m3(2, 2) + 1.0;
-	if(trace > Math::EPSILON)
+	if(trace > getEpsilon<F32>())
 	{
 		F32 s = 0.5 / sqrt(trace);
 		w() = 0.25 / s;
@@ -109,13 +109,13 @@ inline Quat::Quat(const Mat3& m3)
 inline Quat::Quat(const Euler& eu)
 {
 	F32 cx, sx;
-	Math::sinCos(eu.y() * 0.5, sx, cx);
+	sinCos(eu.y() * 0.5, sx, cx);
 
 	F32 cy, sy;
-	Math::sinCos(eu.z() * 0.5, sy, cy);
+	sinCos(eu.z() * 0.5, sy, cy);
 
 	F32 cz, sz;
-	Math::sinCos(eu.x() * 0.5, sz, cz);
+	sinCos(eu.x() * 0.5, sz, cz);
 
 	F32 cxcy = cx * cy;
 	F32 sxsy = sx * sy;
@@ -129,7 +129,7 @@ inline Quat::Quat(const Euler& eu)
 inline Quat::Quat(const Axisang& axisang)
 {
 	F32 lengthsq = axisang.getAxis().getLengthSquared();
-	if(Math::isZero(lengthsq))
+	if(isZero(lengthsq))
 	{
 		(*this) = getIdentity();
 		return;
@@ -138,7 +138,7 @@ inline Quat::Quat(const Axisang& axisang)
 	F32 rad = axisang.getAngle() * 0.5;
 
 	F32 sintheta, costheta;
-	Math::sinCos(rad, sintheta, costheta);
+	sinCos(rad, sintheta, costheta);
 
 	F32 scalefactor = sintheta / sqrt(lengthsq);
 
@@ -227,19 +227,19 @@ inline Quat& Quat::operator *=(const Quat& b)
 // ==
 inline Bool Quat::operator ==(const Quat& b) const
 {
-	return Math::isZero(x() - b.x()) &&
-		Math::isZero(y() - b.y()) &&
-		Math::isZero(z() - b.z()) &&
-		Math::isZero(w() - b.w());
+	return isZero(x() - b.x()) &&
+		isZero(y() - b.y()) &&
+		isZero(z() - b.z()) &&
+		isZero(w() - b.w());
 }
 
 // !=
 inline Bool Quat::operator !=(const Quat& b) const
 {
-	return !(Math::isZero(x() - b.x()) &&
-		Math::isZero(y() - b.y()) &&
-		Math::isZero(z() - b.z()) &&
-		Math::isZero(w() - b.w()));
+	return !(isZero(x() - b.x()) &&
+		isZero(y() - b.y()) &&
+		isZero(z() - b.z()) &&
+		isZero(w() - b.w()));
 }
 
 //==============================================================================
@@ -275,7 +275,7 @@ inline void Quat::normalize()
 // getLength
 inline F32 Quat::getLength() const
 {
-	return Math::sqrt(w() * w() + x() * x() + y() * y() + z() * z());
+	return sqrt(w() * w() + x() * x() + y() * y() + z() * z());
 }
 
 // getInverted
@@ -283,7 +283,7 @@ inline Quat Quat::getInverted() const
 {
 	F32 norm = w() * w() + x() * x() + y() * y() + z() * z();
 
-	ANKI_ASSERT(!Math::isZero(norm)); // Norm is zero
+	ANKI_ASSERT(!isZero(norm)); // Norm is zero
 
 	F32 normi = 1.0 / norm;
 	return Quat(-normi * x(), -normi * y(), -normi * z(), normi * w());
@@ -303,7 +303,7 @@ inline void Quat::setFrom2Vec3(const Vec3& from, const Vec3& to)
 	normalize();
 	w() += 1.0;
 
-	if(w() <= Math::EPSILON)
+	if(w() <= getEpsilon<F32>())
 	{
 		if(from.z() * from.z() > from.x() * from.x())
 		{
@@ -354,7 +354,7 @@ inline Quat Quat::slerp(const Quat& q1_, const F32 t) const
 	}
 
 	F32 halfTheta = acos(cosHalfTheta);
-	F32 sinHalfTheta = Math::sqrt(1.0 - cosHalfTheta * cosHalfTheta);
+	F32 sinHalfTheta = sqrt(1.0 - cosHalfTheta * cosHalfTheta);
 
 	if(fabs(sinHalfTheta) < 0.001)
 	{

+ 0 - 0
include/anki/math/MathSimd.h → include/anki/math/Simd.h


+ 11 - 2
include/anki/math/Transform.h

@@ -3,7 +3,7 @@
 
 #include "anki/math/Vec3.h"
 #include "anki/math/Mat3.h"
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -49,8 +49,17 @@ public:
 	/// @{
 	void setIdentity();
 	static const Transform& getIdentity();
+
+	static void combineTransformations(
+		const Vec3& t0, const Mat3& r0, const F32 s0,
+		const Vec3& t1, const Mat3& r1, const F32 s1,
+		Vec3& tf, Mat3& rf, F32& sf);
+	static void combineTransformations(
+		const Vec3& t0, const Mat3& r0,
+		const Vec3& t1, const Mat3& r1,
+		Vec3& tf, Mat3& rf);
 	static Transform combineTransformations(const Transform& a,
-		const Transform& b); ///< @copybrief Math::combineTransformations
+		const Transform& b); ///< @copybrief combineTransformations
 
 	/// Get the inverse transformation. Its faster that inverting a Mat4
 	Transform getInverse() const;

+ 25 - 5
include/anki/math/Transform.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -120,16 +120,36 @@ inline const Transform& Transform::getIdentity()
 	return ident;
 }
 
+// combineTransformations
+inline void Transform::combineTransformations(
+	const Vec3& t0, const Mat3& r0, const F32 s0,
+	const Vec3& t1, const Mat3& r1, const F32 s1,
+	Vec3& tf, Mat3& rf, F32& sf)
+{
+	tf = t1.getTransformed(t0, r0, s0);
+	rf = r0 * r1;
+	sf = s0 * s1;
+}
+
+// combineTransformations
+inline void Transform::combineTransformations(
+	const Vec3& t0, const Mat3& r0,
+	const Vec3& t1, const Mat3& r1,
+	Vec3& tf, Mat3& rf)
+{
+	tf = t1.getTransformed(t0, r0);
+	rf = r0 * r1;
+}
+
 // combineTransformations
 inline Transform Transform::combineTransformations(const Transform& a,
 	const Transform& b)
 {
 	Transform out;
 
-	Math::combineTransformations(
-		a.origin, a.rotation, a.scale,
-		b.origin, b.rotation, b.scale,
-		out.origin, out.rotation, out.scale);
+	out.origin = b.origin.getTransformed(a.origin, a.rotation, a.scale);
+	out.rotation = a.rotation * b.rotation;
+	out.scale = a.scale * b.scale;
 
 	return out;
 }

+ 2 - 2
include/anki/math/Vec2.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_VEC2_H
 #define ANKI_MATH_VEC2_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -92,7 +92,7 @@ private:
 			F32 x, y;
 		} vec;
 
-		std::array<F32, 2> arr;
+		Array<F32, 2> arr;
 	};
 	/// @}
 };

+ 4 - 4
include/anki/math/Vec2.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -164,8 +164,8 @@ inline Vec2 Vec2::operator-() const
 // ==
 inline Bool Vec2::operator==(const Vec2& b) const
 {
-	return Math::isZero(x() - b.x()) &&
-		Math::isZero(y() - b.y());
+	return isZero(x() - b.x()) &&
+		isZero(y() - b.y());
 }
 
 // !=
@@ -255,7 +255,7 @@ inline F32 Vec2::getLengthSquared() const
 // getLength
 inline F32 Vec2::getLength() const
 {
-	return Math::sqrt(getLengthSquared());
+	return sqrt(getLengthSquared());
 }
 
 // normalize

+ 2 - 2
include/anki/math/Vec3.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_VEC3_H
 #define ANKI_MATH_VEC3_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -130,7 +130,7 @@ private:
 			F32 x, y, z;
 		} vec;
 
-		std::array<F32, 3> arr;
+		Array<F32, 3> arr;
 	};
 	/// @}
 };

+ 6 - 6
include/anki/math/Vec3.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -197,9 +197,9 @@ inline Vec3 Vec3::operator-() const
 // ==
 inline Bool Vec3::operator==(const Vec3& b) const
 {
-	return Math::isZero(x() - b.x()) 
-		&& Math::isZero(y() - b.y()) 
-		&& Math::isZero(z() - b.z());
+	return isZero(x() - b.x()) 
+		&& isZero(y() - b.y()) 
+		&& isZero(z() - b.z());
 }
 
 // !=
@@ -309,7 +309,7 @@ inline Vec3 Vec3::cross(const Vec3& b) const
 // getLength
 inline F32 Vec3::getLength() const
 {
-	return Math::sqrt(getLengthSquared());
+	return sqrt(getLengthSquared());
 }
 
 // getLengthSquared
@@ -345,7 +345,7 @@ inline Vec3 Vec3::getProjection(const Vec3& toThis) const
 // getRotated
 inline Vec3 Vec3::getRotated(const Quat& q) const
 {
-	ANKI_ASSERT(Math::isZero(1.0 - q.getLength())); // Not normalized quat
+	ANKI_ASSERT(isZero(1.0 - q.getLength())); // Not normalized quat
 	Vec3 qXyz(q);
 	return (*this) + qXyz.cross(qXyz.cross((*this)) + (*this) * q.w()) * 2.0;
 }

+ 2 - 2
include/anki/math/Vec4.h

@@ -1,7 +1,7 @@
 #ifndef ANKI_MATH_VEC4_H
 #define ANKI_MATH_VEC4_H
 
-#include "anki/math/MathCommonIncludes.h"
+#include "anki/math/CommonIncludes.h"
 
 namespace anki {
 
@@ -113,7 +113,7 @@ private:
 			F32 x, y, z, w;
 		} vec;
 
-		std::array<F32, 4> arr;
+		Array<F32, 4> arr;
 
 #if defined(ANKI_MATH_SIMD_SSE)
 		__m128 mm;

+ 6 - 6
include/anki/math/Vec4.inl.h

@@ -1,4 +1,4 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/CommonSrc.h"
 
 namespace anki {
 
@@ -311,10 +311,10 @@ inline Vec4 Vec4::operator-() const
 inline Bool Vec4::operator==(const Vec4& b) const
 {
 	Vec4 sub = (*this) - b;
-	return Math::isZero(sub.x()) 
-		&& Math::isZero(sub.y()) 
-		&& Math::isZero(sub.z()) 
-		&& Math::isZero(sub.w());
+	return isZero(sub.x()) 
+		&& isZero(sub.y()) 
+		&& isZero(sub.z()) 
+		&& isZero(sub.w());
 }
 
 // !=
@@ -424,7 +424,7 @@ inline F32 Vec4::dot(const Vec4& b) const
 // getLength
 inline F32 Vec4::getLength() const
 {
-	return Math::sqrt(dot((*this)));
+	return sqrt(dot((*this)));
 }
 
 // getNormalized

+ 4 - 4
src/collision/CollisionAlgorithmsMatrix.cpp

@@ -98,7 +98,7 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Obb& obb)
 		F32 f = ls.getDirection().dot(axis);
 
 		// ray is parallel to plane
-		if(Math::isZero(f))
+		if(isZero(f))
 		{
 			// ray passes by box
 			if(-e - obb.getExtend()[i] > 0.0 || -e + obb.getExtend()[i] > 0.0)
@@ -195,7 +195,7 @@ bool CollisionAlgorithmsMatrix::collide(const Ls& ls, const Aabb& aabb)
 	for(U i = 0; i < 3; ++i)
 	{
 		// segment is parallel to plane
-		if(Math::isZero(ls.getDirection()[i]))
+		if(isZero(ls.getDirection()[i]))
 		{
 			// segment passes by box
 			if(ls.getOrigin()[i] < aabb.getMin()[i] 
@@ -266,7 +266,7 @@ bool CollisionAlgorithmsMatrix::collide(const Obb& o0, const Obb& o1)
 		{
 			rabs(i, j) = fabs(rt(i, j));
 			// if magnitude of dot product between axes is close to one
-			if(rabs(i, j) + Math::EPSILON >= 1.0)
+			if(rabs(i, j) + getEpsilon<F32>() >= 1.0)
 			{
 				// then box A and box B have near-parallel axes
 				parallelAxes = true;
@@ -571,7 +571,7 @@ bool CollisionAlgorithmsMatrix::collide(const Ray& r, const Aabb& aabb)
 	for(U i = 0; i < 3; ++i)
 	{
 		// ray is parallel to plane
-		if(Math::isZero(r.getDirection()[i]))
+		if(isZero(r.getDirection()[i]))
 		{
 			// ray passes by box
 			if(r.getOrigin()[i] < aabb.getMin()[i] ||

+ 3 - 3
src/collision/Frustum.cpp

@@ -122,13 +122,13 @@ void PerspectiveFrustum::recalculate()
 	//
 	F32 c, s; // cos & sine
 
-	Math::sinCos(Math::PI + fovX / 2.0, s, c);
+	sinCos(getPi<F32>() + fovX / 2.0, s, c);
 	// right
 	planes[FP_RIGHT] = Plane(Vec3(c, 0.0, s), 0.0);
 	// left
 	planes[FP_LEFT] = Plane(Vec3(-c, 0.0, s), 0.0);
 
-	Math::sinCos((Math::PI + fovY) * 0.5, s, c);
+	sinCos((getPi<F32>() + fovY) * 0.5, s, c);
 	// bottom
 	planes[FP_BOTTOM] = Plane(Vec3(0.0, s, c), 0.0);
 	// top
@@ -143,7 +143,7 @@ void PerspectiveFrustum::recalculate()
 	//
 	eye = Vec3(0.0, 0.0, -near);
 
-	F32 x = far / tan((Math::PI - fovX) / 2.0);
+	F32 x = far / tan((getPi<F32>() - fovX) / 2.0);
 	F32 y = tan(fovY / 2.0) * far;
 	F32 z = -far;
 

+ 1 - 1
src/collision/Obb.cpp

@@ -131,7 +131,7 @@ void Obb::toAabb(Aabb& aabb) const
 	Vec3 newE = absM * extends;
 
 	// Add a small epsilon to avoid some assertions
-	aabb = Aabb(center - newE, center + newE + Vec3(Math::EPSILON * 100.0));
+	aabb = Aabb(center - newE, center + newE + Vec3(getEpsilon<F32>() * 100.0));
 }
 
 } // end namespace

+ 3 - 3
src/collision/Plane.cpp

@@ -30,7 +30,7 @@ void Plane::setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2)
 	normal = u.cross(v);
 
 	// length of normal had better not be zero
-	ANKI_ASSERT(!Math::isZero(normal.getLengthSquared()));
+	ANKI_ASSERT(!isZero(normal.getLengthSquared()));
 
 	normal.normalize();
 	offset = normal.dot(p0); // XXX: correct??
@@ -42,10 +42,10 @@ void Plane::setFromPlaneEquation(F32 a, F32 b, F32 c, F32 d)
 	// normalize for cheap distance checks
 	F32 lensq = a * a + b * b + c * c;
 	// length of normal had better not be zero
-	ANKI_ASSERT(!Math::isZero(lensq));
+	ANKI_ASSERT(!isZero(lensq));
 
 	// recover gracefully
-	if(Math::isZero(lensq))
+	if(isZero(lensq))
 	{
 		normal = Vec3(1.0, 0.0, 0.0);
 		offset = 0.0;

+ 25 - 11
src/math/Math.cpp → src/math/Functions.cpp

@@ -1,35 +1,37 @@
-#include "anki/math/MathCommonSrc.h"
+#include "anki/math/Functions.h"
 
 namespace anki {
 
 //==============================================================================
-F32 Math::polynomialSinQuadrant(const F32 a)
+template<typename Scalar>
+static Scalar polynomialSinQuadrant(const Scalar a)
 {
 	return a * (1.0 + a * a * (-0.16666 + a * a *
 		(0.0083143 - a * a * 0.00018542)));
 }
 
 //==============================================================================
-void Math::sinCos(const F32 a_, F32& sina, F32& cosa)
+template<typename Scalar>
+static void sinCosInternal(const Scalar a_, Scalar& sina, Scalar& cosa)
 {
 #if NDEBUG
 	Bool negative = false;
-	F32 a = a_;
+	Scalar a = a_;
 	if(a < 0.0)
 	{
 		a = -a;
 		negative = true;
 	}
-	const F32 TWO_OVER_PI = 1.0 / (PI / 2.0);
-	F32 floatA = TWO_OVER_PI * a;
+	const Scalar TWO_OVER_PI = 1.0 / (getPi<Scalar>() / 2.0);
+	Scalar floatA = TWO_OVER_PI * a;
 	I intA = (int)floatA;
 
-	const F32 RATIONAL_HALF_PI = 201 / 128.0;
-	const F32 REMAINDER_HALF_PI = 4.8382679e-4;
+	const Scalar RATIONAL_HALF_PI = 201 / 128.0;
+	const Scalar REMAINDER_HALF_PI = 4.8382679e-4;
 
 	floatA = (a - RATIONAL_HALF_PI * intA) - REMAINDER_HALF_PI * intA;
 
-	F32 floatAMinusHalfPi = (floatA - RATIONAL_HALF_PI) - REMAINDER_HALF_PI;
+	Scalar floatAMinusHalfPi = (floatA - RATIONAL_HALF_PI) - REMAINDER_HALF_PI;
 
 	switch(intA & 3)
 	{
@@ -56,9 +58,21 @@ void Math::sinCos(const F32 a_, F32& sina, F32& cosa)
 		sina = -sina;
 	}
 #else
-	sina = ::sin(a_);
-	cosa = ::cos(a_);
+	sina = sin(a_);
+	cosa = cos(a_);
 #endif
 }
 
+//==============================================================================
+void sinCos(const F32 a, F32& sina, F32& cosa)
+{
+	sinCosInternal(a, sina, cosa);
+}
+
+//==============================================================================
+void sinCos(const F64 a, F64& sina, F64& cosa)
+{
+	sinCosInternal(a, sina, cosa);
+}
+
 } // end namespace anki

+ 2 - 2
src/renderer/Dbg.cpp

@@ -159,7 +159,7 @@ void Dbg::run()
 
 	Vec3 a(0.0);
 	F32 s, c;
-	Math::sinCos(Math::PI / 2 - fx / 2, s, c);
+	sinCos(getPi<F32>() / 2 - fx / 2, s, c);
 	Vec3 b(c, 0.0, -s);
 
 	a.transform(camera1->getWorldTransform());
@@ -167,7 +167,7 @@ void Dbg::run()
 
 	drawer->drawLine(a, b, Vec4(1));
 
-	Math::sinCos(fy / 2, s, c);
+	sinCos(fy / 2, s, c);
 	b = Vec3(0.0, s, -c);
 	b.transform(camera1->getWorldTransform());
 

+ 6 - 6
src/renderer/Drawer.cpp

@@ -116,14 +116,14 @@ void DebugDrawer::drawSphere(float radius, int complexity)
 		complexityToPreCalculatedSphere[complexity] = Vector<Vec3>();
 		sphereLines = &complexityToPreCalculatedSphere[complexity];
 
-		float fi = Math::PI / complexity;
+		float fi = getPi<F32>() / complexity;
 
 		Vec3 prev(1.0, 0.0, 0.0);
-		for(float th = fi; th < Math::PI * 2.0 + fi; th += fi)
+		for(float th = fi; th < getPi<F32>() * 2.0 + fi; th += fi)
 		{
 			Vec3 p = Mat3(Euler(0.0, th, 0.0)) * Vec3(1.0, 0.0, 0.0);
 
-			for(float th2 = 0.0; th2 < Math::PI; th2 += fi)
+			for(float th2 = 0.0; th2 < getPi<F32>(); th2 += fi)
 			{
 				Mat3 rot(Euler(th2, 0.0, 0.0));
 
@@ -133,7 +133,7 @@ void DebugDrawer::drawSphere(float radius, int complexity)
 				sphereLines->push_back(rotPrev);
 				sphereLines->push_back(rotP);
 
-				Mat3 rot2(Euler(0.0, 0.0, Math::PI / 2));
+				Mat3 rot2(Euler(0.0, 0.0, getPi<F32>() / 2));
 
 				sphereLines->push_back(rot2 * rotPrev);
 				sphereLines->push_back(rot2 * rotP);
@@ -271,7 +271,7 @@ void CollisionDebugDrawer::visit(const Plane& plane)
 	Quat q;
 	q.setFrom2Vec3(Vec3(0.0, 0.0, 1.0), n);
 	Mat3 rot(q);
-	rot.rotateXAxis(Math::PI / 2.0);
+	rot.rotateXAxis(getPi<F32>() / 2.0);
 	Mat4 trf(n * o, rot);
 
 	dbg->setModelMatrix(trf);
@@ -313,7 +313,7 @@ void CollisionDebugDrawer::visit(const Frustum& f)
 			static_cast<const PerspectiveFrustum&>(f);
 
 		float camLen = pf.getFar();
-		float tmp0 = camLen / tan((Math::PI - pf.getFovX()) * 0.5) + 0.001;
+		float tmp0 = camLen / tan((getPi<F32>() - pf.getFovX()) * 0.5) + 0.001;
 		float tmp1 = camLen * tan(pf.getFovY() * 0.5) + 0.001;
 
 		Vec3 points[] = {

+ 1 - 1
src/resource/MeshLoader.cpp

@@ -230,7 +230,7 @@ void MeshLoader::createVertTangents()
 
 		float det = (uvedge01.y() * uvedge02.x()) -
 			(uvedge01.x() * uvedge02.y());
-		if(Math::isZero(det))
+		if(isZero(det))
 		{
 			//ANKI_LOGW(getRsrcName() << ": det == " << fixed << det);
 			det = 0.0001;

+ 3 - 3
src/resource/ParticleEmitterRsrc.cpp

@@ -66,8 +66,8 @@ ParticleEmitterRsrc& ParticleEmitterRsrc::operator=(
 //==============================================================================
 bool ParticleEmitterRsrc::hasForce() const
 {
-	return (!Math::isZero(forceDirection.getLengthSquared()) ||
-		!Math::isZero(forceDirectionDeviation.getLengthSquared())) &&
+	return (!isZero(forceDirection.getLengthSquared()) ||
+		!isZero(forceDirectionDeviation.getLengthSquared())) &&
 			(forceMagnitude != 0.0 || forceMagnitudeDeviation != 0.0);
 }
 
@@ -77,7 +77,7 @@ bool ParticleEmitterRsrc::hasForce() const
 //==============================================================================
 bool ParticleEmitterRsrc::usingWorldGrav() const
 {
-	return Math::isZero(gravity.getLengthSquared());
+	return isZero(gravity.getLengthSquared());
 }
 
 

+ 1 - 1
src/scene/Light.cpp

@@ -50,7 +50,7 @@ SpotLight::SpotLight(const char* name, Scene* scene,
 	: Light(LT_SPOT, name, scene, movableFlags, movParent, &frustum),
 		Frustumable(&frustum)
 {
-	const F32 ang = Math::toRad(45.0);
+	const F32 ang = toRad(45.0);
 	setOuterAngle(ang / 2.0);
 	const F32 dist = 1.0;
 

+ 3 - 3
src/scene/SkinNode.cpp

@@ -328,13 +328,13 @@ void SkinNode::updateBoneTransforms(const Skeleton& skeleton,
 		// bone.final_transform = MA * ANIM * MAi
 		// where MA is bone matrix at armature space and ANIM the interpolated
 		// transformation.
-		Math::combineTransformations(
+		Transform::combineTransformations(
 			boneTranslations[boneId], boneRotations[boneId],
 			boned.getTranslationSkeletonSpaceInverted(),
 			boned.getRotationSkeletonSpaceInverted(),
 			boneTranslations[boneId], boneRotations[boneId]);
 
-		Math::combineTransformations(
+		Transform::combineTransformations(
 			boned.getTranslationSkeletonSpace(),
 			boned.getRotationSkeletonSpace(),
 			boneTranslations[boneId], boneRotations[boneId],
@@ -344,7 +344,7 @@ void SkinNode::updateBoneTransforms(const Skeleton& skeleton,
 		if(boned.getParent())
 		{
 			// bone.final_final_transform = parent.transf * bone.final_transform
-			Math::combineTransformations(
+			Transform::combineTransformations(
 				boneTranslations[boned.getParent()->getId()],
 				boneRotations[boned.getParent()->getId()],
 				boneTranslations[boneId],

+ 11 - 11
testapp/Main.cpp

@@ -61,10 +61,10 @@ void init()
 		Movable::MF_NONE, nullptr);
 	const float ang = 45.0;
 	cam->setAll(
-		MainRendererSingleton::get().getAspectRatio() * Math::toRad(ang),
-		Math::toRad(ang), 0.5, 200.0);
+		MainRendererSingleton::get().getAspectRatio() * toRad(ang),
+		toRad(ang), 0.5, 200.0);
 	cam->setLocalTransform(Transform(Vec3(100.0, 3.0, 8.0),
-		Mat3(Axisang(Math::toRad(90), Vec3(0, 1, 0))),
+		Mat3(Axisang(toRad(90.0), Vec3(0, 1, 0))),
 		1.0));
 	scene.setActiveCamera(cam);
 
@@ -72,10 +72,10 @@ void init()
 	PerspectiveCamera* pcam = new PerspectiveCamera("camera1", &scene,
 		Movable::MF_NONE, nullptr);
 	pcam->setAll(
-		MainRendererSingleton::get().getAspectRatio() * Math::toRad(ang),
-		Math::toRad(ang), 0.5, 200.0);
+		MainRendererSingleton::get().getAspectRatio() * toRad(ang),
+		toRad(ang), 0.5, 200.0);
 	pcam->setLocalTransform(Transform(Vec3(100.0, 3.0, 8.0),
-		Mat3(Axisang(Math::toRad(90), Vec3(0, 1, 0))),
+		Mat3(Axisang(toRad(90.0), Vec3(0, 1, 0))),
 		1.0));
 
 	// lights
@@ -102,8 +102,8 @@ void init()
 
 #if 1
 	SpotLight* spot = new SpotLight("spot0", &scene, Movable::MF_NONE, nullptr);
-	spot->setOuterAngle(Math::toRad(45.0));
-	spot->setInnerAngle(Math::toRad(15.0));
+	spot->setOuterAngle(toRad(45.0));
+	spot->setInnerAngle(toRad(15.0));
 	spot->setLocalTransform(Transform(Vec3(1.3, 4.3, 3.0),
 		Mat3::getIdentity(), 1.0));
 	spot->setDiffuseColor(Vec4(1.0));
@@ -114,8 +114,8 @@ void init()
 
 
 	spot = new SpotLight("spot1", &scene, Movable::MF_NONE, nullptr);
-	spot->setOuterAngle(Math::toRad(45.0));
-	spot->setInnerAngle(Math::toRad(15.0));
+	spot->setOuterAngle(toRad(45.0));
+	spot->setInnerAngle(toRad(15.0));
 	spot->setLocalTransform(Transform(Vec3(5.3, 4.3, 3.0),
 		Mat3::getIdentity(), 1.0));
 	spot->setDiffuseColor(Vec4(1.0, 0.0, 0.0, 0.0));
@@ -186,7 +186,7 @@ void mainLoopExtra()
 	InputSingleton::get().handleEvents();
 
 	float dist = 0.2;
-	float ang = Math::toRad(3.0);
+	float ang = toRad(3.0);
 	float scale = 0.01;
 
 	// move the camera