Преглед изворни кода

- SSE math
- Math unit tests

Panagiotis Christopoulos Charitos пре 15 година
родитељ
комит
0bf688290d

+ 1 - 1
src/Collision/Plane.cpp

@@ -39,7 +39,7 @@ void Plane::setFromPlaneEquation(float a, float b, float c, float d)
 	}
 	else
 	{
-		float recip = invSqrt(lensq);
+		float recip = 1.0 / sqrt(lensq);
 		normal = Vec3(a * recip, b * recip, c * recip);
 		offset = d * recip;
 	}

+ 4 - 4
src/Input/Input.cpp

@@ -81,11 +81,11 @@ void Input::handleEvents()
 			{
 				Vec2 prevMousePosNdc(mousePosNdc);
 
-				mousePos.x = event_.button.x;
-				mousePos.y = event_.button.y;
+				mousePos.x() = event_.button.x;
+				mousePos.y() = event_.button.y;
 
-				mousePosNdc.x = (2.0 * mousePos.x) / (float)AppSingleton::getInstance().getWindowWidth() - 1.0;
-				mousePosNdc.y = 1.0 - (2.0 * mousePos.y) / (float)AppSingleton::getInstance().getWindowHeight();
+				mousePosNdc.x() = (2.0 * mousePos.x()) / (float)AppSingleton::getInstance().getWindowWidth() - 1.0;
+				mousePosNdc.y() = 1.0 - (2.0 * mousePos.y()) / (float)AppSingleton::getInstance().getWindowHeight();
 
 				if(warpMouse)
 				{

+ 2 - 3
src/Main.cpp

@@ -112,7 +112,6 @@ void init()
 	INFO("Other init...");
 
 	srand(unsigned(time(NULL)));
-	mathSanityChecks();
 
 	uint ticks = AppSingleton::getInstance().getTicks();
 
@@ -279,8 +278,8 @@ void mainLoop()
 		else
 		{
 			float accel = 44.0;
-			mover->rotateLocalX(ang * InputSingleton::getInstance().mouseVelocity.y * accel);
-			mover->rotateLocalY(-ang * InputSingleton::getInstance().mouseVelocity.x * accel);
+			mover->rotateLocalX(ang * InputSingleton::getInstance().mouseVelocity.y() * accel);
+			mover->rotateLocalY(-ang * InputSingleton::getInstance().mouseVelocity.x() * accel);
 		}
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_Q)) mover->rotateLocalZ(ang);
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_E)) mover->rotateLocalZ(-ang);

+ 12 - 12
src/Math/Mat3.inl.h

@@ -517,10 +517,10 @@ inline void Mat3::rotateXAxis(float rad)
 	ME(2, 2) = ME(2, 2)*cosa - ME(2, 1)*sina;
 
 	// zAxis.normalize();
-	float len = invSqrt(ME(0, 2)*ME(0, 2) + ME(1, 2)*ME(1, 2) + ME(2, 2)*ME(2, 2));
-	ME(0, 2) *= len;
-	ME(1, 2) *= len;
-	ME(2, 2) *= len;
+	float len = sqrt(ME(0, 2)*ME(0, 2) + ME(1, 2)*ME(1, 2) + ME(2, 2)*ME(2, 2));
+	ME(0, 2) /= len;
+	ME(1, 2) /= len;
+	ME(2, 2) /= len;
 
 	// yAxis = zAxis * xAxis;
 	ME(0, 1) = ME(1, 2)*ME(2, 0) - ME(2, 2)*ME(1, 0);
@@ -552,10 +552,10 @@ inline void Mat3::rotateYAxis(float rad)
 	ME(2, 2) = ME(2, 2)*cosa + ME(2, 0)*sina;
 
 	// zAxis.normalize();
-	float len = invSqrt(ME(0, 2)*ME(0, 2) + ME(1, 2)*ME(1, 2) + ME(2, 2)*ME(2, 2));
-	ME(0, 2) *= len;
-	ME(1, 2) *= len;
-	ME(2, 2) *= len;
+	float len = sqrt(ME(0, 2)*ME(0, 2) + ME(1, 2)*ME(1, 2) + ME(2, 2)*ME(2, 2));
+	ME(0, 2) /= len;
+	ME(1, 2) /= len;
+	ME(2, 2) /= len;
 
 	// xAxis = (zAxis*yAxis) * -1.0f;
 	ME(0, 0) = ME(2, 2)*ME(1, 1) - ME(1, 2)*ME(2, 1);
@@ -587,10 +587,10 @@ inline void Mat3::rotateZAxis(float rad)
 	ME(2, 0) = ME(2, 0)*cosa + ME(2, 1)*sina;
 
 	// xAxis.normalize();
-	float len = invSqrt(ME(0, 0)*ME(0, 0) + ME(1, 0)*ME(1, 0) + ME(2, 0)*ME(2, 0));
-	ME(0, 0) *= len;
-	ME(1, 0) *= len;
-	ME(2, 0) *= len;
+	float len = sqrt(ME(0, 0)*ME(0, 0) + ME(1, 0)*ME(1, 0) + ME(2, 0)*ME(2, 0));
+	ME(0, 0) /= len;
+	ME(1, 0) /= len;
+	ME(2, 0) /= len;
 
 	// yAxis = zAxis*xAxis;
 	ME(0, 1) = ME(1, 2)*ME(2, 0) - ME(2, 2)*ME(1, 0);

+ 4 - 0
src/Math/MathCommon.h

@@ -5,7 +5,11 @@
 #define MATH_COMMON_H
 
 #include <iostream>
+#include <boost/array.hpp>
 #include "StdTypes.h"
+#if defined(MATH_INTEL_SIMD)
+	#include <smmintrin.h>
+#endif
 
 
 // Forward delcs

+ 0 - 3
src/Math/MathFuncs.h

@@ -10,10 +10,7 @@ namespace M {
 const float PI = 3.14159265358979323846;
 const float EPSILON = 1.0e-6;
 
-
-extern void  mathSanityChecks(); ///< Used to test the compiler
 extern void  sinCos(float rad, float& sin_, float& cos_); ///< A fast func that given the angle in rads it returns the sin and cos
-extern float invSqrt(float f); ///< Inverted square root
 extern float sqrt(float f); ///< Square root
 extern float toRad(float degrees);
 extern float toDegrees(float rad);

+ 15 - 43
src/Math/MathFuncs.inl.h

@@ -4,47 +4,6 @@
 namespace M {
 
 
-// mathSanityChecks
-inline void mathSanityChecks()
-{
-	const int fs = sizeof(float); // float size
-	if(sizeof(Vec2)!=fs*2 || sizeof(Vec3)!=fs*3 || sizeof(Vec4)!=fs*4 || sizeof(Quat)!=fs*4 ||
-	   sizeof(Euler)!=fs*3 || sizeof(Mat3)!=fs*9 || sizeof(Mat4)!=fs*16)
-	{
-		throw EXCEPTION("Your compiler does class alignment");
-	}
-}
-
-
-// 1/sqrt(f)
-inline float invSqrt(float f)
-{
-	float fhalf = 0.5 * f;
-	#if defined(PLATFORM_WIN)
-		int i = *(int*)&f;
-		i = 0x5F3759DF - (i>>1);
-		f = *(float*)&i;
-		f *= 1.5 - fhalf*f*f;
-	#elif defined(PLATFORM_LINUX)
-		asm
-		(
-			"mov %1, %%eax;"
-			"sar %%eax;"
-			"mov $0x5F3759DF, %%ebx;"
-			"sub %%eax, %%ebx;"
-			"mov %%ebx, %0"
-			:"=g"(f)
-			:"g"(f)
-			:"%eax", "%ebx"
-		);
-		f *= 1.5 - fhalf*f*f;
-	#else
-		#error "See file"
-	#endif
-	return f;
-}
-
-
 // polynomialSinQuadrant
 /// Used in sinCos
 inline static float polynomialSinQuadrant(float a)
@@ -106,30 +65,43 @@ inline void sinCos(float a, float& sina, float& cosa)
 //======================================================================================================================
 inline float sqrt(float f)
 {
-	return 1/invSqrt(f);
+	#if defined(MATH_INTEL_SIMD)
+		__m128 mm = _mm_set_ss(f);
+		mm = _mm_sqrt_ss(mm);
+		float o;
+		_mm_store_ss(&o, mm);
+		return o;
+	#else
+		return ::sqrtf(f);
+	#endif
 }
 
+
 inline float toRad(float degrees)
 {
 	return degrees*(PI/180.0);
 }
 
+
 inline float toDegrees(float rad)
 {
 	return rad*(180.0/PI);
 }
 
+
 inline float sin(float rad)
 {
 	return ::sin(rad);
 }
 
+
 inline float cos(float rad)
 {
 	return ::cos(rad);
 }
 
-inline bool  isZero(float f)
+
+inline bool isZero(float f)
 {
 	return fabs(f) < EPSILON;
 }

+ 6 - 6
src/Math/Quat.inl.h

@@ -23,7 +23,7 @@ inline Quat::Quat(float x_, float y_, float z_, float w_):
 
 // constructor [vec2, float, float]
 inline Quat::Quat(const Vec2& v2, float z_, float w_):
-	x(v2.x), y(v2.y), z(z_), w(w_)
+	x(v2.x()), y(v2.y()), z(z_), w(w_)
 {}
 
 // constructor [vec3, float]
@@ -47,7 +47,7 @@ inline Quat::Quat(const Mat3& m3)
 	float trace = m3(0, 0) + m3(1, 1) + m3(2, 2) + 1.0;
 	if(trace > EPSILON)
 	{
-		float s = 0.5 * invSqrt(trace);
+		float s = 0.5 / sqrt(trace);
 		w = 0.25 / s;
 		x = (m3(2, 1) - m3(1, 2)) * s;
 		y = (m3(0, 2) - m3(2, 0)) * s;
@@ -57,7 +57,7 @@ inline Quat::Quat(const Mat3& m3)
 	{
 		if(m3(0, 0) > m3(1, 1) && m3(0, 0) > m3(2, 2))
 		{
-			float s = 0.5 * invSqrt(1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2));
+			float s = 0.5 / sqrt(1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2));
 			w = (m3(1, 2) - m3(2, 1)) * s;
 			x = 0.25 / s;
 			y = (m3(0, 1) + m3(1, 0)) * s;
@@ -65,7 +65,7 @@ inline Quat::Quat(const Mat3& m3)
 		}
 		else if(m3(1, 1) > m3(2, 2))
 		{
-			float s = 0.5 * invSqrt(1.0 + m3(1, 1) - m3(0, 0) - m3(2, 2));
+			float s = 0.5 / sqrt(1.0 + m3(1, 1) - m3(0, 0) - m3(2, 2));
 			w = (m3(0, 2) - m3(2, 0)) * s;
 			x = (m3(0, 1) + m3(1, 0)) * s;
 			y = 0.25 / s;
@@ -73,7 +73,7 @@ inline Quat::Quat(const Mat3& m3)
 		}
 		else
 		{
-			float s = 0.5 * invSqrt(1.0 + m3(2, 2) - m3(0, 0) - m3(1, 1));
+			float s = 0.5 / sqrt(1.0 + m3(2, 2) - m3(0, 0) - m3(1, 1));
 			w = (m3(0, 1) - m3(1, 0)) * s;
 			x = (m3(0, 2) + m3(2, 0)) * s;
 			y = (m3(1, 2) + m3(2, 1)) * s;
@@ -117,7 +117,7 @@ inline Quat::Quat(const Axisang& axisang)
 	float sintheta, costheta;
 	sinCos(rad, sintheta, costheta);
 
-	float scalefactor = sintheta * invSqrt(lengthsq);
+	float scalefactor = sintheta / sqrt(lengthsq);
 
 	x = scalefactor * axisang.axis.x;
 	y = scalefactor * axisang.axis.y;

+ 52 - 32
src/Math/Vec2.h

@@ -11,53 +11,55 @@ namespace M {
 class Vec2
 {
 	public:
-		/// @name Data members
-		/// @{
-		float x;
-		float y;
-		/// @}
-
 		/// @name Accessors
 		/// @{
-		float& operator [](uint i);
-		float  operator [](uint i) const;
+		float& x();
+		float x() const;
+		float& y();
+		float y() const;
+		float& operator[](uint i);
+		float operator[](uint i) const;
 		/// @}
 
 		/// @name Constructors & distructors
 		/// @{
 		explicit Vec2();
-		explicit Vec2(float f);
 		explicit Vec2(float x, float y);
+		explicit Vec2(float f);
+		explicit Vec2(float arr[]);
 		         Vec2(const Vec2& b);
 		explicit Vec2(const Vec3& v3);
 		explicit Vec2(const Vec4& v4);
+		#if defined(MATH_INTEL_SIMD)
+			explicit Vec2(const __m64& mm);
+		#endif
 		/// @}
 
 		/// @name Operators with same type
 		/// @{
-		Vec2 operator +(const Vec2& b) const;
-		Vec2& operator +=(const Vec2& b);
-		Vec2 operator -(const Vec2& b) const;
-		Vec2& operator -=(const Vec2& b);
-		Vec2 operator *(const Vec2& b) const;
-		Vec2& operator *=(const Vec2& b);
-		Vec2 operator /(const Vec2& b) const;
-		Vec2& operator /=(const Vec2& b);
-		Vec2 operator -() const;
-		bool operator ==(const Vec2& b) const;
-		bool operator !=(const Vec2& b) const;
+		Vec2 operator+(const Vec2& b) const;
+		Vec2& operator+=(const Vec2& b);
+		Vec2 operator-(const Vec2& b) const;
+		Vec2& operator-=(const Vec2& b);
+		Vec2 operator*(const Vec2& b) const;
+		Vec2& operator*=(const Vec2& b);
+		Vec2 operator/(const Vec2& b) const;
+		Vec2& operator/=(const Vec2& b);
+		Vec2 operator-() const;
+		bool operator==(const Vec2& b) const;
+		bool operator!=(const Vec2& b) const;
 		/// @}
 
 		/// @name Operators with float
 		/// @{
-		Vec2 operator +(float f) const;
-		Vec2& operator +=(float f);
-		Vec2 operator -(float f) const;
-		Vec2& operator -=(float f);
-		Vec2 operator *(float f) const;
-		Vec2& operator *=(float f);
-		Vec2 operator /(float f) const;
-		Vec2& operator /=(float f);
+		Vec2 operator+(float f) const;
+		Vec2& operator+=(float f);
+		Vec2 operator-(float f) const;
+		Vec2& operator-=(float f);
+		Vec2 operator*(float f) const;
+		Vec2& operator*=(float f);
+		Vec2 operator/(float f) const;
+		Vec2& operator/=(float f);
 		/// @}
 
 		/// @name Other
@@ -67,15 +69,33 @@ class Vec2
 		void normalize();
 		float dot(const Vec2& b) const;
 		/// @}
+
+	private:
+		/// @name Data members
+		/// @{
+		union
+		{
+			struct
+			{
+				float x, y;
+			} vec;
+
+			boost::array<float, 2> arr;
+
+			#if defined(MATH_INTEL_SIMD)
+				__m64 mm;
+			#endif
+		};
+		/// @}
 };
 
 
 /// @name Other operators
 /// @{
-extern Vec2 operator +(float f, const Vec2& v2);
-extern Vec2 operator -(float f, const Vec2& v2);
-extern Vec2 operator *(float f, const Vec2& v2);
-extern Vec2 operator /(float f, const Vec2& v2);
+extern Vec2 operator+(float f, const Vec2& v2);
+extern Vec2 operator-(float f, const Vec2& v2);
+extern Vec2 operator*(float f, const Vec2& v2);
+extern Vec2 operator/(float f, const Vec2& v2);
 extern std::ostream& operator<<(std::ostream& s, const Vec2& v);
 /// @}
 

+ 105 - 63
src/Math/Vec2.inl.h

@@ -8,187 +8,229 @@ namespace M {
 
 
 // accessors
-inline float& Vec2::operator [](uint i)
+
+inline float& Vec2::x()
+{
+	return vec.x;
+}
+
+inline float Vec2::x() const
+{
+	return vec.x;
+}
+
+inline float& Vec2::y()
 {
-	return (&x)[i];
+	return vec.y;
 }
 
-inline float Vec2::operator [](uint i) const
+inline float Vec2::y() const
 {
-	return (&x)[i];
+	return vec.y;
+}
+
+inline float& Vec2::operator[](uint i)
+{
+	return arr[i];
+}
+
+inline float Vec2::operator[](uint i) const
+{
+	return arr[i];
 }
 
 // constructor []
 inline Vec2::Vec2()
-	: x(0.0), y(0.0)
-{}
+{
+	x() = y() = 0.0;
+}
 
 // constructor [float, float]
 inline Vec2::Vec2(float x_, float y_)
-	: x(x_), y(y_)
-{}
+{
+	x() = x_;
+	y() = y_;
+}
 
 // constructor [float]
-inline Vec2::Vec2(float f): x(f), y(f)
-{}
+inline Vec2::Vec2(float f)
+{
+	x() = y() = f;
+}
+
+// constructor [float[]]
+inline Vec2::Vec2(float arr[])
+{
+	x() = arr[0];
+	y() = arr[1];
+}
 
 // constructor [vec2]
-inline Vec2::Vec2(const Vec2& b): x(b.x), y(b.y)
-{}
+inline Vec2::Vec2(const Vec2& b)
+{
+	x() = b.x();
+	y() = b.y();
+}
 
 // constructor [vec3]
-inline Vec2::Vec2(const Vec3& v3): x(v3.x), y(v3.y)
-{}
+inline Vec2::Vec2(const Vec3& v3)
+{
+	x() = v3.x;
+	y() = v3.y;
+}
 
 // constructor [vec4]
-inline Vec2::Vec2(const Vec4& v4): x(v4.x()), y(v4.y())
-{}
+inline Vec2::Vec2(const Vec4& v4)
+{
+	x() = v4.x();
+	y() = v4.y();
+}
 
 // +
-inline Vec2 Vec2::operator +(const Vec2& b) const
+inline Vec2 Vec2::operator+(const Vec2& b) const
 {
-	return Vec2(x+b.x, y+b.y);
+	return Vec2(x() + b.x(), y() + b.y());
 }
 
 // +=
-inline Vec2& Vec2::operator +=(const Vec2& b)
+inline Vec2& Vec2::operator+=(const Vec2& b)
 {
-	x += b.x;
-	y += b.y;
+	x() += b.x();
+	y() += b.y();
 	return ME;
 }
 
 // -
-inline Vec2 Vec2::operator -(const Vec2& b) const
+inline Vec2 Vec2::operator-(const Vec2& b) const
 {
-	return Vec2(x-b.x, y-b.y);
+	return Vec2(x() - b.x(), y() - b.y());
 }
 
 // -=
-inline Vec2& Vec2::operator -=(const Vec2& b)
+inline Vec2& Vec2::operator-=(const Vec2& b)
 {
-	x -= b.x;
-	y -= b.y;
+	x() -= b.x();
+	y() -= b.y();
 	return ME;
 }
 
 // *
-inline Vec2 Vec2::operator *(const Vec2& b) const
+inline Vec2 Vec2::operator*(const Vec2& b) const
 {
-	return Vec2(x*b.x, y*b.y);
+	return Vec2(x() * b.x(), y() * b.y());
 }
 
 // *=
-inline Vec2& Vec2::operator *=(const Vec2& b)
+inline Vec2& Vec2::operator*=(const Vec2& b)
 {
-	x *= b.x;
-	y *= b.y;
+	x() *= b.x();
+	y() *= b.y();
 	return ME;
 }
 
 // /
-inline Vec2 Vec2::operator /(const Vec2& b) const
+inline Vec2 Vec2::operator/(const Vec2& b) const
 {
-	return Vec2(x/b.x, y/b.y);
+	return Vec2(x() / b.x(), y() / b.y());
 }
 
 // /=
-inline Vec2& Vec2::operator /=(const Vec2& b)
+inline Vec2& Vec2::operator/=(const Vec2& b)
 {
-	x /= b.x;
-	y /= b.y;
+	x() /= b.x();
+	y() /= b.y();
 	return ME;
 }
 
 // negative
-inline Vec2 Vec2::operator -() const
+inline Vec2 Vec2::operator-() const
 {
-	return Vec2(-x, -y);
+	return Vec2(-x(), -y());
 }
 
 // ==
-inline bool Vec2::operator ==(const Vec2& b) const
+inline bool Vec2::operator==(const Vec2& b) const
 {
-	return (isZero(x-b.x) && isZero(y-b.y)) ? true : false;
+	return isZero(x() - b.x()) && isZero(y() - b.y());
 }
 
 // !=
-inline bool Vec2::operator !=(const Vec2& b) const
+inline bool Vec2::operator!=(const Vec2& b) const
 {
-	return (isZero(x-b.x) && isZero(y-b.y)) ? false : true;
+	return !(isZero(x() - b.x()) && isZero(y() - b.y()));
 }
 
 // vec2 + float
-inline Vec2 Vec2::operator +(float f) const
+inline Vec2 Vec2::operator+(float f) const
 {
 	return ME + Vec2(f);
 }
 
 // float + vec2
-inline Vec2 operator +(float f, const Vec2& v2)
+inline Vec2 operator+(float f, const Vec2& v2)
 {
-	return v2+f;
+	return v2 + f;
 }
 
 // vec2 += float
-inline Vec2& Vec2::operator +=(float f)
+inline Vec2& Vec2::operator+=(float f)
 {
 	ME += Vec2(f);
 	return ME;
 }
 
 // vec2 - float
-inline Vec2 Vec2::operator -(float f) const
+inline Vec2 Vec2::operator-(float f) const
 {
 	return ME - Vec2(f);
 }
 
 // float - vec2
-inline Vec2 operator -(float f, const Vec2& v2)
+inline Vec2 operator-(float f, const Vec2& v2)
 {
-	return Vec2(f-v2.x, f-v2.y);
+	return Vec2(f - v2.x(), f - v2.y());
 }
 
 // vec2 -= float
-inline Vec2& Vec2::operator -=(float f)
+inline Vec2& Vec2::operator-=(float f)
 {
 	ME -= Vec2(f);
 	return ME;
 }
 
 // vec2 * float
-inline Vec2 Vec2::operator *(float f) const
+inline Vec2 Vec2::operator*(float f) const
 {
 	return ME * Vec2(f);
 }
 
 // float * vec2
-inline Vec2 operator *(float f, const Vec2& v2)
+inline Vec2 operator*(float f, const Vec2& v2)
 {
-	return v2*f;
+	return v2 * f;
 }
 
 // vec2 *= float
-inline Vec2& Vec2::operator *=(float f)
+inline Vec2& Vec2::operator*=(float f)
 {
 	ME *= Vec2(f);
 	return ME;
 }
 
 // vec2 / float
-inline Vec2 Vec2::operator /(float f) const
+inline Vec2 Vec2::operator/(float f) const
 {
 	return ME / Vec2(f);
 }
 
 // float / vec2
-inline Vec2 operator /(float f, const Vec2& v2)
+inline Vec2 operator/(float f, const Vec2& v2)
 {
-	return Vec2(f/v2.x, f/v2.y);
+	return Vec2(f / v2.x(), f / v2.y());
 }
 
 // vec2 /= float
-inline Vec2& Vec2::operator /=(float f)
+inline Vec2& Vec2::operator/=(float f)
 {
 	ME /= Vec2(f);
 	return ME;
@@ -197,31 +239,31 @@ inline Vec2& Vec2::operator /=(float f)
 // getLength
 inline float Vec2::getLength() const
 {
-	return M::sqrt(x*x + y*y);
+	return M::sqrt(x() * x() + y() * y());
 }
 
 // normalize
 inline void Vec2::normalize()
 {
-	ME *= invSqrt(x*x + y*y);
+	ME /= getLength();
 }
 
 // Normalized (return the normalized)
 inline Vec2 Vec2::getNormalized() const
 {
-	return ME * invSqrt(x*x + y*y);
+	return ME / getLength();
 }
 
 // dot
 inline float Vec2::dot(const Vec2& b) const
 {
-	return x*b.x + y*b.y;
+	return x() * b.x() + y() * b.y();
 }
 
 // print
 inline std::ostream& operator<<(std::ostream& s, const Vec2& v)
 {
-	s << v.x << ' ' << v.y;
+	s << v.x() << ' ' << v.y();
 	return s;
 }
 

+ 27 - 26
src/Math/Vec3.h

@@ -18,14 +18,15 @@ class Vec3
 
 		/// @name Accessors
 		/// @{
-		float& operator [](uint i);
-		float  operator [](uint i) const;
+		float& operator[](uint i);
+		float operator[](uint i) const;
 		/// @}
 
 		/// @name Constructors & distructors
 		/// @{
 		explicit Vec3();
 		explicit Vec3(float f);
+		explicit Vec3(float arr[]);
 		explicit Vec3(float x, float y, float z);
 		explicit Vec3(const Vec2& v2, float z);
 		         Vec3(const Vec3& b);
@@ -35,34 +36,34 @@ class Vec3
 
 		/// @name Operators with same type
 		/// @{
-		Vec3 operator +(const Vec3& b) const;
-		Vec3& operator +=(const Vec3& b);
-		Vec3 operator -(const Vec3& b) const;
-		Vec3& operator -=(const Vec3& b);
-		Vec3 operator *(const Vec3& b) const;
-		Vec3& operator *=(const Vec3& b);
-		Vec3 operator /(const Vec3& b) const;
-		Vec3& operator /=(const Vec3& b);
-		Vec3 operator -() const;
-		bool operator ==(const Vec3& b) const;
-		bool operator !=(const Vec3& b) const;
+		Vec3 operator+(const Vec3& b) const;
+		Vec3& operator+=(const Vec3& b);
+		Vec3 operator-(const Vec3& b) const;
+		Vec3& operator-=(const Vec3& b);
+		Vec3 operator*(const Vec3& b) const;
+		Vec3& operator*=(const Vec3& b);
+		Vec3 operator/(const Vec3& b) const;
+		Vec3& operator/=(const Vec3& b);
+		Vec3 operator-() const;
+		bool operator==(const Vec3& b) const;
+		bool operator!=(const Vec3& b) const;
 		/// @}
 
 		/// @name Operators with float
 		/// @{
-		Vec3 operator +(float f) const;
-		Vec3& operator +=(float f);
-		Vec3 operator -(float f) const;
-		Vec3& operator -=(float f);
-		Vec3 operator *(float f) const;
-		Vec3& operator *=(float f);
-		Vec3 operator /(float f) const;
-		Vec3& operator /=(float f);
+		Vec3 operator+(float f) const;
+		Vec3& operator+=(float f);
+		Vec3 operator-(float f) const;
+		Vec3& operator-=(float f);
+		Vec3 operator*(float f) const;
+		Vec3& operator*=(float f);
+		Vec3 operator/(float f) const;
+		Vec3& operator/=(float f);
 		/// @}
 
 		/// @name Operators with other types
 		/// @{
-		Vec3 operator * (const Mat3& m3) const;
+		Vec3 operator* (const Mat3& m3) const;
 		/// @}
 
 		/// @name Other
@@ -102,10 +103,10 @@ class Vec3
 
 /// @name Other operators
 /// @{
-extern Vec3 operator +(float f, const Vec3& v);
-extern Vec3 operator -(float f, const Vec3& v);
-extern Vec3 operator *(float f, const Vec3& v);
-extern Vec3 operator /(float f, const Vec3& v);
+extern Vec3 operator+(float f, const Vec3& v);
+extern Vec3 operator-(float f, const Vec3& v);
+extern Vec3 operator*(float f, const Vec3& v);
+extern Vec3 operator/(float f, const Vec3& v);
 extern std::ostream& operator<<(std::ostream& s, const Vec3& v);
 /// @}
 

+ 11 - 3
src/Math/Vec3.inl.h

@@ -33,6 +33,14 @@ inline Vec3::Vec3(float f)
 	: x(f), y(f), z(f)
 {}
 
+// constructor [float[]]
+inline Vec3::Vec3(float arr[])
+{
+	x = arr[0];
+	y = arr[1];
+	z = arr[2];
+}
+
 // constructor [Vec3]
 inline Vec3::Vec3(const Vec3& b)
 	: x(b.x), y(b.y), z(b.z)
@@ -40,7 +48,7 @@ inline Vec3::Vec3(const Vec3& b)
 
 // constructor [vec2, float]
 inline Vec3::Vec3(const Vec2& v2, float z_)
-	: x(v2.x), y(v2.y), z(z_)
+	: x(v2.x()), y(v2.y()), z(z_)
 {}
 
 // constructor [vec4]
@@ -240,13 +248,13 @@ inline float Vec3::getDistanceSquared(const Vec3& b) const
 // normalize
 inline void Vec3::normalize()
 {
-	ME *= invSqrt(x*x + y*y + z*z);
+	ME /= getLength();
 }
 
 // Normalized (return the normalized)
 inline Vec3 Vec3::getNormalized() const
 {
-	return ME * invSqrt(x*x + y*y + z*z);
+	return ME / getLength();
 }
 
 // getProjection

+ 10 - 10
src/Math/Vec4.h

@@ -1,11 +1,7 @@
 #ifndef VEC4_H
 #define VEC4_H
 
-#include <boost/array.hpp>
 #include "MathCommon.h"
-#if defined(MATH_INTEL_SIMD)
-	#include <tmmintrin.h>
-#endif
 
 
 namespace M {
@@ -17,8 +13,6 @@ class Vec4
 	public:
 		/// @name Accessors
 		/// @{
-		float& operator[](uint i);
-		float operator[](uint i) const;
 		float& x();
 		float x() const;
 		float& y();
@@ -27,21 +21,27 @@ class Vec4
 		float z() const;
 		float& w();
 		float w() const;
+		float& operator[](uint i);
+		float operator[](uint i) const;
+		#if defined(MATH_INTEL_SIMD)
+			__m128& getMm();
+			const __m128& getMm() const;
+		#endif
 		/// @}
 
 		/// @name Constructors & distructors
 		/// @{
 		explicit Vec4();
+		explicit Vec4(float x, float y, float z, float w);
 		explicit Vec4(float f);
 		explicit Vec4(float arr[]);
-		explicit Vec4(float x, float y, float z, float w);
 		explicit Vec4(const Vec2& v2, float z, float w);
-		#if defined(MATH_INTEL_SIMD)
-			explicit Vec4(const __m128& mm);
-		#endif
 		explicit Vec4(const Vec3& v3, float w);
 		         Vec4(const Vec4& b);
 		explicit Vec4(const Quat& q);
+		#if defined(MATH_INTEL_SIMD)
+			explicit Vec4(const __m128& mm);
+		#endif
 		/// @}
 
 		/// @name Operators with same

+ 56 - 20
src/Math/Vec4.inl.h

@@ -58,6 +58,18 @@ inline float Vec4::w() const
 	return vec.w;
 }
 
+#if defined(MATH_INTEL_SIMD)
+	inline __m128& Vec4::getMm()
+	{
+		return mm;
+	}
+
+	inline const __m128& Vec4::getMm() const
+	{
+		return mm;
+	}
+#endif
+
 // default constructor
 inline Vec4::Vec4()
 {
@@ -115,8 +127,8 @@ inline Vec4::Vec4(float x_, float y_, float z_, float w_)
 // constructor [vec2, float, float]
 inline Vec4::Vec4(const Vec2& v2, float z_, float w_)
 {
-	x() = v2.x;
-	y() = v2.y;
+	x() = v2.x();
+	y() = v2.y();
 	z() = z_;
 	w() = w_;
 }
@@ -203,32 +215,48 @@ inline Vec4& Vec4::operator-=(const Vec4& b)
 // *
 inline Vec4 Vec4::operator*(const Vec4& b) const
 {
-	return Vec4(x() * b.x(), y() * b.y(), z() * b.z(), w() * b.w());
+	#if defined(MATH_INTEL_SIMD)
+		return Vec4(_mm_mul_ps(mm, b.mm));
+	#else
+		return Vec4(x() * b.x(), y() * b.y(), z() * b.z(), w() * b.w());
+	#endif
 }
 
 // *=
 inline Vec4& Vec4::operator*=(const Vec4& b)
 {
-	x() *= b.x();
-	y() *= b.y();
-	z() *= b.z();
-	w() *= b.w();
+	#if defined(MATH_INTEL_SIMD)
+		mm = _mm_mul_ps(mm, b.mm);
+	#else
+		x() *= b.x();
+		y() *= b.y();
+		z() *= b.z();
+		w() *= b.w();
+	#endif
 	return SELF;
 }
 
 // /
 inline Vec4 Vec4::operator/(const Vec4& b) const
 {
-	return Vec4(x() / b.x(), y() / b.y(), z() / b.z(), w() / b.w());
+	#if defined(MATH_INTEL_SIMD)
+		return Vec4(_mm_div_ps(mm, b.mm));
+	#else
+		return Vec4(x() / b.x(), y() / b.y(), z() / b.z(), w() / b.w());
+	#endif
 }
 
 // /=
 inline Vec4& Vec4::operator/=(const Vec4& b)
 {
-	x() /= b.x();
-	y() /= b.y();
-	z() /= b.z();
-	w() /= b.w();
+	#if defined(MATH_INTEL_SIMD)
+		mm = _mm_div_ps(mm, b.mm);
+	#else
+		x() /= b.x();
+		y() /= b.y();
+		z() /= b.z();
+		w() /= b.w();
+	#endif
 	return SELF;
 }
 
@@ -241,13 +269,15 @@ inline Vec4 Vec4::operator-() const
 // ==
 inline bool Vec4::operator==(const Vec4& b) const
 {
-	return isZero(x() - b.x()) && isZero(y() - b.y()) && isZero(z() - b.z()) && isZero(w() - b.w());
+	Vec4 sub = SELF - b;
+	return isZero(sub.x()) && isZero(sub.y()) && isZero(sub.z()) && isZero(sub.w());
 }
 
 // !=
 inline bool Vec4::operator!=(const Vec4& b) const
 {
-	return isZero(x() - b.x()) && isZero(y() - b.y()) && isZero(z() - b.z()) && isZero(w() - b.w());
+	Vec4 sub = SELF - b;
+	return !(isZero(sub.x()) && isZero(sub.y()) && isZero(sub.z()) && isZero(sub.w()));
 }
 
 // vec4 + float
@@ -278,7 +308,7 @@ inline Vec4 Vec4::operator-(float f) const
 // float - vec4
 inline Vec4 operator-(float f, const Vec4& v4)
 {
-	return Vec4(f - v4.x(), f - v4.y(), f - v4.z(), f -v4.w());
+	return Vec4(f) - v4;
 }
 
 // vec4 -= float
@@ -316,7 +346,7 @@ inline Vec4 Vec4::operator/(float f) const
 // float / vec4
 inline Vec4 operator/(float f, const Vec4& v4)
 {
-	return Vec4(f / v4.x(), f / v4.y(), f / v4.z(), f / v4.w());
+	return Vec4(f) / v4;
 }
 
 // vec4 /= float
@@ -340,25 +370,31 @@ inline Vec4 Vec4::operator*(const Mat4& m4) const
 // dot
 inline float Vec4::dot(const Vec4& b) const
 {
-	return x() * b.x() + y() * b.y() + z() * b.z() + w() * b.w();
+	#if defined(MATH_INTEL_SIMD)
+		float o;
+		_mm_store_ss(&o, _mm_dp_ps(mm, b.mm, 0xF1));
+		return o;
+	#else
+		return x() * b.x() + y() * b.y() + z() * b.z() + w() * b.w();
+	#endif
 }
 
 // getLength
 inline float Vec4::getLength() const
 {
-	return M::sqrt(x() * x() + y() * y() + z() * z() + w() * w());
+	return M::sqrt(dot(SELF));
 }
 
 // Normalized
 inline Vec4 Vec4::getNormalized() const
 {
-	return SELF * invSqrt(x() * x() + y() * y() + z() * z() + w() * w());
+	return SELF / getLength();
 }
 
 // normalize
 inline void Vec4::normalize()
 {
-	SELF *= invSqrt(x() * x() + y() * y() + z() * z() + w() * w());
+	SELF /= getLength();
 }
 
 // print

+ 2 - 2
src/Renderer/Is.cpp

@@ -71,8 +71,8 @@ void Is::calcPlanes()
 {
 	const Camera& cam = r.getCamera();
 
-	planes.x = cam.getZFar() / (cam.getZNear() - cam.getZFar());
-	planes.y = (cam.getZFar() * cam.getZNear()) / (cam.getZNear() -cam.getZFar());
+	planes.x() = cam.getZFar() / (cam.getZNear() - cam.getZFar());
+	planes.y() = (cam.getZFar() * cam.getZNear()) / (cam.getZNear() -cam.getZFar());
 }
 
 

+ 3 - 3
src/Resources/Helpers/MeshData.cpp

@@ -237,7 +237,7 @@ void MeshData::createVertTangents()
 		Vec2 uvedge02 = texCoords[i2] - texCoords[i0];
 
 
-		float det = (uvedge01.y * uvedge02.x) - (uvedge01.x * uvedge02.y);
+		float det = (uvedge01.y() * uvedge02.x()) - (uvedge01.x() * uvedge02.y());
 		if(isZero(det))
 		{
 			//WARNING(getRsrcName() << ": det == " << fixed << det);
@@ -248,8 +248,8 @@ void MeshData::createVertTangents()
 			det = 1.0 / det;
 		}
 
-		Vec3 t = (edge02 * uvedge01.y - edge01 * uvedge02.y) * det;
-		Vec3 b = (edge02 * uvedge01.x - edge01 * uvedge02.x) * det;
+		Vec3 t = (edge02 * uvedge01.y() - edge01 * uvedge02.y()) * det;
+		Vec3 b = (edge02 * uvedge01.x() - edge01 * uvedge02.x()) * det;
 		t.normalize();
 		b.normalize();
 

+ 3 - 2
src/Scripting/Math/Vec2.bpi.cpp

@@ -5,8 +5,9 @@
 WRAP(Vec2)
 {
 	class_<Vec2>("Vec2")
-		.def_readwrite("x", &Vec2::x)
-		.def_readwrite("y", &Vec2::y)
+		/// @todo fix this
+		/*.def_readwrite("x", &Vec2::x)
+		.def_readwrite("y", &Vec2::y)*/
 		// constructors
 		.def(init<>())
 		.def(init<float>())

+ 211 - 37
unit-tests/Math/Math.cpp

@@ -5,15 +5,29 @@
 
 
 const float RANGE_MIN = -1.00123;
-const float RANGE_MAX = 9.9990001;
-
+const float RANGE_MAX = 900.9990001;
+const float REALY_SMALL_FLOAT = 1.0e-3;
 
+/// Get random float and not zero cause of the divs
 static float randFloat()
 {
-	return Util::randRange(RANGE_MIN, RANGE_MAX);
+	float f;
+	while(true)
+	{
+		f = Util::randRange(RANGE_MIN, RANGE_MAX);
+		if(!isZero(f))
+		{
+			break;
+		}
+	}
+
+	return f;
 }
 
 
+//======================================================================================================================
+// Alignment                                                                                                           =
+//======================================================================================================================
 TEST(MathTests, Alignment)
 {
 	const int FS = sizeof(float); // float size
@@ -28,66 +42,226 @@ TEST(MathTests, Alignment)
 }
 
 
-TEST(MathTests, Constructors)
+//======================================================================================================================
+// Constructors                                                                                                        =
+//======================================================================================================================
+
+template<typename Type>
+void testCommonContructors()
 {
+	Type a, b;
+	float f;
+	float arr[sizeof(Type) / sizeof(float)];
+
+	f = randFloat();
+	for(uint i = 0; i < (sizeof(Type) / sizeof(float)); i++)
 	{
-		EXPECT_EQ(Vec4().x(), 0.0);
-		EXPECT_EQ(Vec4().y(), 0.0);
-		EXPECT_EQ(Vec4().z(), 0.0);
-		EXPECT_EQ(Vec4().w(), 0.0);
-
-		float f = randFloat();
-		Vec4 a(f);
-		EXPECT_EQ(a.x(), f);
-		EXPECT_EQ(a.y(), f);
-		EXPECT_EQ(a.z(), f);
-		EXPECT_EQ(a.w(), f);
-
-		float arr[4] = {randFloat(), randFloat(), randFloat(), randFloat()};
-		a = Vec4(arr);
-		EXPECT_EQ(a[0], arr[0]);
-		EXPECT_EQ(a.y(), arr[1]);
-		EXPECT_EQ(a.z(), arr[2]);
-		EXPECT_EQ(a[3], arr[3]);
+		a[i] = f;
+		b[i] =  randFloat();
+		arr[i] = b[i];
 	}
 
+	// float
+	EXPECT_EQ(Type(f), a);
+
+	// arr
+	EXPECT_EQ(Type(arr), b);
+
+	// Type
+	EXPECT_EQ(Type(b), b);
+}
+
+
+TEST(MathTests, Constructors)
+{
+	testCommonContructors<Vec2>();
+
+	testCommonContructors<Vec3>();
+
+	// Vec4
+	testCommonContructors<Vec4>();
+}
+
+
+//======================================================================================================================
+// Arithmetic                                                                                                          =
+//======================================================================================================================
+
+float addf(float a, float b)
+{
+	return a + b;
+}
+
+
+float subf(float a, float b)
+{
+	return a - b;
+}
+
 
+float mulf(float a, float b)
+{
+	return a * b;
 }
 
 
-template<typename Type, int size, Type (Type::* op)(const Type&) const>
-void testOperator()
+float divf(float a, float b)
+{
+	return a / b;
+}
+
+
+template<
+	typename Type,
+	Type (Type::* op)(const Type&) const,
+	Type& (Type::* compoundAssignment)(const Type&),
+	float (* normalOp)(float, float)>
+void testOperators()
 {
 	Type a, b, c;
 
-	for(int i = 0; i < size; i++)
+	for(uint i = 0; i < (sizeof(Type) / sizeof(float)); i++)
 	{
 		a[i] = randFloat();
 		b[i] = randFloat();
-		//c[i] = a[i] + b[i];
+		c[i] = normalOp(a[i], b[i]);
 	}
 
 	EXPECT_EQ((a.*op)(b), c);
 
-	/*a += b;
+	(a.*compoundAssignment)(b);
 
-	EXPECT_EQ(a, c);*/
+	EXPECT_EQ(a, c);
 }
 
 
-TEST(MathTests, Addition)
+template<
+	typename Type,
+	Type (Type::* op)(float) const,
+	Type& (Type::* compoundAssignment)(float),
+	Type (* opExtern)(float, const Type&),
+	float (* normalOp)(float, float)>
+void testOperatorsWithFloat()
 {
-	testOperator<Vec4, 4, &Vec4::operator+ >();
+	Type a, b, c;
+	float f = randFloat();
+
+	for(uint i = 0; i < (sizeof(Type) / sizeof(float)); i++)
+	{
+		a[i] = randFloat();
+		b[i] = normalOp(a[i], f);
+		c[i] = normalOp(f, a[i]);
+	}
+
+	EXPECT_EQ((a.*op)(f), b);
+
+	EXPECT_EQ(opExtern(f, a), c);
+
+	(a.*compoundAssignment)(f);
+	EXPECT_EQ(a, b);
 }
 
 
-TEST(MathTests, Substraction)
+template<typename Type>
+void testCmpOperators()
 {
-	Vec4 a(randFloat(), randFloat(), randFloat(), randFloat());
-	Vec4 b(randFloat(), randFloat(), randFloat(), randFloat());
-	EXPECT_EQ(a - b, Vec4(a.x() - b.x(), a.y() - b.y(), a.z() - b.z(), a.w() - b.w()));
+	Type a, b;
 
-	Vec4 c = a;
-	a -= b;
-	EXPECT_EQ(a, Vec4(c.x() - b.x(), c.y() - b.y(), c.z() - b.z(), c.w() - b.w()));
+	for(uint i = 0; i < (sizeof(Type) / sizeof(float)); i++)
+	{
+		a[i] = b[i] = randFloat();
+	}
+
+	EXPECT_EQ(a == b, true);
+	EXPECT_EQ(a != b, false);
+}
+
+
+template<typename Type>
+void testNegOperator()
+{
+	Type a, b;
+	for(int i = 0; i < (sizeof(Type) / sizeof(float)); i++)
+	{
+		a[i] = randFloat();
+		b[i] = -a[i];
+	}
+
+	EXPECT_EQ(-a == b, true);
+}
+
+
+template<typename Type>
+void arithmeticOperations()
+{
+	testOperators<Type, &Type::operator+, &Type::operator+=, &addf>();
+	testOperators<Type, &Type::operator-, &Type::operator-=, &subf>();
+	testOperators<Type, &Type::operator*, &Type::operator*=, &mulf>();
+	testOperators<Type, &Type::operator/, &Type::operator/=, &divf>();
+	testOperatorsWithFloat<Type, &Type::operator+, &Type::operator+=, &operator+, &addf>();
+	testOperatorsWithFloat<Type, &Type::operator-, &Type::operator-=, &operator-, &subf>();
+	testOperatorsWithFloat<Type, &Type::operator*, &Type::operator*=, &operator*, &mulf>();
+	testOperatorsWithFloat<Type, &Type::operator/, &Type::operator/=, &operator/, &divf>();
+	testCmpOperators<Type>();
+}
+
+
+TEST(MathTests, VectorArithmetic)
+{
+	arithmeticOperations<Vec2>();
+	arithmeticOperations<Vec3>();
+	arithmeticOperations<Vec4>();
+}
+
+
+template<typename Type>
+void testDotProd()
+{
+	Type a, b;
+	float o = 0.0;
+
+	for(uint i = 0; i < (sizeof(Type) / sizeof(float)); i++)
+	{
+		a[i] = randFloat();
+		b[i] = randFloat();
+		o += a[i] * b[i];
+	}
+
+	EXPECT_NEAR(a.dot(b), o, M::EPSILON);
+}
+
+
+TEST(MathTests, DotProducts)
+{
+	testDotProd<Vec2>();
+	testDotProd<Vec3>();
+	testDotProd<Vec4>();
+}
+
+
+template<typename Type>
+void testLengthAndNormalize()
+{
+	Type a;
+	float o = 0.0;
+
+	for(uint i = 0; i < (sizeof(Type) / sizeof(float)); i++)
+	{
+		a[i] = randFloat();
+		o += a[i] * a[i];
+	}
+
+	o = sqrt(o);
+
+	EXPECT_NEAR(a.getLength(), o, REALY_SMALL_FLOAT);
+	EXPECT_NEAR(a.getNormalized().getLength(), 1.0, REALY_SMALL_FLOAT);
+	//EXPECT_EQ(a.getNormalized() * a.getLength(), a);
+}
+
+
+TEST(MathTests, LengthsAndNormals)
+{
+	testLengthAndNormalize<Vec2>();
+	testLengthAndNormalize<Vec3>();
+	testLengthAndNormalize<Vec4>();
 }

+ 4 - 2
unit-tests/build/Makefile

@@ -1,7 +1,7 @@
 # Generated by gBuildSystem, command: ../../gbs/gbs.py 
 
 CXX = g++
-CFLAGS = -DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\"`svnversion -c ../..`\" -c -msse3 -mssse3 -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant
+CFLAGS = -DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\"`svnversion -c ../..`\" -c -msse4 -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant
 PHFLAGS = 
 LFLAGS = -rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread -lgtest
 EXECUTABLE = anki-unit-tests
@@ -5062,7 +5062,9 @@ Math.o: ../Math/Math.cpp ../../src/Math/Math.h ../../src/Math/Vec2.h \
  ../../src/Math/Mat3.inl.h ../../src/Math/Mat4.h \
  ../../src/Math/Mat4.inl.h ../../src/Math/MathFuncs.h \
  ../../src/Math/MathFuncs.inl.h ../../src/Math/Transform.h \
- ../../src/Math/Transform.inl.h ../../src/Util/Exception.h
+ ../../src/Math/Transform.inl.h ../../src/Util/Exception.h \
+ ../../src/Util/Util.h ../../src/Util/Vec.h ../../src/Util/Exception.h \
+ ../../src/Util/StdTypes.h
 	@echo Compiling ../Math/Math.cpp...
 	@$(CXX) $(INCPATH) $(CFLAGS) ../Math/Math.cpp -o Math.o
 

+ 1 - 1
unit-tests/build/gen.cfg.py

@@ -9,6 +9,6 @@ executableName = "anki-unit-tests"
 
 compiler = "g++"
 
-compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -msse3 -mssse3 -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant"
+compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -msse4 -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -pg -fsingle-precision-constant"
 
 linkerFlags = "-rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread -lgtest"