ソースを参照

- SIMD in Mat4 (WIP)
- Rename file

Panagiotis Christopoulos Charitos 15 年 前
コミット
18c0f8032b

+ 1 - 1
src/Core/App.cpp

@@ -146,7 +146,7 @@ void App::initWindow()
 	SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
 
 	// OpenWindow
-	windowId = SDL_CreateWindow("AnKi Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowW, windowH,
+	windowId = SDL_CreateWindow("AnKi 3D Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowW, windowH,
 	                            SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
 
 	if(!windowId)

+ 37 - 35
src/Math/Mat4.h

@@ -11,21 +11,13 @@ namespace M {
 class Mat4
 {
 	public:
-		/// @name Accessors
-		/// @{
-		float& operator ()(const uint i, const uint j);
-		const float& operator ()(const uint i, const uint j) const;
-		float& operator [](const uint i);
-		const float& operator [](const uint i) const;
-		/// @}
-
 		/// @name Constructors & distructors
 		/// @{
 		explicit Mat4() {}
 		explicit Mat4(float f);
 		explicit Mat4(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13,
 		              float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33);
-		explicit Mat4(const float arr []);
+		explicit Mat4(const float arr[]);
 		         Mat4(const Mat4& b);
 		explicit Mat4(const Mat3& m3);
 		explicit Mat4(const Vec3& v);
@@ -35,35 +27,43 @@ class Mat4
 		explicit Mat4(const Transform& t);
 		/// @}
 
+		/// @name Accessors
+		/// @{
+		float& operator()(const uint i, const uint j);
+		const float& operator()(const uint i, const uint j) const;
+		float& operator[](const uint i);
+		const float& operator[](const uint i) const;
+		/// @}
+
 		/// @name Operators with same type
 		/// @{
-		Mat4 operator +(const Mat4& b) const;
-		Mat4& operator +=(const Mat4& b);
-		Mat4 operator -(const Mat4& b) const;
-		Mat4& operator -=(const Mat4& b);
-		Mat4 operator *(const Mat4& b) const; ///< 64 muls, 48 adds
-		Mat4& operator *=(const Mat4& b);
-		Mat4 operator /(const Mat4& b) const;
-		Mat4& operator /=(const Mat4& b);
-		bool operator ==(const Mat4& b) const;
-		bool operator !=(const Mat4& b) const;
+		Mat4 operator+(const Mat4& b) const;
+		Mat4& operator+=(const Mat4& b);
+		Mat4 operator-(const Mat4& b) const;
+		Mat4& operator-=(const Mat4& b);
+		Mat4 operator*(const Mat4& b) const; ///< 64 muls, 48 adds
+		Mat4& operator*=(const Mat4& b);
+		Mat4 operator/(const Mat4& b) const;
+		Mat4& operator/=(const Mat4& b);
+		bool operator==(const Mat4& b) const;
+		bool operator!=(const Mat4& b) const;
 		/// @}
 
 		/// @name Operators with float
 		/// @{
-		Mat4  operator + (float f) const;
-		Mat4& operator +=(float f);
-		Mat4  operator - (float f) const;
-		Mat4& operator -=(float f);
-		Mat4  operator * (float f) const;
-		Mat4& operator *=(float f);
-		Mat4  operator / (float f) const;
-		Mat4& operator /=(float f);
+		Mat4  operator+(float f) const;
+		Mat4& operator+=(float f);
+		Mat4  operator-(float f) const;
+		Mat4& operator-=(float f);
+		Mat4  operator*(float f) const;
+		Mat4& operator*=(float f);
+		Mat4  operator/(float f) const;
+		Mat4& operator/=(float f);
 		/// @}
 
 		/// @name Operators with other types
 		/// @{
-		Vec4  operator *(const Vec4& v4) const; ///< 16 muls, 12 adds
+		Vec4 operator*(const Vec4& v4) const; ///< 16 muls, 12 adds
 		/// @}
 
 		/// @name Other
@@ -96,8 +96,11 @@ class Mat4
 		/// @{
 		union
 		{
-			float arr1[16];
-			float arr2[4][4];
+			boost::array<float, 16> arr1;
+			boost::array<boost::array<float, 4>, 4> arr2;
+			#if defined(MATH_INTEL_SIMD)
+				boost::array<__m128, 4> arrMm;
+			#endif
 		};
 		/// @}
 };
@@ -105,14 +108,13 @@ class Mat4
 
 /// @name Other operators
 /// @{
-extern Mat4 operator +(float f, const Mat4& m4);
-extern Mat4 operator -(float f, const Mat4& m4);
-extern Mat4 operator *(float f, const Mat4& m4);
-extern Mat4 operator /(float f, const Mat4& m4);
+extern Mat4 operator+(float f, const Mat4& m4);
+extern Mat4 operator-(float f, const Mat4& m4);
+extern Mat4 operator*(float f, const Mat4& m4);
+extern Mat4 operator/(float f, const Mat4& m4);
 extern std::ostream& operator<<(std::ostream& s, const Mat4& m);
 /// @}
 
-
 } // end namespace
 
 

ファイルの差分が大きいため隠しています
+ 471 - 321
src/Math/Mat4.inl.h


+ 10 - 17
src/Math/Vec2.h

@@ -11,16 +11,6 @@ namespace M {
 class Vec2
 {
 	public:
-		/// @name Accessors
-		/// @{
-		float& x();
-		float x() const;
-		float& y();
-		float y() const;
-		float& operator[](uint i);
-		float operator[](uint i) const;
-		/// @}
-
 		/// @name Constructors & distructors
 		/// @{
 		explicit Vec2();
@@ -30,9 +20,16 @@ class Vec2
 		         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 Accessors
+		/// @{
+		float& x();
+		float x() const;
+		float& y();
+		float y() const;
+		float& operator[](uint i);
+		float operator[](uint i) const;
 		/// @}
 
 		/// @name Operators with same type
@@ -81,10 +78,6 @@ class Vec2
 			} vec;
 
 			boost::array<float, 2> arr;
-
-			#if defined(MATH_INTEL_SIMD)
-				__m64 mm;
-			#endif
 		};
 		/// @}
 };

+ 64 - 40
src/Math/Vec2.inl.h

@@ -7,85 +7,97 @@
 namespace M {
 
 
-// accessors
+//======================================================================================================================
+// Constructors                                                                                                                    =
+//======================================================================================================================
 
-inline float& Vec2::x()
+// default
+inline Vec2::Vec2()
 {
-	return vec.x;
+	x() = y() = 0.0;
 }
 
-inline float Vec2::x() const
+// float
+inline Vec2::Vec2(float f)
 {
-	return vec.x;
+	x() = y() = f;
 }
 
-inline float& Vec2::y()
+// float, float
+inline Vec2::Vec2(float x_, float y_)
 {
-	return vec.y;
+	x() = x_;
+	y() = y_;
 }
 
-inline float Vec2::y() const
+// float[]
+inline Vec2::Vec2(float arr[])
 {
-	return vec.y;
+	x() = arr[0];
+	y() = arr[1];
 }
 
-inline float& Vec2::operator[](uint i)
+// vec2
+inline Vec2::Vec2(const Vec2& b)
 {
-	return arr[i];
+	x() = b.x();
+	y() = b.y();
 }
 
-inline float Vec2::operator[](uint i) const
+// vec3
+inline Vec2::Vec2(const Vec3& v3)
 {
-	return arr[i];
+	x() = v3.x();
+	y() = v3.y();
 }
 
-// constructor []
-inline Vec2::Vec2()
+// vec4
+inline Vec2::Vec2(const Vec4& v4)
 {
-	x() = y() = 0.0;
+	x() = v4.x();
+	y() = v4.y();
 }
 
-// constructor [float, float]
-inline Vec2::Vec2(float x_, float y_)
+
+//======================================================================================================================
+// Accessors                                                                                                           =
+//======================================================================================================================
+
+inline float& Vec2::x()
 {
-	x() = x_;
-	y() = y_;
+	return vec.x;
 }
 
-// constructor [float]
-inline Vec2::Vec2(float f)
+inline float Vec2::x() const
 {
-	x() = y() = f;
+	return vec.x;
 }
 
-// constructor [float[]]
-inline Vec2::Vec2(float arr[])
+inline float& Vec2::y()
 {
-	x() = arr[0];
-	y() = arr[1];
+	return vec.y;
 }
 
-// constructor [vec2]
-inline Vec2::Vec2(const Vec2& b)
+inline float Vec2::y() const
 {
-	x() = b.x();
-	y() = b.y();
+	return vec.y;
 }
 
-// constructor [vec3]
-inline Vec2::Vec2(const Vec3& v3)
+inline float& Vec2::operator[](uint i)
 {
-	x() = v3.x();
-	y() = v3.y();
+	return arr[i];
 }
 
-// constructor [vec4]
-inline Vec2::Vec2(const Vec4& v4)
+inline float Vec2::operator[](uint i) const
 {
-	x() = v4.x();
-	y() = v4.y();
+	return arr[i];
 }
 
+
+//======================================================================================================================
+// Operators with same                                                                                                 =
+//======================================================================================================================
+
 // +
 inline Vec2 Vec2::operator+(const Vec2& b) const
 {
@@ -160,6 +172,11 @@ inline bool Vec2::operator!=(const Vec2& b) const
 	return !(isZero(x() - b.x()) && isZero(y() - b.y()));
 }
 
+
+//======================================================================================================================
+// Operators with float                                                                                                =
+//======================================================================================================================
+
 // vec2 + float
 inline Vec2 Vec2::operator+(float f) const
 {
@@ -236,6 +253,10 @@ inline Vec2& Vec2::operator/=(float f)
 	return ME;
 }
 
+//======================================================================================================================
+// Misc methods                                                                                                        =
+//======================================================================================================================
+
 // getLength
 inline float Vec2::getLength() const
 {
@@ -260,7 +281,10 @@ inline float Vec2::dot(const Vec2& b) const
 	return x() * b.x() + y() * b.y();
 }
 
-// print
+
+//======================================================================================================================
+// Print                                                                                                               =
+//======================================================================================================================
 inline std::ostream& operator<<(std::ostream& s, const Vec2& v)
 {
 	s << v.x() << ' ' << v.y();

+ 1 - 1
src/Scripting/ScriptingCommon.h

@@ -39,7 +39,7 @@ void setterSv(ClassType* t, InType in)
 	(t->*accessor)(in);
 }
 
-/// Boost python property for simple RW types (int, float etc) that cannot be wrapped by boost::python correctly
+/// Boost python property for simple types (int, float etc) that cannot be wrapped by boost::python correctly
 #define BP_PROPERTY_BASIC_TYPE(Type__, Class__, var__, getter__, setter__) \
 	.add_property(var__, &getterSv<Class__, Type__, &Class__::getter__>, \
 	              &setterSv<Class__, Type__, &Class__::setter__>)

+ 1 - 1
src/Scripting/ScriptingEngine.cpp

@@ -4,7 +4,7 @@
 #include "Logger.h"
 
 
-extern "C" void initAnki(); /// Defined in BoostPythonInterfaces.cpp
+extern "C" void initAnki(); /// Defined in BoostPythonInterfaces.cpp by boost::python
 
 
 //======================================================================================================================

+ 0 - 0
unit-tests/Math/Math.cpp → unit-tests/Math/Math.ut.cpp


ファイルの差分が大きいため隠しています
+ 0 - 0
unit-tests/build/Makefile


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません