ソースを参照

- DDS
- Code style

Panagiotis Christopoulos Charitos 14 年 前
コミット
b92af78496
49 ファイル変更2051 行追加2145 行削除
  1. 2 2
      anki/core/App.cpp
  2. 0 8
      anki/gl/TimeQuery.cpp
  3. 0 8
      anki/gl/Vao.cpp
  4. 0 6
      anki/input/Input.cpp
  5. 60 57
      anki/input/Input.h
  6. 37 37
      anki/math/Axisang.h
  7. 3 6
      anki/math/Axisang.inl.h
  8. 44 44
      anki/math/Euler.h
  9. 108 108
      anki/math/Mat3.h
  10. 112 112
      anki/math/Mat4.h
  11. 0 7
      anki/math/Math.cpp
  12. 29 29
      anki/math/Math.h
  13. 8 0
      anki/math/Math.inl.h
  14. 71 71
      anki/math/Quat.h
  15. 45 45
      anki/math/Transform.h
  16. 2 6
      anki/math/Transform.inl.h
  17. 82 82
      anki/math/Vec2.h
  18. 120 120
      anki/math/Vec3.h
  19. 1 1
      anki/math/Vec3.inl.h
  20. 97 97
      anki/math/Vec4.h
  21. 51 51
      anki/resource/AsyncOperator.h
  22. 21 21
      anki/resource/AsyncTextureResourceManager.h
  23. 23 30
      anki/resource/DummyRsrc.h
  24. 13 14
      anki/resource/Extension.h
  25. 14 20
      anki/resource/Image.cpp
  26. 112 112
      anki/resource/Image.h
  27. 0 4
      anki/resource/LightRsrc.cpp
  28. 79 79
      anki/resource/LightRsrc.h
  29. 26 26
      anki/resource/MaterialShaderProgramCreator.h
  30. 1 1
      anki/resource/MaterialVariable.cpp
  31. 0 4
      anki/resource/Mesh.cpp
  32. 170 170
      anki/resource/Mesh.h
  33. 0 12
      anki/resource/MeshData.cpp
  34. 96 96
      anki/resource/MeshData.h
  35. 0 2
      anki/resource/Model.cpp
  36. 18 18
      anki/resource/Model.h
  37. 43 43
      anki/resource/ModelPatch.h
  38. 6 14
      anki/resource/ParticleEmitterRsrc.cpp
  39. 23 23
      anki/resource/ResourceManager.h
  40. 80 80
      anki/resource/ResourcePointer.h
  41. 4 4
      anki/resource/Script.h
  42. 1 1
      anki/resource/ShaderProgram.h
  43. 5 5
      anki/resource/ShaderProgramAttributeVariable.h
  44. 122 137
      anki/resource/ShaderProgramPrePreprocessor.h
  45. 26 26
      anki/resource/ShaderProgramUniformVariable.h
  46. 63 65
      anki/resource/SkelAnim.h
  47. 88 88
      anki/resource/Skeleton.h
  48. 23 23
      anki/resource/Skin.h
  49. 122 130
      anki/resource/Texture.h

+ 2 - 2
anki/core/App.cpp

@@ -65,8 +65,8 @@ void App::parseCommandLineArgs(int argc, char* argv[])
 		}
 		else
 		{
-			std::cerr << "Incorrect command line argument \"" << arg << "\"" <<
-				std::endl;
+			std::cerr << "Incorrect command line argument \"" << arg <<
+				"\"" << std::endl;
 			abort();
 		}
 	}

+ 0 - 8
anki/gl/TimeQuery.cpp

@@ -6,8 +6,6 @@
 namespace anki {
 
 
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
 TimeQuery::TimeQuery()
 {
@@ -16,8 +14,6 @@ TimeQuery::TimeQuery()
 }
 
 
-//==============================================================================
-// Destructor                                                                  =
 //==============================================================================
 TimeQuery::~TimeQuery()
 {
@@ -25,8 +21,6 @@ TimeQuery::~TimeQuery()
 }
 
 
-//==============================================================================
-// begin                                                                       =
 //==============================================================================
 void TimeQuery::begin()
 {
@@ -38,8 +32,6 @@ void TimeQuery::begin()
 }
 
 
-//==============================================================================
-// end                                                                         =
 //==============================================================================
 double TimeQuery::end()
 {

+ 0 - 8
anki/gl/Vao.cpp

@@ -7,8 +7,6 @@
 namespace anki {
 
 
-//==============================================================================
-// Destructor                                                                  =
 //==============================================================================
 Vao::~Vao()
 {
@@ -19,8 +17,6 @@ Vao::~Vao()
 }
 
 
-//==============================================================================
-// attachArrayBufferVbo                                                        =
 //==============================================================================
 void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation,
 	GLint size, GLenum type, GLboolean normalized, GLsizei stride,
@@ -46,8 +42,6 @@ void Vao::attachArrayBufferVbo(const Vbo& vbo, uint attribVarLocation,
 }
 
 
-//==============================================================================
-// attachArrayBufferVbo                                                        =
 //==============================================================================
 void Vao::attachArrayBufferVbo(const Vbo& vbo,
 	const ShaderProgramAttributeVariable& attribVar,
@@ -59,8 +53,6 @@ void Vao::attachArrayBufferVbo(const Vbo& vbo,
 }
 
 
-//==============================================================================
-// attachElementArrayBufferVbo                                                 =
 //==============================================================================
 void Vao::attachElementArrayBufferVbo(const Vbo& vbo)
 {

+ 0 - 6
anki/input/Input.cpp

@@ -8,8 +8,6 @@
 namespace anki {
 
 
-//==============================================================================
-// init                                                                        =
 //==============================================================================
 void Input::init()
 {
@@ -21,8 +19,6 @@ void Input::init()
 }
 
 
-//==============================================================================
-// reset                                                                       =
 //==============================================================================
 void Input::reset(void)
 {
@@ -33,8 +29,6 @@ void Input::reset(void)
 }
 
 
-//==============================================================================
-// handleEvents                                                                =
 //==============================================================================
 void Input::handleEvents()
 {

+ 60 - 57
anki/input/Input.h

@@ -12,63 +12,66 @@ namespace anki {
 /// Handle the SDL input
 class Input
 {
-	public:
-		Input() {init();}
-
-		/// @name Acessors
-		/// @{
-		short getKey(uint i) const
-		{
-			return keys[i];
-		}
-
-		short getMouseBtn(uint i) const
-		{
-			return mouseBtns[i];
-		}
-
-		bool getWarpMouse() const
-		{
-			return warpMouseFlag;
-		}
-		bool& getWarpMouse()
-		{
-			return warpMouseFlag;
-		}
-		void setWarpMouse(const bool x)
-		{
-			warpMouseFlag = x;
-		}
-		/// @}
-
-		void reset();
-		void handleEvents();
-
-		// mouse stuff
-		Vec2 mousePosNdc; ///< The coords are in the NDC space
-		/// The coords are in the window space. (0, 0) is in the upper left
-		/// corner
-		Vec2 mousePos;
-		Vec2 mouseVelocity;
-		bool hideCursor;
-
-	private:
-		/// @name Keys and btns
-		/// @{
-
-		/// Shows the current key state
-		/// - 0 times: unpressed
-		/// - 1 times: pressed once
-		/// - >1 times: Kept pressed 'n' times continuously
-		boost::array<short, SDL_NUM_SCANCODES> keys;
-
-		/// Mouse btns. Supporting 3 btns & wheel. @see keys
-		boost::array<short, 8> mouseBtns;
-		/// @}
-
-		bool warpMouseFlag;
-
-		void init();
+public:
+	Input()
+	{
+		init();
+	}
+
+	/// @name Acessors
+	/// @{
+	short getKey(uint i) const
+	{
+		return keys[i];
+	}
+
+	short getMouseBtn(uint i) const
+	{
+		return mouseBtns[i];
+	}
+
+	bool getWarpMouse() const
+	{
+		return warpMouseFlag;
+	}
+	bool& getWarpMouse()
+	{
+		return warpMouseFlag;
+	}
+	void setWarpMouse(const bool x)
+	{
+		warpMouseFlag = x;
+	}
+	/// @}
+
+	void reset();
+	void handleEvents();
+
+	// mouse stuff
+	Vec2 mousePosNdc; ///< The coords are in the NDC space
+	/// The coords are in the window space. (0, 0) is in the upper left
+	/// corner
+	Vec2 mousePos;
+	Vec2 mouseVelocity;
+	bool hideCursor;
+
+private:
+	/// @name Keys and btns
+	/// @{
+
+	/// Shows the current key state
+	/// - 0 times: unpressed
+	/// - 1 times: pressed once
+	/// - >1 times: Kept pressed 'n' times continuously
+	boost::array<short, SDL_NUM_SCANCODES> keys;
+
+	/// Mouse btns. Supporting 3 btns & wheel. @see keys
+	boost::array<short, 8> mouseBtns;
+	/// @}
+
+	bool warpMouseFlag;
+
+	void init();
 };
 
 

+ 37 - 37
anki/math/Axisang.h

@@ -14,43 +14,43 @@ namespace anki {
 /// Axis angles. Used for rotations
 class Axisang
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Axisang();
-		         Axisang(const Axisang& b);
-		explicit Axisang(const float rad, const Vec3& axis_);
-		explicit Axisang(const Quat& q);
-		explicit Axisang(const Mat3& m3);
-		/// @}
-		
-		/// @name Accessors
-		/// @{
-		float getAngle() const;
-		float& getAngle();
-		void setAngle(const float a);
-		
-		const Vec3& getAxis() const;
-		Vec3& getAxis();
-		void setAxis(const Vec3& a);
-		/// @}
-		
-		/// @name Operators with same type
-		/// @{
-		Axisang& operator=(const Axisang& b);
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend std::ostream& operator<<(std::ostream& s, const Axisang& a);
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		float ang;
-		Vec3 axis;
-		/// @}
+public:
+	/// @name Constructors
+	/// @{
+	explicit Axisang();
+			 Axisang(const Axisang& b);
+	explicit Axisang(const float rad, const Vec3& axis_);
+	explicit Axisang(const Quat& q);
+	explicit Axisang(const Mat3& m3);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float getAngle() const;
+	float& getAngle();
+	void setAngle(const float a);
+
+	const Vec3& getAxis() const;
+	Vec3& getAxis();
+	void setAxis(const Vec3& a);
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	Axisang& operator=(const Axisang& b);
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend std::ostream& operator<<(std::ostream& s, const Axisang& a);
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	float ang;
+	Vec3 axis;
+	/// @}
 };
 /// @}
 

+ 3 - 6
anki/math/Axisang.inl.h

@@ -10,22 +10,19 @@ namespace anki {
 
 // Default
 inline Axisang::Axisang()
-:	ang(0.0),
-	axis(0.0)
+	: ang(0.0), axis(0.0)
 {}
 
 
 // Copy
 inline Axisang::Axisang(const Axisang& b)
-:	ang(b.ang),
-	axis(b.axis)
+	: ang(b.ang), axis(b.axis)
 {}
 
 
 // float, axis
 inline Axisang::Axisang(const float rad, const Vec3& axis_)
-:	ang(rad),
-	axis(axis_)
+	: ang(rad), axis(axis_)
 {}
 
 

+ 44 - 44
anki/math/Euler.h

@@ -14,51 +14,51 @@ namespace anki {
 /// accurately though
 class Euler
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Euler();
-		explicit Euler(const float x, const float y, const float z);
-		         Euler(const Euler& b);
-		explicit Euler(const Quat& q);
-		explicit Euler(const Mat3& m3);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float& operator [](const size_t i);
-		float operator [](const size_t i) const;
-		float& x();
-		float x() const;
-		float& y();
-		float y() const;
-		float& z();
-		float z() const;
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		Euler& operator=(const Euler& b);
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend std::ostream& operator<<(std::ostream& s, const Euler& e);
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		union
+public:
+	/// @name Constructors
+	/// @{
+	explicit Euler();
+	explicit Euler(const float x, const float y, const float z);
+			 Euler(const Euler& b);
+	explicit Euler(const Quat& q);
+	explicit Euler(const Mat3& m3);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float& operator [](const size_t i);
+	float operator [](const size_t i) const;
+	float& x();
+	float x() const;
+	float& y();
+	float y() const;
+	float& z();
+	float z() const;
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	Euler& operator=(const Euler& b);
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend std::ostream& operator<<(std::ostream& s, const Euler& e);
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	union
+	{
+		struct
 		{
-			struct
-			{
-				float x, y, z;
-			} vec;
-
-			boost::array<float, 3> arr;
-		};
-		/// @}
+			float x, y, z;
+		} vec;
+
+		boost::array<float, 3> arr;
+	};
+	/// @}
 };
 /// @}
 

+ 108 - 108
anki/math/Mat3.h

@@ -14,114 +14,114 @@ namespace anki {
 /// functions. Its row major
 class Mat3
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Mat3() {};
-		explicit Mat3(const float f);
-		explicit Mat3(const float m00, const float m01, const float m02,
-			const float m10, const float m11, const float m12,
-			const float m20, const float m21, const float m22);
-		explicit Mat3(const float arr[]);
-		         Mat3(const Mat3& b);
-		explicit Mat3(const Quat& q); ///< Quat to Mat3. 12 muls, 12 adds
-		explicit Mat3(const Euler& eu);
-		explicit Mat3(const Axisang& axisang);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float& operator()(const size_t i, const size_t j);
-		const float& operator()(const size_t i, const size_t j) const;
-		float& operator[](const size_t i);
-		const float& operator[](const size_t i) const;
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		Mat3& operator=(const Mat3& b);
-		Mat3 operator+(const Mat3& b) const;
-		Mat3& operator+=(const Mat3& b);
-		Mat3 operator-(const Mat3& b) const;
-		Mat3& operator-=(const Mat3& b);
-		Mat3 operator*(const Mat3& b) const; ///< 27 muls, 18 adds
-		Mat3& operator*=(const Mat3& b);
-		Mat3 operator/(const Mat3& b) const;
-		Mat3& operator/=(const Mat3& b);
-		bool operator==(const Mat3& b) const;
-		bool operator!=(const Mat3& b) const;
-		/// @}
-
-		/// @name Operators with float
-		/// @{
-		Mat3 operator+(const float f) const;
-		Mat3& operator+=(const float f);
-		Mat3 operator-(const float f) const;
-		Mat3& operator-=(const float f);
-		Mat3 operator*(const float f) const;
-		Mat3& operator*=(const float f);
-		Mat3 operator/(const float f) const;
-		Mat3& operator/=(const float f);
-		/// @}
-
-		/// @name Operators with others
-		/// @{
-		Vec3 operator*(const Vec3& b) const;  ///< 9 muls, 6 adds
-		/// @}
-
-		/// @name Other
-		/// @{
-		void setRows(const Vec3& a, const Vec3& b, const Vec3& c);
-		void setRow(const size_t i, const Vec3& v);
-		void getRows(Vec3& a, Vec3& b, Vec3& c) const;
-		Vec3 getRow(const size_t i) const;
-		void setColumns(const Vec3& a, const Vec3& b, const Vec3& c);
-		void setColumn(const size_t i, const Vec3& v);
-		void getColumns(Vec3& a, Vec3& b, Vec3& c) const;
-		Vec3 getColumn(const size_t i) const;
-		Vec3 getXAxis() const; ///< Get 1st column
-		Vec3 getYAxis() const; ///< Get 2nd column
-		Vec3 getZAxis() const; ///< Get 3rd column
-		void setXAxis(const Vec3& v3); ///< Set 1st column
-		void setYAxis(const Vec3& v3); ///< Set 2nd column
-		void setZAxis(const Vec3& v3); ///< Set 3rd column
-		void setRotationX(const float rad);
-		void setRotationY(const float rad);
-		void setRotationZ(const float rad);
-		/// It rotates "this" in the axis defined by the rotation AND not the
-		/// world axis
-		void rotateXAxis(const float rad);
-		void rotateYAxis(const float rad); ///< @copybrief rotateXAxis
-		void rotateZAxis(const float rad); ///< @copybrief rotateXAxis
-		void transpose();
-		Mat3 getTransposed() const;
-		void reorthogonalize();
-		float getDet() const;
-		void invert();
-		Mat3 getInverse() const;
-		void setIdentity();
-		static const Mat3& getZero();
-		static const Mat3& getIdentity();
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend Mat3 operator+(float f, const Mat3& m3);
-		friend Mat3 operator-(float f, const Mat3& m3);
-		friend Mat3 operator*(float f, const Mat3& m3);
-		friend Mat3 operator/(float f, const Mat3& m3);
-		friend std::ostream& operator<<(std::ostream& s, const Mat3& m);
-		/// @}
-
-	private:
-		/// @name Data members
-		/// @{
-		union
-		{
-			boost::array<float, 9> arr1;
-			boost::array<boost::array<float, 3>, 3> arr2;
-		};
-		/// @}
+public:
+	/// @name Constructors
+	/// @{
+	explicit Mat3() {};
+	explicit Mat3(const float f);
+	explicit Mat3(const float m00, const float m01, const float m02,
+		const float m10, const float m11, const float m12,
+		const float m20, const float m21, const float m22);
+	explicit Mat3(const float arr[]);
+			 Mat3(const Mat3& b);
+	explicit Mat3(const Quat& q); ///< Quat to Mat3. 12 muls, 12 adds
+	explicit Mat3(const Euler& eu);
+	explicit Mat3(const Axisang& axisang);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float& operator()(const size_t i, const size_t j);
+	const float& operator()(const size_t i, const size_t j) const;
+	float& operator[](const size_t i);
+	const float& operator[](const size_t i) const;
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	Mat3& operator=(const Mat3& b);
+	Mat3 operator+(const Mat3& b) const;
+	Mat3& operator+=(const Mat3& b);
+	Mat3 operator-(const Mat3& b) const;
+	Mat3& operator-=(const Mat3& b);
+	Mat3 operator*(const Mat3& b) const; ///< 27 muls, 18 adds
+	Mat3& operator*=(const Mat3& b);
+	Mat3 operator/(const Mat3& b) const;
+	Mat3& operator/=(const Mat3& b);
+	bool operator==(const Mat3& b) const;
+	bool operator!=(const Mat3& b) const;
+	/// @}
+
+	/// @name Operators with float
+	/// @{
+	Mat3 operator+(const float f) const;
+	Mat3& operator+=(const float f);
+	Mat3 operator-(const float f) const;
+	Mat3& operator-=(const float f);
+	Mat3 operator*(const float f) const;
+	Mat3& operator*=(const float f);
+	Mat3 operator/(const float f) const;
+	Mat3& operator/=(const float f);
+	/// @}
+
+	/// @name Operators with others
+	/// @{
+	Vec3 operator*(const Vec3& b) const;  ///< 9 muls, 6 adds
+	/// @}
+
+	/// @name Other
+	/// @{
+	void setRows(const Vec3& a, const Vec3& b, const Vec3& c);
+	void setRow(const size_t i, const Vec3& v);
+	void getRows(Vec3& a, Vec3& b, Vec3& c) const;
+	Vec3 getRow(const size_t i) const;
+	void setColumns(const Vec3& a, const Vec3& b, const Vec3& c);
+	void setColumn(const size_t i, const Vec3& v);
+	void getColumns(Vec3& a, Vec3& b, Vec3& c) const;
+	Vec3 getColumn(const size_t i) const;
+	Vec3 getXAxis() const; ///< Get 1st column
+	Vec3 getYAxis() const; ///< Get 2nd column
+	Vec3 getZAxis() const; ///< Get 3rd column
+	void setXAxis(const Vec3& v3); ///< Set 1st column
+	void setYAxis(const Vec3& v3); ///< Set 2nd column
+	void setZAxis(const Vec3& v3); ///< Set 3rd column
+	void setRotationX(const float rad);
+	void setRotationY(const float rad);
+	void setRotationZ(const float rad);
+	/// It rotates "this" in the axis defined by the rotation AND not the
+	/// world axis
+	void rotateXAxis(const float rad);
+	void rotateYAxis(const float rad); ///< @copybrief rotateXAxis
+	void rotateZAxis(const float rad); ///< @copybrief rotateXAxis
+	void transpose();
+	Mat3 getTransposed() const;
+	void reorthogonalize();
+	float getDet() const;
+	void invert();
+	Mat3 getInverse() const;
+	void setIdentity();
+	static const Mat3& getZero();
+	static const Mat3& getIdentity();
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend Mat3 operator+(float f, const Mat3& m3);
+	friend Mat3 operator-(float f, const Mat3& m3);
+	friend Mat3 operator*(float f, const Mat3& m3);
+	friend Mat3 operator/(float f, const Mat3& m3);
+	friend std::ostream& operator<<(std::ostream& s, const Mat3& m);
+	/// @}
+
+private:
+	/// @name Data members
+	/// @{
+	union
+	{
+		boost::array<float, 9> arr1;
+		boost::array<boost::array<float, 3>, 3> arr2;
+	};
+	/// @}
 };
 /// @}
 

+ 112 - 112
anki/math/Mat4.h

@@ -14,122 +14,122 @@ namespace anki {
 /// row major. SSE optimized
 class Mat4
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Mat4() {}
-		explicit Mat4(const float f);
-		explicit Mat4(const float m00, const float m01, const float m02,
-			const float m03, const float m10, const float m11,
-			const float m12, const float m13, const float m20,
-			const float m21, const float m22, const float m23,
-			const float m30, const float m31, const float m32,
-			const float m33);
-		explicit Mat4(const float arr[]);
-		         Mat4(const Mat4& b);
-		explicit Mat4(const Mat3& m3);
-		explicit Mat4(const Vec3& v);
-		explicit Mat4(const Vec4& v);
-		explicit Mat4(const Vec3& transl, const Mat3& rot);
-		explicit Mat4(const Vec3& transl, const Mat3& rot, const float scale);
-		explicit Mat4(const Transform& t);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float& operator()(const size_t i, const size_t j);
-		const float& operator()(const size_t i, const size_t j) const;
-		float& operator[](const size_t i);
-		const float& operator[](const size_t i) const;
+public:
+	/// @name Constructors
+	/// @{
+	explicit Mat4() {}
+	explicit Mat4(const float f);
+	explicit Mat4(const float m00, const float m01, const float m02,
+		const float m03, const float m10, const float m11,
+		const float m12, const float m13, const float m20,
+		const float m21, const float m22, const float m23,
+		const float m30, const float m31, const float m32,
+		const float m33);
+	explicit Mat4(const float arr[]);
+			 Mat4(const Mat4& b);
+	explicit Mat4(const Mat3& m3);
+	explicit Mat4(const Vec3& v);
+	explicit Mat4(const Vec4& v);
+	explicit Mat4(const Vec3& transl, const Mat3& rot);
+	explicit Mat4(const Vec3& transl, const Mat3& rot, const float scale);
+	explicit Mat4(const Transform& t);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float& operator()(const size_t i, const size_t j);
+	const float& operator()(const size_t i, const size_t j) const;
+	float& operator[](const size_t i);
+	const float& operator[](const size_t i) const;
 #if defined(ANKI_MATH_INTEL_SIMD)
-		__m128& getMm(const size_t i);
-		const __m128& getMm(const size_t i) const;
+	__m128& getMm(const size_t i);
+	const __m128& getMm(const size_t i) const;
 #endif
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		Mat4& operator=(const Mat4& b);
-		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+(const float f) const;
-		Mat4& operator+=(const float f);
-		Mat4  operator-(const float f) const;
-		Mat4& operator-=(const float f);
-		Mat4  operator*(const float f) const;
-		Mat4& operator*=(const float f);
-		Mat4  operator/(const float f) const;
-		Mat4& operator/=(const float f);
-		/// @}
-
-		/// @name Operators with other types
-		/// @{
-		Vec4 operator*(const Vec4& v4) const; ///< 16 muls, 12 adds
-		/// @}
-
-		/// @name Other
-		/// @{
-		void setRows(const Vec4& a, const Vec4& b, const Vec4& c,
-			const Vec4& d);
-		void setRow(const size_t i, const Vec4& v);
-		void setColumns(const Vec4& a, const Vec4& b, const Vec4& c,
-			const Vec4& d);
-		void setColumn(const size_t i, const Vec4& v);
-		void setRotationPart(const Mat3& m3);
-		void setTranslationPart(const Vec4& v4);
-		Mat3 getRotationPart() const;
-		void setTranslationPart(const Vec3& v3);
-		Vec3 getTranslationPart() const;
-		void transpose();
-		Mat4 getTransposed() const;
-		float getDet() const;
-		Mat4 getInverse() const; ///< Invert using Cramer's rule
-		void invert(); ///< See getInverse
-		/// If we suppose this matrix represents a transformation, return the
-		/// inverted transformation
-		Mat4 getInverseTransformation() const;
-		Mat4 lerp(const Mat4& b, float t) const;
-		void setIdentity();
-		/// 12 muls, 27 adds. Something like m4 = m0 * m1 but without touching
-		/// the 4rth row and allot faster
-		static Mat4 combineTransformations(const Mat4& m0, const Mat4& m1);
-		static const Mat4& getIdentity();
-		static const Mat4& getZero();
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend Mat4 operator+(const float f, const Mat4& m4);
-		friend Mat4 operator-(const float f, const Mat4& m4);
-		friend Mat4 operator*(const float f, const Mat4& m4);
-		friend Mat4 operator/(const float f, const Mat4& m4);
-		friend std::ostream& operator<<(std::ostream& s, const Mat4& m);
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		union
-		{
-			boost::array<float, 16> arr1;
-			boost::array<boost::array<float, 4>, 4> arr2;
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	Mat4& operator=(const Mat4& b);
+	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+(const float f) const;
+	Mat4& operator+=(const float f);
+	Mat4  operator-(const float f) const;
+	Mat4& operator-=(const float f);
+	Mat4  operator*(const float f) const;
+	Mat4& operator*=(const float f);
+	Mat4  operator/(const float f) const;
+	Mat4& operator/=(const float f);
+	/// @}
+
+	/// @name Operators with other types
+	/// @{
+	Vec4 operator*(const Vec4& v4) const; ///< 16 muls, 12 adds
+	/// @}
+
+	/// @name Other
+	/// @{
+	void setRows(const Vec4& a, const Vec4& b, const Vec4& c,
+		const Vec4& d);
+	void setRow(const size_t i, const Vec4& v);
+	void setColumns(const Vec4& a, const Vec4& b, const Vec4& c,
+		const Vec4& d);
+	void setColumn(const size_t i, const Vec4& v);
+	void setRotationPart(const Mat3& m3);
+	void setTranslationPart(const Vec4& v4);
+	Mat3 getRotationPart() const;
+	void setTranslationPart(const Vec3& v3);
+	Vec3 getTranslationPart() const;
+	void transpose();
+	Mat4 getTransposed() const;
+	float getDet() const;
+	Mat4 getInverse() const; ///< Invert using Cramer's rule
+	void invert(); ///< See getInverse
+	/// If we suppose this matrix represents a transformation, return the
+	/// inverted transformation
+	Mat4 getInverseTransformation() const;
+	Mat4 lerp(const Mat4& b, float t) const;
+	void setIdentity();
+	/// 12 muls, 27 adds. Something like m4 = m0 * m1 but without touching
+	/// the 4rth row and allot faster
+	static Mat4 combineTransformations(const Mat4& m0, const Mat4& m1);
+	static const Mat4& getIdentity();
+	static const Mat4& getZero();
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend Mat4 operator+(const float f, const Mat4& m4);
+	friend Mat4 operator-(const float f, const Mat4& m4);
+	friend Mat4 operator*(const float f, const Mat4& m4);
+	friend Mat4 operator/(const float f, const Mat4& m4);
+	friend std::ostream& operator<<(std::ostream& s, const Mat4& m);
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	union
+	{
+		boost::array<float, 16> arr1;
+		boost::array<boost::array<float, 4>, 4> arr2;
 #if defined(ANKI_MATH_INTEL_SIMD)
-			boost::array<__m128, 4> arrMm;
+		boost::array<__m128, 4> arrMm;
 #endif
-		};
-		/// @}
+	};
+	/// @}
 };
 /// @}
 

+ 0 - 7
anki/math/Math.cpp

@@ -5,15 +5,10 @@ namespace anki {
 
 
 //==============================================================================
-// Statics                                                                     =
-//==============================================================================
-
 const float Math::PI = 3.14159265358979323846;
 const float Math::EPSILON = 1.0e-6;
 
 
-//==============================================================================
-// polynomialSinQuadrant                                                       =
 //==============================================================================
 float Math::polynomialSinQuadrant(const float a)
 {
@@ -22,8 +17,6 @@ float Math::polynomialSinQuadrant(const float a)
 }
 
 
-//==============================================================================
-// sinCos                                                                      =
 //==============================================================================
 void Math::sinCos(const float a_, float& sina, float& cosa)
 {

+ 29 - 29
anki/math/Math.h

@@ -13,45 +13,45 @@ namespace anki {
 /// Useful and optimized math functions
 class Math
 {
-	public:
-		static const float PI;
-		static const float EPSILON;
+public:
+	static const float PI;
+	static const float EPSILON;
 
-		/// A fast func that given the angle in rads it returns the sin and cos
-		static void sinCos(const float rad, float& sin_, float& cos_);
+	/// A fast func that given the angle in rads it returns the sin and cos
+	static void sinCos(const float rad, float& sin_, float& cos_);
 
-		/// Optimized square root
-		static float sqrt(const float f);
+	/// Optimized square root
+	static float sqrt(const float f);
 
-		/// Convert
-		static float toRad(const float degrees);
+	/// Convert
+	static float toRad(const float degrees);
 
-		/// Convert
-		static float toDegrees(const float rad);
+	/// Convert
+	static float toDegrees(const float rad);
 
-		/// Optimized sine
-		static float sin(const float rad);
+	/// Optimized sine
+	static float sin(const float rad);
 
-		/// Optimized cosine
-		static float cos(const float rad);
+	/// Optimized cosine
+	static float cos(const float rad);
 
-		/// The proper way to test if a float is zero
-		static bool isZero(const float f);
+	/// The proper way to test if a float is zero
+	static bool isZero(const float f);
 
-		/// Mat4(t0,r0,s0) * Mat4(t1, r1, s1) == Mat4(tf, rf, sf)
-		static void combineTransformations(
-			const Vec3& t0, const Mat3& r0, const float s0, // in 0
-			const Vec3& t1, const Mat3& r1, const float s1, // in 1
-			Vec3& tf, Mat3& rf, float& sf); // out
+	/// Mat4(t0,r0,s0) * Mat4(t1, r1, s1) == Mat4(tf, rf, sf)
+	static void combineTransformations(
+		const Vec3& t0, const Mat3& r0, const float s0, // in 0
+		const Vec3& t1, const Mat3& r1, const float s1, // in 1
+		Vec3& tf, Mat3& rf, float& 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
+	/// 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 float polynomialSinQuadrant(const float a);
+private:
+	static float polynomialSinQuadrant(const float a);
 };
 /// @}
 

+ 8 - 0
anki/math/Math.inl.h

@@ -4,6 +4,7 @@
 namespace anki {
 
 
+//==============================================================================
 inline float Math::sqrt(const float f)
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
@@ -18,36 +19,42 @@ inline float Math::sqrt(const float f)
 }
 
 
+//==============================================================================
 inline float Math::toRad(const float degrees)
 {
 	return degrees * (Math::PI / 180.0);
 }
 
 
+//==============================================================================
 inline float Math::toDegrees(const float rad)
 {
 	return rad * (180.0 / Math::PI);
 }
 
 
+//==============================================================================
 inline float Math::sin(const float rad)
 {
 	return ::sin(rad);
 }
 
 
+//==============================================================================
 inline float Math::cos(const float rad)
 {
 	return ::cos(rad);
 }
 
 
+//==============================================================================
 inline bool Math::isZero(const float f)
 {
 	return fabs(f) < EPSILON;
 }
 
 
+//==============================================================================
 inline void Math::combineTransformations(
 	const Vec3& t0, const Mat3& r0, const float s0,
 	const Vec3& t1, const Mat3& r1, const float s1,
@@ -59,6 +66,7 @@ inline void Math::combineTransformations(
 }
 
 
+//==============================================================================
 inline void Math::combineTransformations(
 	const Vec3& t0, const Mat3& r0,
 	const Vec3& t1, const Mat3& r1,

+ 71 - 71
anki/math/Quat.h

@@ -13,77 +13,77 @@ namespace anki {
 /// Quaternion. Used in rotations
 class Quat
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Quat();
-		explicit Quat(const float f);
-		explicit Quat(const float x, const float y, const float z,
-			const float w);
-		explicit Quat(const Vec2& v2, const float z, const float w);
-		explicit Quat(const Vec3& v3, const float w);
-		explicit Quat(const Vec4& v4);
-		         Quat(const Quat& b);
-		explicit Quat(const Mat3& m3);
-		explicit Quat(const Euler& eu);
-		explicit Quat(const Axisang& axisang);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float x() const;
-		float& x();
-		float y() const;
-		float& y();
-		float z() const;
-		float& z();
-		float w() const;
-		float& w();
-		/// @}
-
-		/// Operators with same type
-		/// @{
-		Quat& operator=(const Quat& b);
-		Quat operator*(const Quat& b) const; ///< 16 muls, 12 adds
-		Quat& operator*=(const Quat& b);
-		bool operator==(const Quat& b) const;
-		bool operator!=(const Quat& b) const;
-		/// @}
-
-		/// @name Other
-		/// @{
-
-		/// Calculates the rotation from Vec3 v0 to v1
-		void  setFrom2Vec3(const Vec3& v0, const Vec3& v1);
-		float getLength() const;
-		Quat  getInverted() const;
-		void  invert();
-		void  conjugate();
-		Quat  getConjugated() const;
-		void  normalize();
-		Quat  getNormalized() const;
-		float dot(const Quat& b) const;
-		/// Returns slerp(this, q1, t)
-		Quat  slerp(const Quat& q1, const float t) const;
-		Quat  getRotated(const Quat& b) const; ///< The same as Quat * Quat
-		void  rotate(const Quat& b); ///< @see getRotated
-		void  setIdentity();
-		static const Quat& getIdentity();
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend std::ostream& operator<<(std::ostream& s, const Quat& q);
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		struct
-		{
-			float x, y, z, w;
-		} vec;
-		/// @}
+public:
+	/// @name Constructors
+	/// @{
+	explicit Quat();
+	explicit Quat(const float f);
+	explicit Quat(const float x, const float y, const float z,
+		const float w);
+	explicit Quat(const Vec2& v2, const float z, const float w);
+	explicit Quat(const Vec3& v3, const float w);
+	explicit Quat(const Vec4& v4);
+			 Quat(const Quat& b);
+	explicit Quat(const Mat3& m3);
+	explicit Quat(const Euler& eu);
+	explicit Quat(const Axisang& axisang);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float x() const;
+	float& x();
+	float y() const;
+	float& y();
+	float z() const;
+	float& z();
+	float w() const;
+	float& w();
+	/// @}
+
+	/// Operators with same type
+	/// @{
+	Quat& operator=(const Quat& b);
+	Quat operator*(const Quat& b) const; ///< 16 muls, 12 adds
+	Quat& operator*=(const Quat& b);
+	bool operator==(const Quat& b) const;
+	bool operator!=(const Quat& b) const;
+	/// @}
+
+	/// @name Other
+	/// @{
+
+	/// Calculates the rotation from Vec3 v0 to v1
+	void setFrom2Vec3(const Vec3& v0, const Vec3& v1);
+	float getLength() const;
+	Quat getInverted() const;
+	void invert();
+	void conjugate();
+	Quat getConjugated() const;
+	void normalize();
+	Quat getNormalized() const;
+	float dot(const Quat& b) const;
+	/// Returns slerp(this, q1, t)
+	Quat slerp(const Quat& q1, const float t) const;
+	Quat getRotated(const Quat& b) const; ///< The same as Quat * Quat
+	void rotate(const Quat& b); ///< @see getRotated
+	void setIdentity();
+	static const Quat& getIdentity();
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend std::ostream& operator<<(std::ostream& s, const Quat& q);
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	struct
+	{
+		float x, y, z, w;
+	} vec;
+	/// @}
 };
 /// @}
 

+ 45 - 45
anki/math/Transform.h

@@ -15,51 +15,51 @@ namespace anki {
 /// Transformation
 class Transform
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Transform();
-		         Transform(const Transform& b);
-		explicit Transform(const Mat4& m4);
-		explicit Transform(const Vec3& origin, const Mat3& rotation_,
-			const float scale_);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getOrigin() const;
-		Vec3& getOrigin();
-		void setOrigin(const Vec3 o);
-		
-		const Mat3& getRotation() const;
-		Mat3& getRotation();
-		void setRotation(const Mat3& r);
-		
-		float getScale() const;
-		float& getScale();
-		void setScale(const float s);
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		Transform& operator=(const Transform& b);
-		/// @}
-
-		/// @name Other
-		/// @{
-		void setIdentity();
-		static const Transform& getIdentity();
-		static Transform combineTransformations(const Transform& a,
-			const Transform& b); ///< @copybrief Math::combineTransformations
-		/// @}
-		
-	private:
-		/// @name Data
-		/// @{
-		Vec3 origin; ///< The rotation
-		Mat3 rotation; ///< The translation
-		float scale; ///< The uniform scaling
-		/// @}
+public:
+	/// @name Constructors
+	/// @{
+	explicit Transform();
+			 Transform(const Transform& b);
+	explicit Transform(const Mat4& m4);
+	explicit Transform(const Vec3& origin, const Mat3& rotation,
+		const float scale);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getOrigin() const;
+	Vec3& getOrigin();
+	void setOrigin(const Vec3 o);
+
+	const Mat3& getRotation() const;
+	Mat3& getRotation();
+	void setRotation(const Mat3& r);
+
+	float getScale() const;
+	float& getScale();
+	void setScale(const float s);
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	Transform& operator=(const Transform& b);
+	/// @}
+
+	/// @name Other
+	/// @{
+	void setIdentity();
+	static const Transform& getIdentity();
+	static Transform combineTransformations(const Transform& a,
+		const Transform& b); ///< @copybrief Math::combineTransformations
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	Vec3 origin; ///< The rotation
+	Mat3 rotation; ///< The translation
+	float scale; ///< The uniform scaling
+	/// @}
 };
 /// @}
 

+ 2 - 6
anki/math/Transform.inl.h

@@ -15,9 +15,7 @@ inline Transform::Transform()
 
 // Copy
 inline Transform::Transform(const Transform& b)
-:	origin(b.origin),
-	rotation(b.rotation),
-	scale(b.scale)
+	: origin(b.origin), rotation(b.rotation), scale(b.scale)
 {}
 
 
@@ -33,9 +31,7 @@ inline Transform::Transform(const Mat4& m4)
 // Vec3, Quat, float
 inline Transform::Transform(const Vec3& origin, const Mat3& rotation_,
 	const float scale_)
-:	origin(origin),
-	rotation(rotation_),
-	scale(scale_)
+	: origin(origin), rotation(rotation_), scale(scale_)
 {}
 
 

+ 82 - 82
anki/math/Vec2.h

@@ -13,89 +13,89 @@ namespace anki {
 /// 2D vector
 class Vec2
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Vec2();
-		explicit Vec2(const float x, const float y);
-		explicit Vec2(const float f);
-		explicit Vec2(const float arr[]);
-		         Vec2(const Vec2& b);
-		explicit Vec2(const Vec3& v3);
-		explicit Vec2(const Vec4& v4);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float& x();
-		float x() const;
-		float& y();
-		float y() const;
-		float& operator[](const size_t i);
-		float operator[](const size_t i) const;
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		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 Vec2& b) const;
-		Vec2& operator/=(const Vec2& b);
-		Vec2 operator-() const;
-		bool operator==(const Vec2& b) const;
-		bool operator!=(const Vec2& b) const;
-		bool operator<(const Vec2& b) const;
-		bool operator<=(const Vec2& b) const;
-		bool operator>(const Vec2& b) const;
-		bool operator>=(const Vec2& b) const;
-		/// @}
-
-		/// @name Operators with float
-		/// @{
-		Vec2 operator+(const float f) const;
-		Vec2& operator+=(const float f);
-		Vec2 operator-(const float f) const;
-		Vec2& operator-=(const float f);
-		Vec2 operator*(const float f) const;
-		Vec2& operator*=(const float f);
-		Vec2 operator/(const float f) const;
-		Vec2& operator/=(const float f);
-		/// @}
-
-		/// @name Other
-		/// @{
-		float getLength() const;
-		Vec2 getNormalized() const;
-		void normalize();
-		float dot(const Vec2& b) const;
-		/// @}
-
-		/// @name Friends
-		friend Vec2 operator+(const float f, const Vec2& v2);
-		friend Vec2 operator-(const float f, const Vec2& v2);
-		friend Vec2 operator*(const float f, const Vec2& v2);
-		friend Vec2 operator/(const float f, const Vec2& v2);
-		friend std::ostream& operator<<(std::ostream& s, const Vec2& v);
-		///@]
-
-	private:
-		/// @name Data members
-		/// @{
-		union
+public:
+	/// @name Constructors
+	/// @{
+	explicit Vec2();
+	explicit Vec2(const float x, const float y);
+	explicit Vec2(const float f);
+	explicit Vec2(const float arr[]);
+			 Vec2(const Vec2& b);
+	explicit Vec2(const Vec3& v3);
+	explicit Vec2(const Vec4& v4);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float& x();
+	float x() const;
+	float& y();
+	float y() const;
+	float& operator[](const size_t i);
+	float operator[](const size_t i) const;
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	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 Vec2& b) const;
+	Vec2& operator/=(const Vec2& b);
+	Vec2 operator-() const;
+	bool operator==(const Vec2& b) const;
+	bool operator!=(const Vec2& b) const;
+	bool operator<(const Vec2& b) const;
+	bool operator<=(const Vec2& b) const;
+	bool operator>(const Vec2& b) const;
+	bool operator>=(const Vec2& b) const;
+	/// @}
+
+	/// @name Operators with float
+	/// @{
+	Vec2 operator+(const float f) const;
+	Vec2& operator+=(const float f);
+	Vec2 operator-(const float f) const;
+	Vec2& operator-=(const float f);
+	Vec2 operator*(const float f) const;
+	Vec2& operator*=(const float f);
+	Vec2 operator/(const float f) const;
+	Vec2& operator/=(const float f);
+	/// @}
+
+	/// @name Other
+	/// @{
+	float getLength() const;
+	Vec2 getNormalized() const;
+	void normalize();
+	float dot(const Vec2& b) const;
+	/// @}
+
+	/// @name Friends
+	friend Vec2 operator+(const float f, const Vec2& v2);
+	friend Vec2 operator-(const float f, const Vec2& v2);
+	friend Vec2 operator*(const float f, const Vec2& v2);
+	friend Vec2 operator/(const float f, const Vec2& v2);
+	friend std::ostream& operator<<(std::ostream& s, const Vec2& v);
+	///@]
+
+private:
+	/// @name Data members
+	/// @{
+	union
+	{
+		struct
 		{
-			struct
-			{
-				float x, y;
-			} vec;
-
-			boost::array<float, 2> arr;
-		};
-		/// @}
+			float x, y;
+		} vec;
+
+		boost::array<float, 2> arr;
+	};
+	/// @}
 };
 /// @}
 

+ 120 - 120
anki/math/Vec3.h

@@ -13,127 +13,127 @@ namespace anki {
 /// 3D vector. One of the most used classes
 class Vec3
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Vec3();
-		explicit Vec3(const float x, const float y, const float z);
-		explicit Vec3(const float f);
-		explicit Vec3(const float arr[]);
-		explicit Vec3(const Vec2& v2, const float z);
-		         Vec3(const Vec3& b);
-		explicit Vec3(const Vec4& v4);
-		explicit Vec3(const Quat& q);
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float& x();
-		float x() const;
-		float& y();
-		float y() const;
-		float& z();
-		float z() const;
-		float& operator[](const size_t i);
-		float operator[](const size_t i) const;
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		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 Vec3& b) const;
-		Vec3& operator/=(const Vec3& b);
-		Vec3 operator-() const;
-		bool operator==(const Vec3& b) const;
-		bool operator!=(const Vec3& b) const;
-		bool operator<(const Vec3& b) const;
-		bool operator<=(const Vec3& b) const;
-		bool operator>(const Vec3& b) const;
-		bool operator>=(const Vec3& b) const;
-		/// @}
-
-		/// @name Operators with float
-		/// @{
-		Vec3 operator+(const float f) const;
-		Vec3& operator+=(const float f);
-		Vec3 operator-(const float f) const;
-		Vec3& operator-=(const float f);
-		Vec3 operator*(const float f) const;
-		Vec3& operator*=(const float f);
-		Vec3 operator/(const float f) const;
-		Vec3& operator/=(const float f);
-		/// @}
-
-		/// @name Operators with other types
-		/// @{
-		Vec3 operator*(const Mat3& m3) const;
-		/// @}
-
-		/// @name Other
-		/// @{
-		float dot(const Vec3& b) const;
-		Vec3 cross(const Vec3& b) const;
-		float getLength() const;
-		float getLengthSquared() const;
-		float getDistanceSquared(const Vec3& b) const;
-		void normalize();
-		Vec3 getNormalized() const;
-		Vec3 getProjection(const Vec3& toThis) const;
-		/// Returns q * this * q.Conjucated() aka returns a rotated this.
-		/// 18 muls, 12 adds
-		Vec3 getRotated(const Quat& q) const;
-		void rotate(const Quat& q);
-		Vec3 lerp(const Vec3& v1, float t) const; ///< Return lerp(this, v1, t)
-		/// @}
-
-		/// @name Transformations
-		/// The faster way is by far the Mat4 * Vec3 or the
-		/// getTransformed(const Vec3&, const Mat3&)
-		/// @{
-		Vec3 getTransformed(const Vec3& translate, const Mat3& rotate,
-			float scale) const;
-		void transform(const Vec3& translate, const Mat3& rotate, float scale);
-		Vec3 getTransformed(const Vec3& translate, const Mat3& rotate) const;
-		void transform(const Vec3& translate, const Mat3& rotate);
-		Vec3 getTransformed(const Vec3& translate, const Quat& rotate,
-			float scale) const;
-		void transform(const Vec3& translate, const Quat& rotate, float scale);
-		Vec3 getTransformed(const Vec3& translate, const Quat& rotate) const;
-		void transform(const Vec3& translate, const Quat& rotate);
-		Vec3 getTransformed(const Mat4& transform) const;  ///< 9 muls, 9 adds
-		void transform(const Mat4& transform);
-		Vec3 getTransformed(const Transform& transform) const;
-		void transform(const Transform& transform);
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend Vec3 operator+(const float f, const Vec3& v);
-		friend Vec3 operator-(const float f, const Vec3& v);
-		friend Vec3 operator*(const float f, const Vec3& v);
-		friend Vec3 operator/(const float f, const Vec3& v);
-		friend std::ostream& operator<<(std::ostream& s, const Vec3& v);
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		union
+public:
+	/// @name Constructors
+	/// @{
+	explicit Vec3();
+	explicit Vec3(const float x, const float y, const float z);
+	explicit Vec3(const float f);
+	explicit Vec3(const float arr[]);
+	explicit Vec3(const Vec2& v2, const float z);
+			 Vec3(const Vec3& b);
+	explicit Vec3(const Vec4& v4);
+	explicit Vec3(const Quat& q);
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float& x();
+	float x() const;
+	float& y();
+	float y() const;
+	float& z();
+	float z() const;
+	float& operator[](const size_t i);
+	float operator[](const size_t i) const;
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	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 Vec3& b) const;
+	Vec3& operator/=(const Vec3& b);
+	Vec3 operator-() const;
+	bool operator==(const Vec3& b) const;
+	bool operator!=(const Vec3& b) const;
+	bool operator<(const Vec3& b) const;
+	bool operator<=(const Vec3& b) const;
+	bool operator>(const Vec3& b) const;
+	bool operator>=(const Vec3& b) const;
+	/// @}
+
+	/// @name Operators with float
+	/// @{
+	Vec3 operator+(const float f) const;
+	Vec3& operator+=(const float f);
+	Vec3 operator-(const float f) const;
+	Vec3& operator-=(const float f);
+	Vec3 operator*(const float f) const;
+	Vec3& operator*=(const float f);
+	Vec3 operator/(const float f) const;
+	Vec3& operator/=(const float f);
+	/// @}
+
+	/// @name Operators with other types
+	/// @{
+	Vec3 operator*(const Mat3& m3) const;
+	/// @}
+
+	/// @name Other
+	/// @{
+	float dot(const Vec3& b) const;
+	Vec3 cross(const Vec3& b) const;
+	float getLength() const;
+	float getLengthSquared() const;
+	float getDistanceSquared(const Vec3& b) const;
+	void normalize();
+	Vec3 getNormalized() const;
+	Vec3 getProjection(const Vec3& toThis) const;
+	/// Returns q * this * q.Conjucated() aka returns a rotated this.
+	/// 18 muls, 12 adds
+	Vec3 getRotated(const Quat& q) const;
+	void rotate(const Quat& q);
+	Vec3 lerp(const Vec3& v1, float t) const; ///< Return lerp(this, v1, t)
+	/// @}
+
+	/// @name Transformations
+	/// The faster way is by far the Mat4 * Vec3 or the
+	/// getTransformed(const Vec3&, const Mat3&)
+	/// @{
+	Vec3 getTransformed(const Vec3& translate, const Mat3& rotate,
+		float scale) const;
+	void transform(const Vec3& translate, const Mat3& rotate, float scale);
+	Vec3 getTransformed(const Vec3& translate, const Mat3& rotate) const;
+	void transform(const Vec3& translate, const Mat3& rotate);
+	Vec3 getTransformed(const Vec3& translate, const Quat& rotate,
+		float scale) const;
+	void transform(const Vec3& translate, const Quat& rotate, float scale);
+	Vec3 getTransformed(const Vec3& translate, const Quat& rotate) const;
+	void transform(const Vec3& translate, const Quat& rotate);
+	Vec3 getTransformed(const Mat4& transform) const;  ///< 9 muls, 9 adds
+	void transform(const Mat4& transform);
+	Vec3 getTransformed(const Transform& transform) const;
+	void transform(const Transform& transform);
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend Vec3 operator+(const float f, const Vec3& v);
+	friend Vec3 operator-(const float f, const Vec3& v);
+	friend Vec3 operator*(const float f, const Vec3& v);
+	friend Vec3 operator/(const float f, const Vec3& v);
+	friend std::ostream& operator<<(std::ostream& s, const Vec3& v);
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	union
+	{
+		struct
 		{
-			struct
-			{
-				float x, y, z;
-			} vec;
-
-			boost::array<float, 3> arr;
-		};
-		/// @}
+			float x, y, z;
+		} vec;
+
+		boost::array<float, 3> arr;
+	};
+	/// @}
 };
 /// @}
 

+ 1 - 1
anki/math/Vec3.inl.h

@@ -515,7 +515,7 @@ inline void Vec3::transform(const Transform& transform)
 }
 
 //==============================================================================
-// Globals                                                                     =
+// Friends                                                                     =
 //==============================================================================
 
 // float + Vec3

+ 97 - 97
anki/math/Vec4.h

@@ -13,112 +13,112 @@ namespace anki {
 /// 4D vector. SSE optimized
 class Vec4
 {
-	public:
-		/// @name Constructors
-		/// @{
-		explicit Vec4();
-		explicit Vec4(const float x, const float y, const float z,
-			const float w);
-		explicit Vec4(const float f);
-		explicit Vec4(const float arr[]);
-		explicit Vec4(const Vec2& v2, const float z, const float w);
-		explicit Vec4(const Vec3& v3, const float w);
-		         Vec4(const Vec4& b);
-		explicit Vec4(const Quat& q);
+public:
+	/// @name Constructors
+	/// @{
+	explicit Vec4();
+	explicit Vec4(const float x, const float y, const float z,
+		const float w);
+	explicit Vec4(const float f);
+	explicit Vec4(const float arr[]);
+	explicit Vec4(const Vec2& v2, const float z, const float w);
+	explicit Vec4(const Vec3& v3, const float w);
+			 Vec4(const Vec4& b);
+	explicit Vec4(const Quat& q);
 #if defined(ANKI_MATH_INTEL_SIMD)
-		explicit Vec4(const __m128& mm);
+	explicit Vec4(const __m128& mm);
 #endif
-		/// @}
-
-		/// @name Accessors
-		/// @{
-		float& x();
-		float x() const;
-		float& y();
-		float y() const;
-		float& z();
-		float z() const;
-		float& w();
-		float w() const;
-		float& operator[](const size_t i);
-		float operator[](const size_t i) const;
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float& x();
+	float x() const;
+	float& y();
+	float y() const;
+	float& z();
+	float z() const;
+	float& w();
+	float w() const;
+	float& operator[](const size_t i);
+	float operator[](const size_t i) const;
 #if defined(ANKI_MATH_INTEL_SIMD)
-		__m128& getMm();
-		const __m128& getMm() const;
+	__m128& getMm();
+	const __m128& getMm() const;
 #endif
-		/// @}
-
-		/// @name Operators with same type
-		/// @{
-		Vec4& operator=(const Vec4& b);
-		Vec4 operator+(const Vec4& b) const;
-		Vec4& operator+=(const Vec4& b);
-		Vec4 operator-(const Vec4& b) const;
-		Vec4& operator-=(const Vec4& b);
-		Vec4 operator*(const Vec4& b) const;
-		Vec4& operator*=(const Vec4& b);
-		Vec4 operator/(const Vec4& b) const;
-		Vec4& operator/=(const Vec4& b);
-		Vec4 operator-() const;
-		bool operator==(const Vec4& b) const;
-		bool operator!=(const Vec4& b) const;
-		bool operator<(const Vec4& b) const;
-		bool operator<=(const Vec4& b) const;
-		bool operator>(const Vec4& b) const;
-		bool operator>=(const Vec4& b) const;
-		/// @}
-
-		/// @name Operators with float
-		/// @{
-		Vec4 operator+(const float f) const;
-		Vec4& operator+=(const float f);
-		Vec4 operator-(const float f) const;
-		Vec4& operator-=(const float f);
-		Vec4 operator*(const float f) const;
-		Vec4& operator*=(const float f);
-		Vec4 operator/(const float f) const;
-		Vec4& operator/=(const float f);
-		/// @}
-
-		/// @name Operators with other
-		/// @{
-		Vec4 operator*(const Mat4& m4) const;
-		/// @}
-
-		/// @name Other
-		/// @{
-		float getLength() const;
-		Vec4 getNormalized() const;
-		void normalize();
-		float dot(const Vec4& b) const;
-		/// @}
-
-		/// @name Friends
-		/// @{
-		friend Vec4 operator+(const float f, const Vec4& v4);
-		friend Vec4 operator-(const float f, const Vec4& v4);
-		friend Vec4 operator*(const float f, const Vec4& v4);
-		friend Vec4 operator/(const float f, const Vec4& v4);
-		friend std::ostream& operator<<(std::ostream& s, const Vec4& v);
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		union
+	/// @}
+
+	/// @name Operators with same type
+	/// @{
+	Vec4& operator=(const Vec4& b);
+	Vec4 operator+(const Vec4& b) const;
+	Vec4& operator+=(const Vec4& b);
+	Vec4 operator-(const Vec4& b) const;
+	Vec4& operator-=(const Vec4& b);
+	Vec4 operator*(const Vec4& b) const;
+	Vec4& operator*=(const Vec4& b);
+	Vec4 operator/(const Vec4& b) const;
+	Vec4& operator/=(const Vec4& b);
+	Vec4 operator-() const;
+	bool operator==(const Vec4& b) const;
+	bool operator!=(const Vec4& b) const;
+	bool operator<(const Vec4& b) const;
+	bool operator<=(const Vec4& b) const;
+	bool operator>(const Vec4& b) const;
+	bool operator>=(const Vec4& b) const;
+	/// @}
+
+	/// @name Operators with float
+	/// @{
+	Vec4 operator+(const float f) const;
+	Vec4& operator+=(const float f);
+	Vec4 operator-(const float f) const;
+	Vec4& operator-=(const float f);
+	Vec4 operator*(const float f) const;
+	Vec4& operator*=(const float f);
+	Vec4 operator/(const float f) const;
+	Vec4& operator/=(const float f);
+	/// @}
+
+	/// @name Operators with other
+	/// @{
+	Vec4 operator*(const Mat4& m4) const;
+	/// @}
+
+	/// @name Other
+	/// @{
+	float getLength() const;
+	Vec4 getNormalized() const;
+	void normalize();
+	float dot(const Vec4& b) const;
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend Vec4 operator+(const float f, const Vec4& v4);
+	friend Vec4 operator-(const float f, const Vec4& v4);
+	friend Vec4 operator*(const float f, const Vec4& v4);
+	friend Vec4 operator/(const float f, const Vec4& v4);
+	friend std::ostream& operator<<(std::ostream& s, const Vec4& v);
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	union
+	{
+		struct
 		{
-			struct
-			{
-				float x, y, z, w;
-			} vec;
+			float x, y, z, w;
+		} vec;
 
-			boost::array<float, 4> arr;
+		boost::array<float, 4> arr;
 
 #if defined(ANKI_MATH_INTEL_SIMD)
-			__m128 mm;
+		__m128 mm;
 #endif
-		};
-		/// @}
+	};
+	/// @}
 };
 /// @}
 

+ 51 - 51
anki/resource/AsyncOperator.h

@@ -20,63 +20,63 @@ namespace anki {
 /// deadlock.
 class AsyncOperator
 {
+public:
+	/// XXX
+	class Request
+	{
 	public:
-		/// XXX
-		class Request
-		{
-			public:
-				bool ok;
+		bool ok;
 
-				/// Called in the worker thread
-				virtual void exec() = 0;
+		/// Called in the worker thread
+		virtual void exec() = 0;
 
-				/// Called in the main thread after the request is served
-				virtual void postExec(AsyncOperator& al) = 0;
+		/// Called in the main thread after the request is served
+		virtual void postExec(AsyncOperator& al) = 0;
 
-				/// XXX
-				virtual std::string getInfo() const
-				{
-					return "no info";
-				}
-		};
-
-		/// Default constructor starts the thread
-		AsyncOperator()
+		/// XXX
+		virtual std::string getInfo() const
 		{
-			start();
+			return "no info";
 		}
-		
-		/// Do nothing
-		~AsyncOperator()
-		{}
-
-		/// Add a new request in the queue
-		void putBack(Request* newReq);
-
-		/// Handle the served requests
-		///
-		/// Steps:
-		/// - Gets the served requests
-		/// - Executes the Request::postExec for those requests
-		/// - Deletes them
-		///
-		/// @param[in] availableTime Max time to spend in the Request::postExec
-		/// @return The number of requests served
-		uint execPostLoad(float availableTime);
-
-	private:
-		std::list<Request*> requests;
-		std::list<Request*> responses;
-		boost::mutex mutexReq; ///< Protect the requests container
-		boost::mutex mutexRes; ///< Protect the responses container
-		boost::thread thread;
-		boost::condition_variable condVar;
-
-		/// The thread function. It waits for something in the requests
-		/// container
-		void workingFunc();
-
-		void start(); ///< Start thread
+	};
+
+	/// Default constructor starts the thread
+	AsyncOperator()
+	{
+		start();
+	}
+
+	/// Do nothing
+	~AsyncOperator()
+	{}
+
+	/// Add a new request in the queue
+	void putBack(Request* newReq);
+
+	/// Handle the served requests
+	///
+	/// Steps:
+	/// - Gets the served requests
+	/// - Executes the Request::postExec for those requests
+	/// - Deletes them
+	///
+	/// @param[in] availableTime Max time to spend in the Request::postExec
+	/// @return The number of requests served
+	uint execPostLoad(float availableTime);
+
+private:
+	std::list<Request*> requests;
+	std::list<Request*> responses;
+	boost::mutex mutexReq; ///< Protect the requests container
+	boost::mutex mutexRes; ///< Protect the responses container
+	boost::thread thread;
+	boost::condition_variable condVar;
+
+	/// The thread function. It waits for something in the requests
+	/// container
+	void workingFunc();
+
+	void start(); ///< Start thread
 };
 
 

+ 21 - 21
anki/resource/AsyncTextureResourceManager.h

@@ -18,33 +18,33 @@ class Texture;
 /// XXX
 class AsyncTextureResourceManager: public ResourceManager<Texture>
 {
-	public:
+public:
 
-	private:
-		/// XXX
-		class Request: public AsyncOperator::Request
-		{
-			public:
-				std::string filename;
-				Image img;
-				Texture** ppTex;
+private:
+	/// XXX
+	class Request: public AsyncOperator::Request
+	{
+		public:
+			std::string filename;
+			Image img;
+			Texture** ppTex;
 
-				Request(const char* fname, Texture**& ppTex_)
-				:	filename(fname),
-				 	ppTex(ppTex_)
-				{}
+			Request(const char* fname, Texture**& ppTex_)
+			:	filename(fname),
+				ppTex(ppTex_)
+			{}
 
-				/// Implements AsyncOperator::Request::exec
-				void exec();
+			/// Implements AsyncOperator::Request::exec
+			void exec();
 
-				/// Implements AsyncOperator::Request::postExec
-				void postExec(AsyncOperator& al);
+			/// Implements AsyncOperator::Request::postExec
+			void postExec(AsyncOperator& al);
 
-				/// Re-implements AsyncOperator::Request::getInfo
-				std::string getInfo() const;
-		};
+			/// Re-implements AsyncOperator::Request::getInfo
+			std::string getInfo() const;
+	};
 
-		boost::scoped_ptr<AsyncOperator> ao;
+	boost::scoped_ptr<AsyncOperator> ao;
 
 };
 /// @}

+ 23 - 30
anki/resource/DummyRsrc.h

@@ -8,44 +8,37 @@ namespace anki {
 /// A dummy resource for the unit tests of the ResourceManager
 class DummyRsrc
 {
-	public:
-		DummyRsrc();
-		~DummyRsrc();
-
-		void load(const char* filename);
+public:
+	DummyRsrc()
+	{
+		++mem;
+		loaded = false;
+	}
 
-		static int getMem()
+	~DummyRsrc()
+	{
+		--mem;
+		if(loaded)
 		{
-			return mem;
+			--mem;
 		}
-	private:
-		static int mem;
-		bool loaded;
-};
-
-
-inline DummyRsrc::DummyRsrc()
-{
-	++mem;
-	loaded = false;
-}
-
+	}
 
-inline DummyRsrc::~DummyRsrc()
-{
-	--mem;
-	if(loaded)
+	void load(const char* filename)
 	{
-		--mem;
+		++mem;
+		loaded = true;
 	}
-}
 
+	static int getMem()
+	{
+		return mem;
+	}
 
-inline void DummyRsrc::load(const char* /*filename*/)
-{
-	++mem;
-	loaded = true;
-}
+private:
+	static int mem;
+	bool loaded;
+};
 
 
 } // end namespace

+ 13 - 14
anki/resource/Extension.h

@@ -10,23 +10,22 @@ namespace anki {
 /// Extension @ref Resource resource
 class Extension
 {
-	private:
-		void* libHandle;
-		int(*foobarPtr)(void*);
-	
-	public:
-		Extension();
-		~Extension();
-		void load(const char* filename);
-		/*template<typename Type>
-		int FooBar(Type* ptr) { DEBUG_ERR(foobarPtr==NULL);
-			return (*foobarPtr)(reinterpret_cast<Type*>(ptr)); }*/
+private:
+	void* libHandle;
+	int(*foobarPtr)(void*);
+
+public:
+	Extension();
+	~Extension();
+	void load(const char* filename);
+	/*template<typename Type>
+	int FooBar(Type* ptr) { DEBUG_ERR(foobarPtr==NULL);
+		return (*foobarPtr)(reinterpret_cast<Type*>(ptr)); }*/
 };
 
 
-inline Extension::Extension():
-	libHandle(NULL),
-	foobarPtr(NULL)
+inline Extension::Extension()
+	: libHandle(NULL), foobarPtr(NULL)
 {}
 
 

+ 14 - 20
anki/resource/Image.cpp

@@ -11,11 +11,9 @@ namespace anki {
 
 
 uchar Image::tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-uchar Image::tgaHeaderCompressed[12]   = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+uchar Image::tgaHeaderCompressed[12] = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 
-//==============================================================================
-// loadUncompressedTga                                                         =
 //==============================================================================
 void Image::loadUncompressedTga(std::fstream& fs, uint& bpp)
 {
@@ -57,8 +55,6 @@ void Image::loadUncompressedTga(std::fstream& fs, uint& bpp)
 }
 
 
-//==============================================================================
-// loadCompressedTga                                                           =
 //==============================================================================
 void Image::loadCompressedTga(std::fstream& fs, uint& bpp)
 {
@@ -160,8 +156,6 @@ void Image::loadCompressedTga(std::fstream& fs, uint& bpp)
 }
 
 
-//==============================================================================
-// loadTga                                                                     =
 //==============================================================================
 void Image::loadTga(const char* filename)
 {
@@ -214,8 +208,6 @@ void Image::loadTga(const char* filename)
 }
 
 
-//==============================================================================
-// loadPng                                                                     =
 //==============================================================================
 bool Image::loadPng(const char* filename, std::string& err) throw()
 {
@@ -429,8 +421,6 @@ bool Image::loadPng(const char* filename, std::string& err) throw()
 }
 
 
-//==============================================================================
-// load                                                                        =
 //==============================================================================
 void Image::load(const char* filename)
 {
@@ -474,7 +464,6 @@ void Image::load(const char* filename)
 // DDS                                                                         =
 //==============================================================================
 
-/*
 //  little-endian, of course
 #define DDS_MAGIC 0x20534444
 
@@ -509,11 +498,16 @@ void Image::load(const char* filename)
 #define DDSCAPS2_CUBEMAP_NEGATIVEZ  0x00008000
 #define DDSCAPS2_VOLUME             0x00200000
 
-#define D3DFMT_DXT1     '1TXD'    //  DXT1 compression texture format
-#define D3DFMT_DXT2     '2TXD'    //  DXT2 compression texture format
-#define D3DFMT_DXT3     '3TXD'    //  DXT3 compression texture format
-#define D3DFMT_DXT4     '4TXD'    //  DXT4 compression texture format
-#define D3DFMT_DXT5     '5TXD'    //  DXT5 compression texture format
+static int toInt(const char* x)
+{
+	return x[3] | (x[2] << 8) | (x[1] << 16) | (x[0] << 24);
+}
+
+#define D3DFMT_DXT1 toInt("1TXD") //  DXT1 compression texture format
+#define D3DFMT_DXT2 toInt("2TXD") //  DXT2 compression texture format
+#define D3DFMT_DXT3 toInt("3TXD") //  DXT3 compression texture format
+#define D3DFMT_DXT4 toInt("4TXD") //  DXT4 compression texture format
+#define D3DFMT_DXT5 toInt("5TXD") //  DXT5 compression texture format
 
 #define PF_IS_DXT1(pf) \
   ((pf.dwFlags & DDPF_FOURCC) && \
@@ -622,11 +616,11 @@ DdsLoadInfo loadInfoBGRA8 = {false, false, false, 1, 4};
 DdsLoadInfo loadInfoBGR8 = {false, false, false, 1, 3};
 DdsLoadInfo loadInfoBGR5A1 = {false, true, false, 1, 2};
 DdsLoadInfo loadInfoBGR565 = {false, true, false, 1, 2};
-DdsLoadInfo loadInfoIndex8 = {false, false, true, 1, 1};*/
+DdsLoadInfo loadInfoIndex8 = {false, false, true, 1, 1};
 
 void Image::loadDds(const char* filename)
 {
-	/*std::fstream in;
+	std::fstream in;
 	in.open(filename, std::ios::in | std::ios::binary);
 
 	if(!in.is_open())
@@ -700,7 +694,7 @@ void Image::loadDds(const char* filename)
 	width = hdr.data.dwWidth;
 	height = hdr.data.dwHeight;
 
-	in.close();*/
+	in.close();
 }
 
 

+ 112 - 112
anki/resource/Image.h

@@ -13,118 +13,118 @@ namespace anki {
 /// Used in Texture::load. Supported types: TGA and PNG
 class Image
 {
-	public:
-		/// The acceptable color types of AnKi
-		enum ColorType
-		{
-			CT_R, ///< Red only
-			CT_RGB, ///< RGB
-			CT_RGBA ///< RGB plus alpha
-		};
-
-		/// The data compression
-		enum DataCompression
-		{
-			DC_NONE,
-			DC_DXT1,
-			DC_DXT3,
-			DC_DXT5
-		};
-
-		/// Do nothing
-		Image()
-		{}
-
-		/// Load an image
-		/// @param[in] filename The image file to load
-		/// @exception Exception
-		Image(const char* filename)
-		{
-			load(filename);
-		}
-		
-		/// Do nothing
-		~Image()
-		{}
-
-		/// @name Accessors
-		/// @{
-		uint getWidth() const
-		{
-			return width;
-		}
-
-		uint getHeight() const
-		{
-			return height;
-		}
-
-		ColorType getColorType() const
-		{
-			return type;
-		}
-
-		const uchar* getData() const
-		{
-			return &data[0];
-		}
-
-		/// Get image size in bytes
-		size_t getDataSize() const
-		{
-			return Util::getVectorSizeInBytes(data);
-		}
-
-		DataCompression getDataCompression() const
-		{
-			return dataCompression;
-		}
-		/// @}
-		
-		/// Load an image file
-		/// @param[in] filename The file to load
-		/// @exception Exception
-		void load(const char* filename);
-
-	private:
-		uint width; ///< Image width
-		uint height; ///< Image height
-		ColorType type; ///< Image color type
-		std::vector<uchar> data; ///< Image data
-		DataCompression dataCompression;
-
-		/// @name TGA headers
-		/// @{
-		static uchar tgaHeaderUncompressed[12];
-		static uchar tgaHeaderCompressed[12];
-		/// @}
-
-		/// Load a TGA
-		/// @param[in] filename The file to load
-		/// @exception Exception
-		void loadTga(const char* filename);
-
-		/// Used by loadTga
-		/// @param[in] fs The input
-		/// @param[out] bpp Bits per pixel
-		/// @exception Exception
-		void loadUncompressedTga(std::fstream& fs, uint& bpp);
-
-		/// Used by loadTga
-		/// @param[in] fs The input
-		/// @param[out] bpp Bits per pixel
-		/// @exception Exception
-		void loadCompressedTga(std::fstream& fs, uint& bpp);
-
-		/// Load PNG. Dont throw exception because libpng is in C
-		/// @param[in] filename The file to load
-		/// @param[out] err The error message
-		/// @return true on success
-		bool loadPng(const char* filename, std::string& err) throw();
-
-		/// Load a DDS file
-		/// @param[in] filename The file to load
-		void loadDds(const char* filename);
+public:
+	/// The acceptable color types of AnKi
+	enum ColorType
+	{
+		CT_R, ///< Red only
+		CT_RGB, ///< RGB
+		CT_RGBA ///< RGB plus alpha
+	};
+
+	/// The data compression
+	enum DataCompression
+	{
+		DC_NONE,
+		DC_DXT1,
+		DC_DXT3,
+		DC_DXT5
+	};
+
+	/// Do nothing
+	Image()
+	{}
+
+	/// Load an image
+	/// @param[in] filename The image file to load
+	/// @exception Exception
+	Image(const char* filename)
+	{
+		load(filename);
+	}
+
+	/// Do nothing
+	~Image()
+	{}
+
+	/// @name Accessors
+	/// @{
+	uint getWidth() const
+	{
+		return width;
+	}
+
+	uint getHeight() const
+	{
+		return height;
+	}
+
+	ColorType getColorType() const
+	{
+		return type;
+	}
+
+	const uchar* getData() const
+	{
+		return &data[0];
+	}
+
+	/// Get image size in bytes
+	size_t getDataSize() const
+	{
+		return Util::getVectorSizeInBytes(data);
+	}
+
+	DataCompression getDataCompression() const
+	{
+		return dataCompression;
+	}
+	/// @}
+
+	/// Load an image file
+	/// @param[in] filename The file to load
+	/// @exception Exception
+	void load(const char* filename);
+
+private:
+	uint width; ///< Image width
+	uint height; ///< Image height
+	ColorType type; ///< Image color type
+	std::vector<uchar> data; ///< Image data
+	DataCompression dataCompression;
+
+	/// @name TGA headers
+	/// @{
+	static uchar tgaHeaderUncompressed[12];
+	static uchar tgaHeaderCompressed[12];
+	/// @}
+
+	/// Load a TGA
+	/// @param[in] filename The file to load
+	/// @exception Exception
+	void loadTga(const char* filename);
+
+	/// Used by loadTga
+	/// @param[in] fs The input
+	/// @param[out] bpp Bits per pixel
+	/// @exception Exception
+	void loadUncompressedTga(std::fstream& fs, uint& bpp);
+
+	/// Used by loadTga
+	/// @param[in] fs The input
+	/// @param[out] bpp Bits per pixel
+	/// @exception Exception
+	void loadCompressedTga(std::fstream& fs, uint& bpp);
+
+	/// Load PNG. Dont throw exception because libpng is in C
+	/// @param[in] filename The file to load
+	/// @param[out] err The error message
+	/// @return true on success
+	bool loadPng(const char* filename, std::string& err) throw();
+
+	/// Load a DDS file
+	/// @param[in] filename The file to load
+	void loadDds(const char* filename);
 };
 
 

+ 0 - 4
anki/resource/LightRsrc.cpp

@@ -14,8 +14,6 @@
 namespace anki {
 
 
-//==============================================================================
-// Constructor                                                                 =
 //==============================================================================
 LightRsrc::LightRsrc()
 {
@@ -30,8 +28,6 @@ LightRsrc::LightRsrc()
 }
 
 
-//==============================================================================
-// load                                                                        =
 //==============================================================================
 void LightRsrc::load(const char* filename)
 {

+ 79 - 79
anki/resource/LightRsrc.h

@@ -38,85 +38,85 @@ struct LightProps
 /// Light properties Resource
 class LightRsrc: private LightProps
 {
-	public:
-		enum LightType
-		{
-			LT_POINT,
-			LT_SPOT,
-			LT_NUM
-		};
-
-		enum SpotLightCameraType
-		{
-			SLCT_PERSPECTIVE,
-			SLCT_ORTHOGRAPHIC
-		};
-
-		LightRsrc();
-		~LightRsrc()
-		{}
-
-		/// @name Accessors
-		/// @{
-		const Vec3& getDiffuseColor() const
-		{
-			return diffuseCol;
-		}
-
-		const Vec3& getSpecularColor() const
-		{
-			return specularCol;
-		}
-
-		bool getCastShadow() const
-		{
-			return castsShadowFlag;
-		}
-
-		LightType getType() const
-		{
-			return type;
-		}
-
-		float getRadius() const
-		{
-			return radius;
-		}
-
-		float getDistance() const
-		{
-			return distance;
-		}
-
-		float getFovX() const
-		{
-			return fovX;
-		}
-
-		float getFovY() const
-		{
-			return fovY;
-		}
-
-		float getWidth() const
-		{
-			return width;
-		}
-
-		float getHeight() const
-		{
-			return height;
-		}
-
-		const Texture& getTexture() const;
-		/// @}
-
-		void load(const char* filename);
-
-	private:
-		LightType type;
-		SpotLightCameraType spotLightCameraType;
-		TextureResourcePointer texture;
+public:
+	enum LightType
+	{
+		LT_POINT,
+		LT_SPOT,
+		LT_NUM
+	};
+
+	enum SpotLightCameraType
+	{
+		SLCT_PERSPECTIVE,
+		SLCT_ORTHOGRAPHIC
+	};
+
+	LightRsrc();
+	~LightRsrc()
+	{}
+
+	/// @name Accessors
+	/// @{
+	const Vec3& getDiffuseColor() const
+	{
+		return diffuseCol;
+	}
+
+	const Vec3& getSpecularColor() const
+	{
+		return specularCol;
+	}
+
+	bool getCastShadow() const
+	{
+		return castsShadowFlag;
+	}
+
+	LightType getType() const
+	{
+		return type;
+	}
+
+	float getRadius() const
+	{
+		return radius;
+	}
+
+	float getDistance() const
+	{
+		return distance;
+	}
+
+	float getFovX() const
+	{
+		return fovX;
+	}
+
+	float getFovY() const
+	{
+		return fovY;
+	}
+
+	float getWidth() const
+	{
+		return width;
+	}
+
+	float getHeight() const
+	{
+		return height;
+	}
+
+	const Texture& getTexture() const;
+	/// @}
+
+	void load(const char* filename);
+
+private:
+	LightType type;
+	SpotLightCameraType spotLightCameraType;
+	TextureResourcePointer texture;
 };
 
 

+ 26 - 26
anki/resource/MaterialShaderProgramCreator.h

@@ -13,40 +13,40 @@ namespace anki {
 /// and creates the source of a custom program.
 class MaterialShaderProgramCreator
 {
-	public:
-		MaterialShaderProgramCreator(const boost::property_tree::ptree& pt);
-		~MaterialShaderProgramCreator();
+public:
+	MaterialShaderProgramCreator(const boost::property_tree::ptree& pt);
+	~MaterialShaderProgramCreator();
 
-		/// Get the shader program source code. This is the one and only public
-		/// member
-		const std::string& getShaderProgramSource() const
-		{
-			return source;
-		}
+	/// Get the shader program source code. This is the one and only public
+	/// member
+	const std::string& getShaderProgramSource() const
+	{
+		return source;
+	}
 
-	private:
-		/// The lines of the shader program source
-		StringList srcLines;
+private:
+	/// The lines of the shader program source
+	StringList srcLines;
 
-		std::string source; ///< Shader program final source
+	std::string source; ///< Shader program final source
 
-		/// Used for shorting vectors of strings. Used in std::sort
-		static bool compareStrings(const std::string& a, const std::string& b);
+	/// Used for shorting vectors of strings. Used in std::sort
+	static bool compareStrings(const std::string& a, const std::string& b);
 
-		/// Parse what is within the
-		/// @code <shaderProgram></shaderProgram> @endcode
-		void parseShaderProgramTag(const boost::property_tree::ptree& pt);
+	/// Parse what is within the
+	/// @code <shaderProgram></shaderProgram> @endcode
+	void parseShaderProgramTag(const boost::property_tree::ptree& pt);
 
-		/// Parse what is within the
-		/// @code <shader></shader> @endcode
-		void parseShaderTag(const boost::property_tree::ptree& pt);
+	/// Parse what is within the
+	/// @code <shader></shader> @endcode
+	void parseShaderTag(const boost::property_tree::ptree& pt);
 
-		/// Parse what is within the @code <input></input> @endcode
-		void parseInputTag(const boost::property_tree::ptree& pt,
-			std::string& line);
+	/// Parse what is within the @code <input></input> @endcode
+	void parseInputTag(const boost::property_tree::ptree& pt,
+		std::string& line);
 
-		/// Parse what is within the @code <operation></operation> @endcode
-		void parseOperationTag(const boost::property_tree::ptree& pt);
+	/// Parse what is within the @code <operation></operation> @endcode
+	void parseOperationTag(const boost::property_tree::ptree& pt);
 };
 
 

+ 1 - 1
anki/resource/MaterialVariable.cpp

@@ -24,7 +24,7 @@ MaterialVariable::MaterialVariable(
 	const char* shaderProgVarName,
 	const PassLevelToShaderProgramHashMap& sProgs,
 	const std::string& val)
-:	type(T_USER)
+	: type(T_USER)
 {
 	init(shaderProgVarName, sProgs);
 	ANKI_ASSERT(getShaderProgramVariableType() ==

+ 0 - 4
anki/resource/Mesh.cpp

@@ -10,8 +10,6 @@
 namespace anki {
 
 
-//==============================================================================
-// load                                                                        =
 //==============================================================================
 void Mesh::load(const char* filename)
 {
@@ -43,8 +41,6 @@ void Mesh::load(const char* filename)
 }
 
 
-//==============================================================================
-// createVbos                                                                  =
 //==============================================================================
 void Mesh::createVbos(const MeshData& meshData)
 {

+ 170 - 170
anki/resource/Mesh.h

@@ -17,182 +17,182 @@ class MeshData;
 /// XXX
 class MeshBase
 {
-	public:
-		MeshBase()
-		{
-			pVbo = nVbo = tVbo = wVbo = NULL;
-		}
-
-		virtual ~MeshBase()
-		{}
-
-		/// @name Accessors
-		/// @{
-		const Vbo& getPositionsVbo() const
-		{
-			ANKI_ASSERT(pVbo != NULL);
-			return *pVbo;
-		}
-
-		const Vbo& getNormalsVbo() const
-		{
-			ANKI_ASSERT(nVbo != NULL);
-			return *nVbo;
-		}
-
-		const Vbo& getTangentsVbo() const
-		{
-			ANKI_ASSERT(tVbo != NULL);
-			return *tVbo;
-		}
-
-		const Vbo& getTextureCoordsVbo(uint channel) const
-		{
-			ANKI_ASSERT(texVbo[channel] != NULL);
-			return *texVbo[channel];
-		}
-
-		const Vbo& getIndecesVbo(uint lod) const
-		{
-			ANKI_ASSERT(iVbo[lod] != NULL);
-			return *iVbo[lod];
-		}
-
-		const Vbo& getWeightsVbo() const
-		{
-			ANKI_ASSERT(wVbo != NULL);
-			return *wVbo;
-		}
-
-		uint getTextureChannelsNumber() const
-		{
-			return texVbo.size();
-		}
-
-		uint getLodsNumber() const
-		{
-			ANKI_ASSERT(iVbo.size() > 0);
-			return iVbo.size();
-		}
-
-		uint getIndicesNumber(uint lod) const
-		{
-			ANKI_ASSERT(idsNum[lod] != 0);
-			return idsNum[lod];
-		}
-
-		uint getVertexNumber(uint lod) const
-		{
-			ANKI_ASSERT(vertsNum[lod] != 0);
-			return vertsNum[lod];
-		}
-		/// @}
-
-		/// @name Ask for geometry properties
-		/// @{
-		bool hasTexCoords() const
-		{
-			return texVbo.size() > 0;
-		}
-
-		bool hasWeights() const
-		{
-			return wVbo != NULL;
-		}
-		/// @}
-
-	protected:
-		Vbo* pVbo; ///< Mandatory
-		Vbo* nVbo; ///< Mandatory
-		Vbo* tVbo; ///< Mandatory
-		std::vector<Vbo*> texVbo; ///< Optional. Tex coords per channel
-		std::vector<Vbo*> iVbo; ///< Mandatory. Indices VBO per LOD
-		Vbo* wVbo; ///< Optional
-
-		std::vector<uint> idsNum; ///< Indices count per LOD
-		std::vector<uint> vertsNum; ///< Vertex count per LOD
+public:
+	MeshBase()
+	{
+		pVbo = nVbo = tVbo = wVbo = NULL;
+	}
+
+	virtual ~MeshBase()
+	{}
+
+	/// @name Accessors
+	/// @{
+	const Vbo& getPositionsVbo() const
+	{
+		ANKI_ASSERT(pVbo != NULL);
+		return *pVbo;
+	}
+
+	const Vbo& getNormalsVbo() const
+	{
+		ANKI_ASSERT(nVbo != NULL);
+		return *nVbo;
+	}
+
+	const Vbo& getTangentsVbo() const
+	{
+		ANKI_ASSERT(tVbo != NULL);
+		return *tVbo;
+	}
+
+	const Vbo& getTextureCoordsVbo(uint channel) const
+	{
+		ANKI_ASSERT(texVbo[channel] != NULL);
+		return *texVbo[channel];
+	}
+
+	const Vbo& getIndecesVbo(uint lod) const
+	{
+		ANKI_ASSERT(iVbo[lod] != NULL);
+		return *iVbo[lod];
+	}
+
+	const Vbo& getWeightsVbo() const
+	{
+		ANKI_ASSERT(wVbo != NULL);
+		return *wVbo;
+	}
+
+	uint getTextureChannelsNumber() const
+	{
+		return texVbo.size();
+	}
+
+	uint getLodsNumber() const
+	{
+		ANKI_ASSERT(iVbo.size() > 0);
+		return iVbo.size();
+	}
+
+	uint getIndicesNumber(uint lod) const
+	{
+		ANKI_ASSERT(idsNum[lod] != 0);
+		return idsNum[lod];
+	}
+
+	uint getVertexNumber(uint lod) const
+	{
+		ANKI_ASSERT(vertsNum[lod] != 0);
+		return vertsNum[lod];
+	}
+	/// @}
+
+	/// @name Ask for geometry properties
+	/// @{
+	bool hasTexCoords() const
+	{
+		return texVbo.size() > 0;
+	}
+
+	bool hasWeights() const
+	{
+		return wVbo != NULL;
+	}
+	/// @}
+
+protected:
+	Vbo* pVbo; ///< Mandatory
+	Vbo* nVbo; ///< Mandatory
+	Vbo* tVbo; ///< Mandatory
+	std::vector<Vbo*> texVbo; ///< Optional. Tex coords per channel
+	std::vector<Vbo*> iVbo; ///< Mandatory. Indices VBO per LOD
+	Vbo* wVbo; ///< Optional
+
+	std::vector<uint> idsNum; ///< Indices count per LOD
+	std::vector<uint> vertsNum; ///< Vertex count per LOD
 };
 
 
 /// Mesh Resource. It contains the geometry packed in VBOs
 class Mesh
 {
-	public:
-		/// Used in @ref vbos array
-		enum Vbos
-		{
-			VBO_VERT_POSITIONS, ///< VBO never empty
-			VBO_VERT_NORMALS, ///< VBO never empty
-			VBO_VERT_TANGENTS, ///< VBO never empty
-			VBO_TEX_COORDS, ///< VBO may be empty
-			VBO_VERT_INDECES, ///< VBO never empty
-			VBO_VERT_WEIGHTS, ///< VBO may be empty
-			VBOS_NUM
-		};
-
-		typedef boost::array<Vbo, VBOS_NUM> VbosArray;
-
-		/// Default constructor
-		Mesh()
-		{}
-
-		/// Does nothing
-		~Mesh()
-		{}
-
-		/// @name Accessors
-		/// @{
-		const Vbo& getVbo(Vbos id) const
-		{
-			return vbos[id];
-		}
-
-		uint getVertIdsNum() const
-		{
-			return vertIdsNum;
-		}
-
-		const Obb& getVisibilityShape() const
-		{
-			return visibilityShape;
-		}
-
-		uint getVertsNum() const
-		{
-			return vertsNum;
-		}
-		/// @}
-
-		/// Load from a file
-		void load(const char* filename);
-
-		/// @name Ask for geometry properties
-		/// @{
-		bool hasTexCoords() const
-		{
-			return vbos[VBO_TEX_COORDS].isCreated();
-		}
-
-		bool hasVertWeights() const
-		{
-			return vbos[VBO_VERT_WEIGHTS].isCreated();
-		}
-
-		bool hasNormalsAndTangents() const
-		{
-			return vbos[VBO_VERT_NORMALS].isCreated() &&
-				vbos[VBO_VERT_TANGENTS].isCreated();
-		}
-		/// @}
-
-	private:
-		VbosArray vbos; ///< The vertex buffer objects
-		uint vertIdsNum; ///< The number of vertex IDs
-		Obb visibilityShape;
-		uint vertsNum;
-
-		/// Create the VBOs
-		void createVbos(const MeshData& meshData);
+public:
+	/// Used in @ref vbos array
+	enum Vbos
+	{
+		VBO_VERT_POSITIONS, ///< VBO never empty
+		VBO_VERT_NORMALS, ///< VBO never empty
+		VBO_VERT_TANGENTS, ///< VBO never empty
+		VBO_TEX_COORDS, ///< VBO may be empty
+		VBO_VERT_INDECES, ///< VBO never empty
+		VBO_VERT_WEIGHTS, ///< VBO may be empty
+		VBOS_NUM
+	};
+
+	typedef boost::array<Vbo, VBOS_NUM> VbosArray;
+
+	/// Default constructor
+	Mesh()
+	{}
+
+	/// Does nothing
+	~Mesh()
+	{}
+
+	/// @name Accessors
+	/// @{
+	const Vbo& getVbo(Vbos id) const
+	{
+		return vbos[id];
+	}
+
+	uint getVertIdsNum() const
+	{
+		return vertIdsNum;
+	}
+
+	const Obb& getVisibilityShape() const
+	{
+		return visibilityShape;
+	}
+
+	uint getVertsNum() const
+	{
+		return vertsNum;
+	}
+	/// @}
+
+	/// Load from a file
+	void load(const char* filename);
+
+	/// @name Ask for geometry properties
+	/// @{
+	bool hasTexCoords() const
+	{
+		return vbos[VBO_TEX_COORDS].isCreated();
+	}
+
+	bool hasVertWeights() const
+	{
+		return vbos[VBO_VERT_WEIGHTS].isCreated();
+	}
+
+	bool hasNormalsAndTangents() const
+	{
+		return vbos[VBO_VERT_NORMALS].isCreated() &&
+			vbos[VBO_VERT_TANGENTS].isCreated();
+	}
+	/// @}
+
+private:
+	VbosArray vbos; ///< The vertex buffer objects
+	uint vertIdsNum; ///< The number of vertex IDs
+	Obb visibilityShape;
+	uint vertsNum;
+
+	/// Create the VBOs
+	void createVbos(const MeshData& meshData);
 };
 
 

+ 0 - 12
anki/resource/MeshData.cpp

@@ -10,8 +10,6 @@
 namespace anki {
 
 
-//==============================================================================
-// load                                                                        =
 //==============================================================================
 void MeshData::load(const char* filename)
 {
@@ -132,8 +130,6 @@ void MeshData::load(const char* filename)
 }
 
 
-//==============================================================================
-// doPostLoad                                                                  =
 //==============================================================================
 void MeshData::doPostLoad()
 {
@@ -163,8 +159,6 @@ void MeshData::doPostLoad()
 }
 
 
-//==============================================================================
-// createFaceNormals                                                           =
 //==============================================================================
 void MeshData::createVertIndeces()
 {
@@ -178,8 +172,6 @@ void MeshData::createVertIndeces()
 }
 
 
-//==============================================================================
-// createFaceNormals                                                           =
 //==============================================================================
 void MeshData::createFaceNormals()
 {
@@ -201,8 +193,6 @@ void MeshData::createFaceNormals()
 }
 
 
-//==============================================================================
-// createVertNormals                                                           =
 //==============================================================================
 void MeshData::createVertNormals()
 {
@@ -227,8 +217,6 @@ void MeshData::createVertNormals()
 }
 
 
-//==============================================================================
-// createVertTangents                                                          =
 //==============================================================================
 void MeshData::createVertTangents()
 {

+ 96 - 96
anki/resource/MeshData.h

@@ -45,103 +45,103 @@ namespace anki {
 /// @endcode
 class MeshData
 {
+public:
+	/// Vertex weight for skeletal animation
+	class VertexWeight
+	{
 	public:
-		/// Vertex weight for skeletal animation
-		class VertexWeight
-		{
-			public:
-				/// Dont change this or prepare to change the skinning code in
-				/// shader
-				static const uint MAX_BONES_PER_VERT = 4;
-
-				/// @todo change the vals to uint when change drivers
-				float bonesNum;
-				boost::array<float, MAX_BONES_PER_VERT> boneIds;
-				boost::array<float, MAX_BONES_PER_VERT> weights;
-		};
-
-		/// Triangle
-		class Triangle
-		{
-			public:
-				/// An array with the vertex indexes in the mesh class
-				boost::array<uint, 3> vertIds;
-				Vec3 normal;
-		};
-
-		MeshData(const char* filename)
-		{
-			load(filename);
-		}
-		~MeshData()
-		{}
-
-		/// @name Accessors
-		/// @{
-		const std::vector<Vec3>& getVertCoords() const
-		{
-			return vertCoords;
-		}
-
-		const std::vector<Vec3>& getVertNormals() const
-		{
-			return vertNormals;
-		}
-
-		const std::vector<Vec4>& getVertTangents() const
-		{
-			return vertTangents;
-		}
-
-		const std::vector<Vec2>& getTexCoords() const
-		{
-			return texCoords;
-		}
-
-		const std::vector<VertexWeight>& getVertWeights() const
-		{
-			return vertWeights;
-		}
-
-		const std::vector<Triangle>& getTris() const
-		{
-			return tris;
-		}
-
-		const std::vector<ushort>& getVertIndeces() const
-		{
-			return vertIndeces;
-		}
-		/// @}
-
-	private:
-		/// @name Data
-		/// @{
-		std::vector<Vec3> vertCoords; ///< Loaded from file
-		std::vector<Vec3> vertNormals; ///< Generated
-		std::vector<Vec4> vertTangents; ///< Generated
-		/// Optional. One for every vert so we can use vertex arrays & VBOs
-		std::vector<Vec2> texCoords;
-		std::vector<VertexWeight> vertWeights; ///< Optional
-		std::vector<Triangle> tris; ///< Required
-		/// Generated. Used for vertex arrays & VBOs
-		std::vector<ushort> vertIndeces;
-		/// @}
-
-		/// Load the mesh data from a binary file
-		/// @exception Exception
-		void load(const char* filename);
-
-		void createFaceNormals();
-		void createVertNormals();
-		void createAllNormals();
-		void createVertTangents();
-		void createVertIndeces();
-
-		/// This method does some sanity checks and creates normals,
-		/// tangents, VBOs etc
-		/// @exception Exception
-		void doPostLoad();
+		/// Dont change this or prepare to change the skinning code in
+		/// shader
+		static const uint MAX_BONES_PER_VERT = 4;
+
+		/// @todo change the vals to uint when change drivers
+		float bonesNum;
+		boost::array<float, MAX_BONES_PER_VERT> boneIds;
+		boost::array<float, MAX_BONES_PER_VERT> weights;
+	};
+
+	/// Triangle
+	class Triangle
+	{
+		public:
+			/// An array with the vertex indexes in the mesh class
+			boost::array<uint, 3> vertIds;
+			Vec3 normal;
+	};
+
+	MeshData(const char* filename)
+	{
+		load(filename);
+	}
+	~MeshData()
+	{}
+
+	/// @name Accessors
+	/// @{
+	const std::vector<Vec3>& getVertCoords() const
+	{
+		return vertCoords;
+	}
+
+	const std::vector<Vec3>& getVertNormals() const
+	{
+		return vertNormals;
+	}
+
+	const std::vector<Vec4>& getVertTangents() const
+	{
+		return vertTangents;
+	}
+
+	const std::vector<Vec2>& getTexCoords() const
+	{
+		return texCoords;
+	}
+
+	const std::vector<VertexWeight>& getVertWeights() const
+	{
+		return vertWeights;
+	}
+
+	const std::vector<Triangle>& getTris() const
+	{
+		return tris;
+	}
+
+	const std::vector<ushort>& getVertIndeces() const
+	{
+		return vertIndeces;
+	}
+	/// @}
+
+private:
+	/// @name Data
+	/// @{
+	std::vector<Vec3> vertCoords; ///< Loaded from file
+	std::vector<Vec3> vertNormals; ///< Generated
+	std::vector<Vec4> vertTangents; ///< Generated
+	/// Optional. One for every vert so we can use vertex arrays & VBOs
+	std::vector<Vec2> texCoords;
+	std::vector<VertexWeight> vertWeights; ///< Optional
+	std::vector<Triangle> tris; ///< Required
+	/// Generated. Used for vertex arrays & VBOs
+	std::vector<ushort> vertIndeces;
+	/// @}
+
+	/// Load the mesh data from a binary file
+	/// @exception Exception
+	void load(const char* filename);
+
+	void createFaceNormals();
+	void createVertNormals();
+	void createAllNormals();
+	void createVertTangents();
+	void createVertIndeces();
+
+	/// This method does some sanity checks and creates normals,
+	/// tangents, VBOs etc
+	/// @exception Exception
+	void doPostLoad();
 };
 
 

+ 0 - 2
anki/resource/Model.cpp

@@ -15,8 +15,6 @@
 namespace anki {
 
 
-//==============================================================================
-// load                                                                        =
 //==============================================================================
 void Model::load(const char* filename)
 {

+ 18 - 18
anki/resource/Model.h

@@ -34,28 +34,28 @@ namespace anki {
 /// - Its an error to have skelAnims without skeleton
 class Model
 {
-	public:
-		typedef boost::ptr_vector<ModelPatch> ModelPatchesContainer;
+public:
+	typedef boost::ptr_vector<ModelPatch> ModelPatchesContainer;
 
-		void load(const char* filename);
+	void load(const char* filename);
 
-		/// @name Accessors
-		/// @{
-		const ModelPatchesContainer& getModelPatches() const
-		{
-			return modelPatches;
-		}
+	/// @name Accessors
+	/// @{
+	const ModelPatchesContainer& getModelPatches() const
+	{
+		return modelPatches;
+	}
 
-		const Obb& getVisibilityShape() const
-		{
-			return visibilityShape;
-		}
-		/// @}
+	const Obb& getVisibilityShape() const
+	{
+		return visibilityShape;
+	}
+	/// @}
 
-	private:
-		/// The vector of ModelPatch
-		ModelPatchesContainer modelPatches;
-		Obb visibilityShape;
+private:
+	/// The vector of ModelPatch
+	ModelPatchesContainer modelPatches;
+	Obb visibilityShape;
 };
 
 

+ 43 - 43
anki/resource/ModelPatch.h

@@ -18,49 +18,49 @@ class Material;
 /// for a Mesh and it's Material
 class ModelPatch
 {
-	public:
-		typedef boost::ptr_vector<Vao> VaosContainer;
-		typedef PassLevelHashMap<Vao*>::Type PassLevelToVaoHashMap;
-		typedef boost::array<const Vbo*, Mesh::VBOS_NUM> VboArray;
-
-		ModelPatch(const char* meshFName, const char* mtlFName);
-		~ModelPatch();
-
-		/// @name Accessors
-		/// @{
-		const Mesh& getMesh() const
-		{
-			return *mesh;
-		}
-
-		const Material& getMaterial() const
-		{
-			return *mtl;
-		}
-		/// @}
-
-		bool supportsHwSkinning() const;
-
-		const Vao& getVao(const PassLevelKey& key) const
-		{
-			return *vaosHashMap.at(key);
-		}
-
-		static void createVaos(const Material& mtl,
-			const VboArray& vbos,
-			VaosContainer& vaos,
-			PassLevelToVaoHashMap& vaosHashMap);
-
-	private:
-		MeshResourcePointer mesh; ///< The geometry
-		MaterialResourcePointer mtl; ///< Material
-
-		VaosContainer vaos;
-		PassLevelToVaoHashMap vaosHashMap;
-
-		static Vao* createVao(const Material& mtl,
-			const VboArray& vbos,
-			const PassLevelKey& key);
+public:
+	typedef boost::ptr_vector<Vao> VaosContainer;
+	typedef PassLevelHashMap<Vao*>::Type PassLevelToVaoHashMap;
+	typedef boost::array<const Vbo*, Mesh::VBOS_NUM> VboArray;
+
+	ModelPatch(const char* meshFName, const char* mtlFName);
+	~ModelPatch();
+
+	/// @name Accessors
+	/// @{
+	const Mesh& getMesh() const
+	{
+		return *mesh;
+	}
+
+	const Material& getMaterial() const
+	{
+		return *mtl;
+	}
+	/// @}
+
+	bool supportsHwSkinning() const;
+
+	const Vao& getVao(const PassLevelKey& key) const
+	{
+		return *vaosHashMap.at(key);
+	}
+
+	static void createVaos(const Material& mtl,
+		const VboArray& vbos,
+		VaosContainer& vaos,
+		PassLevelToVaoHashMap& vaosHashMap);
+
+private:
+	MeshResourcePointer mesh; ///< The geometry
+	MaterialResourcePointer mtl; ///< Material
+
+	VaosContainer vaos;
+	PassLevelToVaoHashMap vaosHashMap;
+
+	static Vao* createVao(const Material& mtl,
+		const VboArray& vbos,
+		const PassLevelKey& key);
 };
 
 

+ 6 - 14
anki/resource/ParticleEmitterRsrc.cpp

@@ -15,20 +15,12 @@ static const char* errMsg = "Incorrect or missing value ";
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-ParticleEmitterRsrc::ParticleEmitterRsrc():
-	particleLife(0.0),
-	particleLifeDeviation(0.0),
-	forceDirection(0.0),
-	forceDirectionDeviation(0.0),
-	forceMagnitude(0.0),
-	forceMagnitudeDeviation(0.0),
-	particleMass(0.0),
-	particleMassDeviation(0.0),
-	gravity(0.0),
-	gravityDeviation(0.0),
-	startingPos(0.0),
-	startingPosDeviation(0.0),
-	size(0.0)
+ParticleEmitterRsrc::ParticleEmitterRsrc()
+	: particleLife(0.0), particleLifeDeviation(0.0), forceDirection(0.0),
+		forceDirectionDeviation(0.0), forceMagnitude(0.0),
+		forceMagnitudeDeviation(0.0), particleMass(0.0),
+		particleMassDeviation(0.0), gravity(0.0), gravityDeviation(0.0),
+		startingPos(0.0), startingPosDeviation(0.0), size(0.0)
 {}
 
 

+ 23 - 23
anki/resource/ResourceManager.h

@@ -29,36 +29,36 @@ struct ResourceHook
 template<typename Type>
 class ResourceManager
 {
-	public:
-		typedef ResourceManager<Type> Self;
-		typedef ResourceHook<Type> Hook;
-		typedef boost::ptr_vector<Hook> Container;
-		typedef typename Container::iterator Iterator;
-		typedef typename Container::const_iterator ConstIterator;
+public:
+	typedef ResourceManager<Type> Self;
+	typedef ResourceHook<Type> Hook;
+	typedef boost::ptr_vector<Hook> Container;
+	typedef typename Container::iterator Iterator;
+	typedef typename Container::const_iterator ConstIterator;
 
-		virtual ~ResourceManager()
-		{}
+	virtual ~ResourceManager()
+	{}
 
-		Hook& load(const char* filename);
+	Hook& load(const char* filename);
 
-		void unload(const Hook& hook);
+	void unload(const Hook& hook);
 
-	protected:
-		Container hooks;
+protected:
+	Container hooks;
 
-		Iterator find(const char* filename);
+	Iterator find(const char* filename);
 
-		/// Allocate and load a resource.
-		/// This method allocates memory for a resource and loads it (calls the
-		/// load method). Its been used by the load method. Its a separate
-		/// method because we want to specialize it for async loaded resources
-		virtual void allocAndLoadRsrc(const char* filename, Type*& ptr);
+	/// Allocate and load a resource.
+	/// This method allocates memory for a resource and loads it (calls the
+	/// load method). Its been used by the load method. Its a separate
+	/// method because we want to specialize it for async loaded resources
+	virtual void allocAndLoadRsrc(const char* filename, Type*& ptr);
 
-		/// Dealocate the resource. Its separate for two reasons:
-		/// - Because we want to specialize it for the async loaded resources
-		/// - Because we cannot have the operator delete in a template body.
-		/// Apparently the compiler is to dump to decide
-		virtual void deallocRsrc(Type* rsrc);
+	/// Dealocate the resource. Its separate for two reasons:
+	/// - Because we want to specialize it for the async loaded resources
+	/// - Because we cannot have the operator delete in a template body.
+	/// Apparently the compiler is to dump to decide
+	virtual void deallocRsrc(Type* rsrc);
 };
 
 

+ 80 - 80
anki/resource/ResourcePointer.h

@@ -13,96 +13,96 @@ namespace anki {
 template<typename Type, typename ResourceManagerSingleton>
 class ResourcePointer
 {
-	public:
-		typedef ResourcePointer<Type, ResourceManagerSingleton> Self;
-		typedef typename ResourceManagerSingleton::ValueType::Hook Hook;
-
-		/// Default constructor
-		ResourcePointer()
-		:	hook(NULL)
-		{}
-
-		/// Copy constructor
-		ResourcePointer(const Self& b)
-		:	hook(NULL)
+public:
+	typedef ResourcePointer<Type, ResourceManagerSingleton> Self;
+	typedef typename ResourceManagerSingleton::ValueType::Hook Hook;
+
+	/// Default constructor
+	ResourcePointer()
+	:	hook(NULL)
+	{}
+
+	/// Copy constructor
+	ResourcePointer(const Self& b)
+	:	hook(NULL)
+	{
+		copy(b);
+	}
+
+	~ResourcePointer()
+	{
+		unload();
+	}
+
+	/// @name Accessors
+	/// @{
+	Type& operator*() const
+	{
+		ANKI_ASSERT(hook != NULL);
+		return *hook->resource;
+	}
+
+	Type* operator->() const
+	{
+		ANKI_ASSERT(hook != NULL);
+		return hook->resource;
+	}
+
+	Type* get() const
+	{
+		return hook->resource;
+	}
+
+	const std::string& getResourceName() const
+	{
+		return hook->uuid;
+	}
+	/// @}
+
+	/// Copy
+	Self& operator=(const Self& b)
+	{
+		copy(b);
+		return *this;
+	}
+
+	/// Load the resource using the resource manager
+	void load(const char* filename)
+	{
+		ANKI_ASSERT(hook == NULL);
+		hook = &ResourceManagerSingleton::get().load(filename);
+	}
+
+private:
+	/// Points to a container in the resource manager
+	Hook* hook;
+
+	/// Unloads the resource @see loadRsrc
+	void unload()
+	{
+		if(hook != NULL)
 		{
-			copy(b);
+			ResourceManagerSingleton::get().unload(*hook);
+			hook = NULL;
 		}
+	}
 
-		~ResourcePointer()
-		{
-			unload();
-		}
-
-		/// @name Accessors
-		/// @{
-		Type& operator*() const
-		{
-			ANKI_ASSERT(hook != NULL);
-			return *hook->resource;
-		}
-
-		Type* operator->() const
-		{
-			ANKI_ASSERT(hook != NULL);
-			return hook->resource;
-		}
-
-		Type* get() const
-		{
-			return hook->resource;
-		}
-
-		const std::string& getResourceName() const
-		{
-			return hook->uuid;
-		}
-		/// @}
-
-		/// Copy
-		Self& operator=(const Self& b)
-		{
-			copy(b);
-			return *this;
-		}
-
-		/// Load the resource using the resource manager
-		void load(const char* filename)
-		{
-			ANKI_ASSERT(hook == NULL);
-			hook = &ResourceManagerSingleton::get().load(filename);
-		}
-
-	private:
-		/// Points to a container in the resource manager
-		Hook* hook;
-
-		/// Unloads the resource @see loadRsrc
-		void unload()
+	/// XXX
+	void copy(const Self& b)
+	{
+		if(b.hook == NULL)
 		{
 			if(hook != NULL)
 			{
-				ResourceManagerSingleton::get().unload(*hook);
-				hook = NULL;
+				unload();
 			}
 		}
-
-		/// XXX
-		void copy(const Self& b)
+		else
 		{
-			if(b.hook == NULL)
-			{
-				if(hook != NULL)
-				{
-					unload();
-				}
-			}
-			else
-			{
-				unload();
-				load(b.hook->uuid.c_str());
-			}
+			unload();
+			load(b.hook->uuid.c_str());
 		}
+	}
 };
 
 

+ 4 - 4
anki/resource/Script.h

@@ -10,11 +10,11 @@ namespace anki {
 /// Python script resource
 class Script
 {
-	public:
-		void load(const char* filename);
+public:
+	void load(const char* filename);
 
-	private:
-		std::string source;
+private:
+	std::string source;
 };
 
 

+ 1 - 1
anki/resource/ShaderProgram.h

@@ -135,7 +135,7 @@ private:
 //==============================================================================
 
 inline ShaderProgram::ShaderProgram()
-:	glId(std::numeric_limits<uint>::max())
+	: glId(std::numeric_limits<uint>::max())
 {}
 
 

+ 5 - 5
anki/resource/ShaderProgramAttributeVariable.h

@@ -10,17 +10,17 @@ namespace anki {
 /// Attribute shader program variable
 class ShaderProgramAttributeVariable: public ShaderProgramVariable
 {
-	public:
-		ShaderProgramAttributeVariable(
-			int loc, const char* name, GLenum glDataType,
-			const ShaderProgram& fatherSProg);
+public:
+	ShaderProgramAttributeVariable(
+		int loc, const char* name, GLenum glDataType,
+		const ShaderProgram& fatherSProg);
 };
 
 
 inline ShaderProgramAttributeVariable::ShaderProgramAttributeVariable(
 	int loc, const char* name,
 	GLenum glDataType, const ShaderProgram& fatherSProg)
-:	ShaderProgramVariable(loc, name, glDataType, T_ATTRIBUTE, fatherSProg)
+	: ShaderProgramVariable(loc, name, glDataType, T_ATTRIBUTE, fatherSProg)
 {}
 
 

+ 122 - 137
anki/resource/ShaderProgramPrePreprocessor.h

@@ -29,156 +29,141 @@ namespace anki {
 /// @note The order of the "#pragma anki start" is important
 class ShaderProgramPrePreprocessor
 {
-	public:
-		/// It loads a file and parses it
-		/// @param[in] filename The file to load
-		/// @exception Exception
-		ShaderProgramPrePreprocessor(const char* filename)
-		{
-			parseFile(filename);
-		}
-
-		/// Destructor does nothing
-		~ShaderProgramPrePreprocessor()
-		{}
+public:
+	/// It loads a file and parses it
+	/// @param[in] filename The file to load
+	/// @exception Exception
+	ShaderProgramPrePreprocessor(const char* filename)
+	{
+		parseFile(filename);
+	}
 
-		/// @name Accessors
-		/// @{
-		const std::vector<std::string>& getTranformFeedbackVaryings() const
-		{
-			return trffbVaryings;
-		}
+	/// Destructor does nothing
+	~ShaderProgramPrePreprocessor()
+	{}
 
-		const std::string& getShaderSource(ShaderType type)
-		{
-			return output.shaderSources[type];
-		}
-		/// @}
+	/// @name Accessors
+	/// @{
+	const std::vector<std::string>& getTranformFeedbackVaryings() const
+	{
+		return trffbVaryings;
+	}
 
-	protected:
-		/// The pragma base class
-		struct Pragma
-		{
-			std::string definedInFile;
-			int definedInLine;
-
-			Pragma()
-			:	definedInLine(-1)
-			{}
-
-			Pragma(const std::string& definedInFile_, int definedInLine_);
-
-			bool isDefined() const
-			{
-				return definedInLine != -1;
-			}
-		};
-		
-		struct IncludePragma: Pragma
-		{
-			std::string filename;
-		};
+	const std::string& getShaderSource(ShaderType type)
+	{
+		return output.shaderSources[type];
+	}
+	/// @}
 
-		struct TrffbVaryingPragma: Pragma
-		{
-			std::string name;
+protected:
+	/// The pragma base class
+	struct Pragma
+	{
+		std::string definedInFile;
+		int definedInLine;
 
-			TrffbVaryingPragma(const std::string& definedInFile_,
-				int definedInLine_, const std::string& name_);
-		};
-	
-		struct CodeBeginningPragma: Pragma
-		{
-			/// The line number in the PrePreprocessor-compatible
-			/// file
-			int globalLine;
+		Pragma()
+		:	definedInLine(-1)
+		{}
 
-			CodeBeginningPragma()
-			:	globalLine(-1)
-			{}
-		};
+		Pragma(const std::string& definedInFile_, int definedInLine_)
+			: definedInFile(definedInFile_), definedInLine(definedInLine_)
+		{}
 
-		/// The output of the class packed in this struct
-		struct Output
+		bool isDefined() const
 		{
-			friend class PrePreprocessor;
-
-			/// Names and and ids for transform feedback varyings
-			std::vector<TrffbVaryingPragma> trffbVaryings;
-			boost::array<std::string, ST_NUM> shaderSources;
-		};
-
-		Output output; ///< The most important variable
-		std::vector<std::string> trffbVaryings;
-		/// The parseFileForPragmas fills this
-		std::vector<std::string> sourceLines;
-		boost::array<CodeBeginningPragma, ST_NUM> shaderStarts;
-		static boost::array<const char*, ST_NUM> startTokens; ///< XXX
-
-		/// Parse a PrePreprocessor formated GLSL file. Use
-		/// the accessors to get the output
-		/// @param filename The file to parse
-		/// @exception Ecxeption
-		void parseFile(const char* filename);
-
-		/// A recursive function that parses a file for pragmas and updates
-		/// the output
-		/// @param filename The file to parse
-		/// @param depth The #line in GLSL does not support filename so an
-		/// depth it being used. It also tracks the
-		/// includance depth
-		/// @exception Exception
-		void parseFileForPragmas(const std::string& filename, int depth = 0);
-
-		/// @todo
-		void parseStartPragma(scanner::Scanner& scanner,
-			const std::string& filename, uint depth,
-			const std::vector<std::string>& lines);
-
-		/// @todo
-		void parseIncludePragma(scanner::Scanner& scanner,
-			const std::string& filename, uint depth,
-			const std::vector<std::string>& lines);
-
-		/// @todo
-		void parseTrffbVarying(scanner::Scanner& scanner,
-			const std::string& filename, uint depth,
-			const std::vector<std::string>& lines);
-
-		/// Searches inside the Output::attributes or Output::trffbVaryings
-		/// vectors
-		/// @param vec Output::uniforms or Output::trffbVaryings
-		/// @param what The name of the varying or attrib
-		/// @return Iterator to the vector
-		template<typename Type>
-		typename std::vector<Type>::const_iterator findNamed(
-			const std::vector<Type>& vec,
-			const std::string& what) const;
-
-		void printSourceLines() const;  ///< For debugging
-
-		/// Add a in the source lines a: #line <line> <depth> // cmnt
-		void addLinePreProcExpression(uint line, uint depth, const char* cmnt);
-};
+			return definedInLine != -1;
+		}
+	};
 
+	struct IncludePragma: Pragma
+	{
+		std::string filename;
+	};
 
-//==============================================================================
-// Inlines                                                                     =
-//==============================================================================
+	struct TrffbVaryingPragma: Pragma
+	{
+		std::string name;
 
-inline ShaderProgramPrePreprocessor::Pragma::Pragma(
-	const std::string& definedInFile_, int definedInLine_)
-:	definedInFile(definedInFile_),
-	definedInLine(definedInLine_)
-{}
+		TrffbVaryingPragma(const std::string& definedInFile_,
+			int definedInLine_, const std::string& name_)
+			: Pragma(definedInFile_, definedInLine_), name(name_)
+		{}
+	};
 
+	struct CodeBeginningPragma: Pragma
+	{
+		/// The line number in the PrePreprocessor-compatible
+		/// file
+		int globalLine;
 
-inline ShaderProgramPrePreprocessor::TrffbVaryingPragma::TrffbVaryingPragma(
-	const std::string& definedInFile_,
-	int definedInLine_, const std::string& name_)
-:	Pragma(definedInFile_, definedInLine_),
-	name(name_)
-{}
+		CodeBeginningPragma()
+		:	globalLine(-1)
+		{}
+	};
+
+	/// The output of the class packed in this struct
+	struct Output
+	{
+		friend class PrePreprocessor;
+
+		/// Names and and ids for transform feedback varyings
+		std::vector<TrffbVaryingPragma> trffbVaryings;
+		boost::array<std::string, ST_NUM> shaderSources;
+	};
+
+	Output output; ///< The most important variable
+	std::vector<std::string> trffbVaryings;
+	/// The parseFileForPragmas fills this
+	std::vector<std::string> sourceLines;
+	boost::array<CodeBeginningPragma, ST_NUM> shaderStarts;
+	static boost::array<const char*, ST_NUM> startTokens; ///< XXX
+
+	/// Parse a PrePreprocessor formated GLSL file. Use
+	/// the accessors to get the output
+	/// @param filename The file to parse
+	/// @exception Ecxeption
+	void parseFile(const char* filename);
+
+	/// A recursive function that parses a file for pragmas and updates
+	/// the output
+	/// @param filename The file to parse
+	/// @param depth The #line in GLSL does not support filename so an
+	/// depth it being used. It also tracks the
+	/// includance depth
+	/// @exception Exception
+	void parseFileForPragmas(const std::string& filename, int depth = 0);
+
+	/// @todo
+	void parseStartPragma(scanner::Scanner& scanner,
+		const std::string& filename, uint depth,
+		const std::vector<std::string>& lines);
+
+	/// @todo
+	void parseIncludePragma(scanner::Scanner& scanner,
+		const std::string& filename, uint depth,
+		const std::vector<std::string>& lines);
+
+	/// @todo
+	void parseTrffbVarying(scanner::Scanner& scanner,
+		const std::string& filename, uint depth,
+		const std::vector<std::string>& lines);
+
+	/// Searches inside the Output::attributes or Output::trffbVaryings
+	/// vectors
+	/// @param vec Output::uniforms or Output::trffbVaryings
+	/// @param what The name of the varying or attrib
+	/// @return Iterator to the vector
+	template<typename Type>
+	typename std::vector<Type>::const_iterator findNamed(
+		const std::vector<Type>& vec,
+		const std::string& what) const;
+
+	void printSourceLines() const;  ///< For debugging
+
+	/// Add a in the source lines a: #line <line> <depth> // cmnt
+	void addLinePreProcExpression(uint line, uint depth, const char* cmnt);
+};
 
 
 template<typename Type>

+ 26 - 26
anki/resource/ShaderProgramUniformVariable.h

@@ -14,38 +14,38 @@ class Texture;
 /// Uniform shader variable
 class ShaderProgramUniformVariable: public ShaderProgramVariable
 {
-	public:
-		ShaderProgramUniformVariable(
-			int loc,
-			const char* name,
-			GLenum glDataType,
-			const ShaderProgram& fatherSProg);
-
-		/// @name Set the var
-		/// @{
-		void set(const float f) const;
-		void set(const float f[], uint size = 1) const;
-		void set(const Vec2 v2[], uint size = 1) const;
-		void set(const Vec3 v3[], uint size = 1) const;
-		void set(const Vec4 v4[], uint size = 1) const;
-		void set(const Mat3 m3[], uint size = 1) const;
-		void set(const Mat4 m4[], uint size = 1) const;
-		void set(const Texture& tex, uint texUnit) const;
-		/// @}
-
-	private:
-		/// Standard set uniform checks
-		/// - Check if initialized
-		/// - if the current shader program is the var's shader program
-		/// - if the GL driver gives the same location as the one the var has
-		void doSanityChecks() const;
+public:
+	ShaderProgramUniformVariable(
+		int loc,
+		const char* name,
+		GLenum glDataType,
+		const ShaderProgram& fatherSProg);
+
+	/// @name Set the var
+	/// @{
+	void set(const float f) const;
+	void set(const float f[], uint size = 1) const;
+	void set(const Vec2 v2[], uint size = 1) const;
+	void set(const Vec3 v3[], uint size = 1) const;
+	void set(const Vec4 v4[], uint size = 1) const;
+	void set(const Mat3 m3[], uint size = 1) const;
+	void set(const Mat4 m4[], uint size = 1) const;
+	void set(const Texture& tex, uint texUnit) const;
+	/// @}
+
+private:
+	/// Standard set uniform checks
+	/// - Check if initialized
+	/// - if the current shader program is the var's shader program
+	/// - if the GL driver gives the same location as the one the var has
+	void doSanityChecks() const;
 };
 
 
 inline ShaderProgramUniformVariable::ShaderProgramUniformVariable(
 	int loc_, const char* name_,
 	GLenum glDataType_, const ShaderProgram& father_)
-:	ShaderProgramVariable(loc_, name_, glDataType_, T_UNIFORM, father_)
+	: ShaderProgramVariable(loc_, name_, glDataType_, T_UNIFORM, father_)
 {}
 
 

+ 63 - 65
anki/resource/SkelAnim.h

@@ -11,40 +11,38 @@ namespace anki {
 /// Bone pose
 struct BonePose
 {
-	public:
-		BonePose(const Quat& r, const Vec3& trs);
-
-		/// Copy constructor
-		BonePose(const BonePose& b);
-
-		/// @name Accessors
-		/// @{
-		const Quat& getRotation() const
-		{
-			return rotation;
-		}
-
-		const Vec3& getTranslation() const
-		{
-			return translation;
-		}
-		/// @}
-
-	private:
-		Quat rotation;
-		Vec3 translation;
+public:
+	BonePose(const Quat& r, const Vec3& trs);
+
+	/// Copy constructor
+	BonePose(const BonePose& b);
+
+	/// @name Accessors
+	/// @{
+	const Quat& getRotation() const
+	{
+		return rotation;
+	}
+
+	const Vec3& getTranslation() const
+	{
+		return translation;
+	}
+	/// @}
+
+private:
+	Quat rotation;
+	Vec3 translation;
 };
 
 
 inline BonePose::BonePose(const Quat& r, const Vec3& trs)
-:	rotation(r),
- 	translation(trs)
+	: rotation(r), translation(trs)
 {}
 
 
 inline BonePose::BonePose(const BonePose& b)
-:	rotation(b.rotation),
- 	translation(b.translation)
+	: rotation(b.rotation), translation(b.translation)
 {}
 
 
@@ -53,19 +51,19 @@ class BoneAnim
 {
 	friend class SkelAnim;
 
-	public:
-		/// @name Accessors
-		/// @{
-		const std::vector<BonePose>& getBonePoses() const
-		{
-			return bonePoses;
-		}
-		/// @}
-
-	private:
-		/// The poses for every keyframe. Its empty if the bone doesnt have
-		/// any animation
-		std::vector<BonePose> bonePoses;
+public:
+	/// @name Accessors
+	/// @{
+	const std::vector<BonePose>& getBonePoses() const
+	{
+		return bonePoses;
+	}
+	/// @}
+
+private:
+	/// The poses for every keyframe. Its empty if the bone doesnt have
+	/// any animation
+	std::vector<BonePose> bonePoses;
 };
 
 
@@ -89,32 +87,32 @@ class BoneAnim
 /// @endcode
 class SkelAnim
 {
-	public:
-		/// @name Accessors
-		/// @{
-		const std::vector<uint>& getKeyframes() const
-		{
-			return keyframes;
-		}
-
-		uint getFramesNum() const
-		{
-			return framesNum;
-		}
-
-		const std::vector<BoneAnim>& getBoneAnimations() const
-		{
-			return boneAnims;
-		}
-		/// @}
-
-		/// Load
-		void load(const char* filename);
-
-	private:
-		std::vector<uint> keyframes;
-		uint framesNum;
-		std::vector<BoneAnim> boneAnims;
+public:
+	/// @name Accessors
+	/// @{
+	const std::vector<uint>& getKeyframes() const
+	{
+		return keyframes;
+	}
+
+	uint getFramesNum() const
+	{
+		return framesNum;
+	}
+
+	const std::vector<BoneAnim>& getBoneAnimations() const
+	{
+		return boneAnims;
+	}
+	/// @}
+
+	/// Load
+	void load(const char* filename);
+
+private:
+	std::vector<uint> keyframes;
+	uint framesNum;
+	std::vector<BoneAnim> boneAnims;
 };
 
 

+ 88 - 88
anki/resource/Skeleton.h

@@ -21,80 +21,80 @@ struct Bone
 {
 	friend class Skeleton; /// For loading
 
-	public:
-		/// @name Accessors
-		/// @{
-		const std::string& getName() const
-		{
-			return name;
-		}
-
-		const Vec3& getHead() const
-		{
-			return head;
-		}
-
-		const Vec3& getTail() const
-		{
-			return tail;
-		}
-
-		uint getId() const
-		{
-			return id;
-		}
-
-		const Bone* getParent() const
-		{
-			return parent;
-		}
-
-		const Bone& getChild(uint i) const
-		{
-			return *childs[i];
-		}
-
-		size_t getChildsNum() const
-		{
-			return childsNum;
-		}
-
-		const Mat3& getRotationSkeletonSpace() const
-		{
-			return rotSkelSpace;
-		}
-
-		const Vec3& getTranslationSkeletonSpace() const
-		{
-			return tslSkelSpace;
-		}
-
-		const Mat3& getRotationSkeletonSpaceInverted() const
-		{
-			return rotSkelSpaceInv;
-		}
-
-		const Vec3& getTranslationSkeletonSpaceInverted() const
-		{
-			return tslSkelSpaceInv;
-		}
-		/// @}
-
-	private:
-		std::string name; ///< The name of the bone
-		Vec3 head; ///< Starting point of the bone
-		Vec3 tail; ///< End point of the bone
-		uint id; ///< Pos inside the @ref Skeleton::bones vector
-		static const uint MAX_CHILDS_PER_BONE = 4; ///< Please dont change this
-		Bone* parent;
-		boost::array<Bone*, MAX_CHILDS_PER_BONE> childs;
-		ushort childsNum;
-
-		// see the class notes
-		Mat3 rotSkelSpace;
-		Vec3 tslSkelSpace;
-		Mat3 rotSkelSpaceInv;
-		Vec3 tslSkelSpaceInv;
+public:
+	/// @name Accessors
+	/// @{
+	const std::string& getName() const
+	{
+		return name;
+	}
+
+	const Vec3& getHead() const
+	{
+		return head;
+	}
+
+	const Vec3& getTail() const
+	{
+		return tail;
+	}
+
+	uint getId() const
+	{
+		return id;
+	}
+
+	const Bone* getParent() const
+	{
+		return parent;
+	}
+
+	const Bone& getChild(uint i) const
+	{
+		return *childs[i];
+	}
+
+	size_t getChildsNum() const
+	{
+		return childsNum;
+	}
+
+	const Mat3& getRotationSkeletonSpace() const
+	{
+		return rotSkelSpace;
+	}
+
+	const Vec3& getTranslationSkeletonSpace() const
+	{
+		return tslSkelSpace;
+	}
+
+	const Mat3& getRotationSkeletonSpaceInverted() const
+	{
+		return rotSkelSpaceInv;
+	}
+
+	const Vec3& getTranslationSkeletonSpaceInverted() const
+	{
+		return tslSkelSpaceInv;
+	}
+	/// @}
+
+private:
+	std::string name; ///< The name of the bone
+	Vec3 head; ///< Starting point of the bone
+	Vec3 tail; ///< End point of the bone
+	uint id; ///< Pos inside the @ref Skeleton::bones vector
+	static const uint MAX_CHILDS_PER_BONE = 4; ///< Please dont change this
+	Bone* parent;
+	boost::array<Bone*, MAX_CHILDS_PER_BONE> childs;
+	ushort childsNum;
+
+	// see the class notes
+	Mat3 rotSkelSpace;
+	Vec3 tslSkelSpace;
+	Mat3 rotSkelSpaceInv;
+	Vec3 tslSkelSpaceInv;
 };
 
 
@@ -121,20 +121,20 @@ struct Bone
 /// @endcode
 class Skeleton
 {
-	public:
-		/// Implements Resource::load
-		void load(const char* filename);
-
-		/// @name Accessors
-		/// @{
-		const std::vector<Bone>& getBones() const
-		{
-			return bones;
-		}
-		/// @}
-
-	private:
-		std::vector<Bone> bones;
+public:
+	/// Implements Resource::load
+	void load(const char* filename);
+
+	/// @name Accessors
+	/// @{
+	const std::vector<Bone>& getBones() const
+	{
+		return bones;
+	}
+	/// @}
+
+private:
+	std::vector<Bone> bones;
 };
 
 

+ 23 - 23
anki/resource/Skin.h

@@ -26,29 +26,29 @@ class SkelAnim;
 /// @endcode
 class Skin
 {
-	public:
-		Skin();
-		~Skin();
-
-		/// Implements Resource::load
-		void load(const char*);
-
-		/// @name Accessors
-		/// @{
-		const Model& getModel() const;
-		const boost::ptr_vector<ModelPatch>& getModelPatches() const;
-		const Skeleton& getSkeleton() const;
-		const std::vector<SkelAnimResourcePointer >& getSkelAnims() const;
-		/// @}
-
-	private:
-		/// @name The resources
-		/// @{
-		ModelResourcePointer model;
-		SkeletonResourcePointer skeleton; ///< The skeleton
-		/// The standard skeleton animations
-		std::vector<SkelAnimResourcePointer > skelAnims;
-		/// @}
+public:
+	Skin();
+	~Skin();
+
+	/// Implements Resource::load
+	void load(const char*);
+
+	/// @name Accessors
+	/// @{
+	const Model& getModel() const;
+	const boost::ptr_vector<ModelPatch>& getModelPatches() const;
+	const Skeleton& getSkeleton() const;
+	const std::vector<SkelAnimResourcePointer >& getSkelAnims() const;
+	/// @}
+
+private:
+	/// @name The resources
+	/// @{
+	ModelResourcePointer model;
+	SkeletonResourcePointer skeleton; ///< The skeleton
+	/// The standard skeleton animations
+	std::vector<SkelAnimResourcePointer > skelAnims;
+	/// @}
 };
 
 

+ 122 - 130
anki/resource/Texture.h

@@ -21,139 +21,131 @@ class Image;
 /// @note The last texture unit is reserved and you cannot use it
 class Texture
 {
-	public:
-		enum TextureFilteringType
-		{
-			TFT_NEAREST,
-			TFT_LINEAR,
-			TFT_TRILINEAR
-		};
-
-		enum DataCompression
-		{
-			DC_NONE,
-			DC_DXT1,
-			DC_DXT3,
-			DC_DXT5
-		};
-
-		/// Texture initializer struct
-		struct Initializer
-		{
-			float width;
-			float height;
-			int internalFormat;
-			int format;
-			uint type;
-			const void* data;
-			bool mipmapping;
-			TextureFilteringType filteringType;
-			bool repeat;
-			int anisotropyLevel;
-			DataCompression dataCompression;
-			size_t dataSize; ///< For compressed textures
-		};
-
-		/// Default constructor
-		Texture();
-
-		/// Desrcuctor
-		~Texture();
-
-
-		/// @name Accessors
-		/// @{
-		uint getGlId() const;
-		uint getInternalFormat() const;
-		uint getFormat() const;
-		uint getType() const;
-		static int& getTextureUnitsNum() {return textureUnitsNum;}
-		/// @}
-
-		/// @name Create tex funcs
-		/// @{
-
-		/// Implements Resource::load
-		/// @exception Exception
-		void load(const char* filename);
-		
-		/// @exception Exception
-		void load(const Image& img);
-
-		/// Create a texture
-		void create(const Initializer& init);
-		/// @}
-
-		void bind(uint texUnit = 0) const;
-		void setRepeat(bool repeat) const;
-		void setFiltering(TextureFilteringType filterType);
-		void setAnisotropy(uint level);
-		void setMipmapLevel(uint level);
-		void genMipmap();
-		int getWidth(uint level = 0) const;
-		int getHeight(uint level = 0) const;
-		int getBaseLevel() const;
-		int getMaxLevel() const;
-		static uint getActiveTexUnit();
-		static uint getBindedTexId(uint unit);
-
-	private:
-		uint glId; ///< Identification for OGL
-		uint target; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
-		uint internalFormat; ///< GL_COMPRESSED_RED, GL_RGB16 etc
-		uint format; ///< GL_RED, GL_RG, GL_RGB etc
-		uint type; ///< GL_UNSIGNED_BYTE, GL_BYTE etc
-
-		/// @name Variables set by the renderer
-		/// Set upon OpenGL initialization
-		/// @{
-		static int  textureUnitsNum;
-		static bool mipmappingEnabled;
-		static bool compressionEnabled;
-		static int  anisotropyLevel;
-		/// @}
-
-		void setTexParameter(uint paramName, int value) const;
-		void setTexParameter(uint paramName, float value) const;
-
-		bool isLoaded() const;
+public:
+	enum TextureFilteringType
+	{
+		TFT_NEAREST,
+		TFT_LINEAR,
+		TFT_TRILINEAR
+	};
+
+	enum DataCompression
+	{
+		DC_NONE,
+		DC_DXT1,
+		DC_DXT3,
+		DC_DXT5
+	};
+
+	/// Texture initializer struct
+	struct Initializer
+	{
+		float width;
+		float height;
+		int internalFormat;
+		int format;
+		uint type;
+		const void* data;
+		bool mipmapping;
+		TextureFilteringType filteringType;
+		bool repeat;
+		int anisotropyLevel;
+		DataCompression dataCompression;
+		size_t dataSize; ///< For compressed textures
+	};
+
+	/// Default constructor
+	Texture();
+
+	/// Desrcuctor
+	~Texture();
+
+
+	/// @name Accessors
+	/// @{
+	uint getGlId() const
+	{
+		ANKI_ASSERT(isLoaded());
+		return glId;
+	}
+
+	uint getInternalFormat() const
+	{
+		ANKI_ASSERT(isLoaded());
+		return internalFormat;
+	}
+
+	uint getFormat() const
+	{
+		ANKI_ASSERT(isLoaded());
+		return format;
+	}
+
+	uint getType() const
+	{
+		ANKI_ASSERT(isLoaded());
+		return type;
+	}
+
+	static int& getTextureUnitsNum()
+	{
+		return textureUnitsNum;
+	}
+	/// @}
+
+	/// @name Create tex funcs
+	/// @{
+
+	/// Implements Resource::load
+	/// @exception Exception
+	void load(const char* filename);
+
+	/// @exception Exception
+	void load(const Image& img);
+
+	/// Create a texture
+	void create(const Initializer& init);
+	/// @}
+
+	void bind(uint texUnit = 0) const;
+	void setRepeat(bool repeat) const;
+	void setFiltering(TextureFilteringType filterType);
+	void setAnisotropy(uint level);
+	void setMipmapLevel(uint level);
+	void genMipmap();
+	int getWidth(uint level = 0) const;
+	int getHeight(uint level = 0) const;
+	int getBaseLevel() const;
+	int getMaxLevel() const;
+	static uint getActiveTexUnit();
+	static uint getBindedTexId(uint unit);
+
+private:
+	uint glId; ///< Identification for OGL
+	uint target; ///< GL_TEXTURE_2D, GL_TEXTURE_3D... etc
+	uint internalFormat; ///< GL_COMPRESSED_RED, GL_RGB16 etc
+	uint format; ///< GL_RED, GL_RG, GL_RGB etc
+	uint type; ///< GL_UNSIGNED_BYTE, GL_BYTE etc
+
+	/// @name Variables set by the renderer
+	/// Set upon OpenGL initialization
+	/// @{
+	static int  textureUnitsNum;
+	static bool mipmappingEnabled;
+	static bool compressionEnabled;
+	static int  anisotropyLevel;
+	/// @}
+
+	void setTexParameter(uint paramName, int value) const;
+	void setTexParameter(uint paramName, float value) const;
+
+	bool isLoaded() const
+	{
+		return glId != std::numeric_limits<uint>::max();
+	}
 };
 
 
-inline uint Texture::getGlId() const
-{
-	ANKI_ASSERT(isLoaded());
-	return glId;
-}
-
-
-inline uint Texture::getInternalFormat() const
-{
-	ANKI_ASSERT(isLoaded());
-	return internalFormat;
-}
-
-
-inline uint Texture::getFormat() const
-{
-	ANKI_ASSERT(isLoaded());
-	return format;
-}
-
-
-inline uint Texture::getType() const
-{
-	ANKI_ASSERT(isLoaded());
-	return type;
-}
-
-
-inline bool Texture::isLoaded() const
-{
-	return glId != std::numeric_limits<uint>::max();
-}
-
-
 } // end namespace