Browse Source

IS and refactoring

Panagiotis Christopoulos Charitos 13 years ago
parent
commit
41ab982f26

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

@@ -17,16 +17,16 @@ public:
 	/// @{
 	/// @{
 	explicit Axisang();
 	explicit Axisang();
 	         Axisang(const Axisang& b);
 	         Axisang(const Axisang& b);
-	explicit Axisang(const float rad, const Vec3& axis_);
+	explicit Axisang(const F32 rad, const Vec3& axis_);
 	explicit Axisang(const Quat& q);
 	explicit Axisang(const Quat& q);
 	explicit Axisang(const Mat3& m3);
 	explicit Axisang(const Mat3& m3);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @name Accessors
 	/// @{
 	/// @{
-	float getAngle() const;
-	float& getAngle();
-	void setAngle(const float a);
+	F32 getAngle() const;
+	F32& getAngle();
+	void setAngle(const F32 a);
 
 
 	const Vec3& getAxis() const;
 	const Vec3& getAxis() const;
 	Vec3& getAxis();
 	Vec3& getAxis();
@@ -46,7 +46,7 @@ public:
 private:
 private:
 	/// @name Data
 	/// @name Data
 	/// @{
 	/// @{
-	float ang;
+	F32 ang;
 	Vec3 axis;
 	Vec3 axis;
 	/// @}
 	/// @}
 };
 };

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

@@ -16,8 +16,8 @@ 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_)
+// F32, axis
+inline Axisang::Axisang(const F32 rad, const Vec3& axis_)
 	: ang(rad), axis(axis_)
 	: ang(rad), axis(axis_)
 {}
 {}
 
 
@@ -25,7 +25,7 @@ inline Axisang::Axisang(const float rad, const Vec3& axis_)
 inline Axisang::Axisang(const Quat& q)
 inline Axisang::Axisang(const Quat& q)
 {
 {
 	ang = 2.0 * acos(q.w());
 	ang = 2.0 * acos(q.w());
-	float length = Math::sqrt(1.0 - q.w() * q.w());
+	F32 length = Math::sqrt(1.0 - q.w() * q.w());
 	if(Math::isZero(length))
 	if(Math::isZero(length))
 	{
 	{
 		axis = Vec3(0.0);
 		axis = Vec3(0.0);
@@ -85,12 +85,12 @@ inline Axisang::Axisang(const Mat3& m3)
 			axis.z() = 0.0;
 			axis.z() = 0.0;
 		}
 		}
 
 
-		bool xZero = (fabs(axis.x()) < Math::EPSILON);
-		bool yZero = (fabs(axis.y()) < Math::EPSILON);
-		bool zZero = (fabs(axis.z()) < Math::EPSILON);
-		bool xyPositive = (m3(0, 1) > 0);
-		bool xzPositive = (m3(0, 2) > 0);
-		bool yzPositive = (m3(1, 2) > 0);
+		Bool xZero = (fabs(axis.x()) < Math::EPSILON);
+		Bool yZero = (fabs(axis.y()) < Math::EPSILON);
+		Bool zZero = (fabs(axis.z()) < Math::EPSILON);
+		Bool xyPositive = (m3(0, 1) > 0);
+		Bool xzPositive = (m3(0, 2) > 0);
+		Bool yzPositive = (m3(1, 2) > 0);
 		if(xZero && !yZero && !zZero)
 		if(xZero && !yZero && !zZero)
 		{
 		{
 			if(!yzPositive)
 			if(!yzPositive)
@@ -116,7 +116,7 @@ inline Axisang::Axisang(const Mat3& m3)
 		return;
 		return;
 	}
 	}
 
 
-	float s = Math::sqrt((m3(2, 1) - m3(1, 2)) * (m3(2, 1) - m3(1, 2)) 
+	F32 s = Math::sqrt((m3(2, 1) - m3(1, 2)) * (m3(2, 1) - m3(1, 2)) 
 		+ (m3(0, 2) - m3(2, 0)) * (m3(0, 2) - m3(2, 0)) 
 		+ (m3(0, 2) - m3(2, 0)) * (m3(0, 2) - m3(2, 0)) 
 		+ (m3(1, 0) - m3(0, 1)) * (m3(1, 0) - m3(0, 1)));
 		+ (m3(1, 0) - m3(0, 1)) * (m3(1, 0) - m3(0, 1)));
 
 
@@ -135,17 +135,17 @@ inline Axisang::Axisang(const Mat3& m3)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float Axisang::getAngle() const
+inline F32 Axisang::getAngle() const
 {
 {
 	return ang;
 	return ang;
 }
 }
 
 
-inline float& Axisang::getAngle()
+inline F32& Axisang::getAngle()
 {
 {
 	return ang;
 	return ang;
 }
 }
 
 
-inline void Axisang::setAngle(float a)
+inline void Axisang::setAngle(F32 a)
 {
 {
 	ang = a;
 	ang = a;
 }
 }

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

@@ -16,7 +16,7 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Euler();
 	explicit Euler();
-	explicit Euler(const float x, const float y, const float z);
+	explicit Euler(const F32 x, const F32 y, const F32 z);
 			 Euler(const Euler& b);
 			 Euler(const Euler& b);
 	explicit Euler(const Quat& q);
 	explicit Euler(const Quat& q);
 	explicit Euler(const Mat3& m3);
 	explicit Euler(const Mat3& m3);
@@ -24,14 +24,14 @@ public:
 
 
 	/// @name Accessors
 	/// @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;
+	F32& operator [](const U i);
+	F32 operator [](const U i) const;
+	F32& x();
+	F32 x() const;
+	F32& y();
+	F32 y() const;
+	F32& z();
+	F32 z() const;
 	/// @}
 	/// @}
 
 
 	/// @name Operators with same type
 	/// @name Operators with same type
@@ -51,10 +51,10 @@ private:
 	{
 	{
 		struct
 		struct
 		{
 		{
-			float x, y, z;
+			F32 x, y, z;
 		} vec;
 		} vec;
 
 
-		std::array<float, 3> arr;
+		std::array<F32, 3> arr;
 	};
 	};
 	/// @}
 	/// @}
 };
 };

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

@@ -12,8 +12,8 @@ inline Euler::Euler()
 	x() = y() = z() = 0.0;
 	x() = y() = z() = 0.0;
 }
 }
 
 
-// float, float, float
-inline Euler::Euler(const float x_, const float y_, const float z_)
+// F32, F32, F32
+inline Euler::Euler(const F32 x_, const F32 y_, const F32 z_)
 {
 {
 	x() = x_;
 	x() = x_;
 	y() = y_;
 	y() = y_;
@@ -31,7 +31,7 @@ inline Euler::Euler(const Euler& b)
 // Quat
 // Quat
 inline Euler::Euler(const Quat& q)
 inline Euler::Euler(const Quat& q)
 {
 {
-	float test = q.x() * q.y() + q.z() * q.w();
+	F32 test = q.x() * q.y() + q.z() * q.w();
 	if(test > 0.499)
 	if(test > 0.499)
 	{
 	{
 		y() = 2.0 * atan2(q.x(), q.w());
 		y() = 2.0 * atan2(q.x(), q.w());
@@ -47,9 +47,9 @@ inline Euler::Euler(const Quat& q)
 		return;
 		return;
 	}
 	}
 
 
-	float sqx = q.x() * q.x();
-	float sqy = q.y() * q.y();
-	float sqz = q.z() * q.z();
+	F32 sqx = q.x() * q.x();
+	F32 sqy = q.y() * q.y();
+	F32 sqz = q.z() * q.z();
 	y() = atan2(2.0 * q.y() * q.w() - 2.0 * q.x() * q.z(),
 	y() = atan2(2.0 * q.y() * q.w() - 2.0 * q.x() * q.z(),
 		1.0 - 2.0 * sqy - 2.0 * sqz);
 		1.0 - 2.0 * sqy - 2.0 * sqz);
 	z() = asin(2.0 * test);
 	z() = asin(2.0 * test);
@@ -60,16 +60,16 @@ inline Euler::Euler(const Quat& q)
 // mat3
 // mat3
 inline Euler::Euler(const Mat3& m3)
 inline Euler::Euler(const Mat3& m3)
 {
 {
-	float cx, sx;
-	float cy, sy;
-	float cz, sz;
+	F32 cx, sx;
+	F32 cy, sy;
+	F32 cz, sz;
 
 
 	sy = m3(0, 2);
 	sy = m3(0, 2);
 	cy = Math::sqrt(1.0 - sy * sy);
 	cy = Math::sqrt(1.0 - sy * sy);
 	// normal case
 	// normal case
 	if (!Math::isZero(cy))
 	if (!Math::isZero(cy))
 	{
 	{
-		float factor = 1.0/cy;
+		F32 factor = 1.0/cy;
 		sx = -m3(1, 2) * factor;
 		sx = -m3(1, 2) * factor;
 		cx = m3(2, 2) * factor;
 		cx = m3(2, 2) * factor;
 		sz = -m3(0, 1) * factor;
 		sz = -m3(0, 1) * factor;
@@ -93,42 +93,42 @@ inline Euler::Euler(const Mat3& m3)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float& Euler::operator [](const size_t i)
+inline F32& Euler::operator [](const U i)
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
-inline float Euler::operator [](const size_t i) const
+inline F32 Euler::operator [](const U i) const
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
-inline float& Euler::x()
+inline F32& Euler::x()
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float Euler::x() const
+inline F32 Euler::x() const
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float& Euler::y()
+inline F32& Euler::y()
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float Euler::y() const
+inline F32 Euler::y() const
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float& Euler::z()
+inline F32& Euler::z()
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float Euler::z() const
+inline F32 Euler::z() const
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }

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

@@ -16,11 +16,11 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Mat3() {};
 	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[]);
+	explicit Mat3(const F32 f);
+	explicit Mat3(const F32 m00, const F32 m01, const F32 m02,
+		const F32 m10, const F32 m11, const F32 m12,
+		const F32 m20, const F32 m21, const F32 m22);
+	explicit Mat3(const F32 arr[]);
 	Mat3(const Mat3& b);
 	Mat3(const Mat3& b);
 	explicit Mat3(const Quat& q); ///< Quat to Mat3. 12 muls, 12 adds
 	explicit Mat3(const Quat& q); ///< Quat to Mat3. 12 muls, 12 adds
 	explicit Mat3(const Euler& eu);
 	explicit Mat3(const Euler& eu);
@@ -29,10 +29,10 @@ public:
 
 
 	/// @name Accessors
 	/// @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;
+	F32& operator()(const U i, const U j);
+	const F32& operator()(const U i, const U j) const;
+	F32& operator[](const U i);
+	const F32& operator[](const U i) const;
 	/// @}
 	/// @}
 
 
 	/// @name Operators with same type
 	/// @name Operators with same type
@@ -46,20 +46,20 @@ public:
 	Mat3& operator*=(const Mat3& b);
 	Mat3& operator*=(const Mat3& b);
 	Mat3 operator/(const Mat3& b) const;
 	Mat3 operator/(const Mat3& b) const;
 	Mat3& operator/=(const Mat3& b);
 	Mat3& operator/=(const Mat3& b);
-	bool operator==(const Mat3& b) const;
-	bool operator!=(const Mat3& b) const;
+	Bool operator==(const Mat3& b) const;
+	Bool operator!=(const Mat3& b) const;
 	/// @}
 	/// @}
 
 
-	/// @name Operators with float
+	/// @name Operators with F32
 	/// @{
 	/// @{
-	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);
+	Mat3 operator+(const F32 f) const;
+	Mat3& operator+=(const F32 f);
+	Mat3 operator-(const F32 f) const;
+	Mat3& operator-=(const F32 f);
+	Mat3 operator*(const F32 f) const;
+	Mat3& operator*=(const F32 f);
+	Mat3 operator/(const F32 f) const;
+	Mat3& operator/=(const F32 f);
 	/// @}
 	/// @}
 
 
 	/// @name Operators with others
 	/// @name Operators with others
@@ -72,31 +72,31 @@ public:
 	/// @name Other
 	/// @name Other
 	/// @{
 	/// @{
 	void setRows(const Vec3& a, const Vec3& b, const Vec3& c);
 	void setRows(const Vec3& a, const Vec3& b, const Vec3& c);
-	void setRow(const size_t i, const Vec3& v);
+	void setRow(const U i, const Vec3& v);
 	void getRows(Vec3& a, Vec3& b, Vec3& c) const;
 	void getRows(Vec3& a, Vec3& b, Vec3& c) const;
-	Vec3 getRow(const size_t i) const;
+	Vec3 getRow(const U i) const;
 	void setColumns(const Vec3& a, const Vec3& b, const Vec3& c);
 	void setColumns(const Vec3& a, const Vec3& b, const Vec3& c);
-	void setColumn(const size_t i, const Vec3& v);
+	void setColumn(const U i, const Vec3& v);
 	void getColumns(Vec3& a, Vec3& b, Vec3& c) const;
 	void getColumns(Vec3& a, Vec3& b, Vec3& c) const;
-	Vec3 getColumn(const size_t i) const;
+	Vec3 getColumn(const U i) const;
 	Vec3 getXAxis() const; ///< Get 1st column
 	Vec3 getXAxis() const; ///< Get 1st column
 	Vec3 getYAxis() const; ///< Get 2nd column
 	Vec3 getYAxis() const; ///< Get 2nd column
 	Vec3 getZAxis() const; ///< Get 3rd column
 	Vec3 getZAxis() const; ///< Get 3rd column
 	void setXAxis(const Vec3& v3); ///< Set 1st column
 	void setXAxis(const Vec3& v3); ///< Set 1st column
 	void setYAxis(const Vec3& v3); ///< Set 2nd column
 	void setYAxis(const Vec3& v3); ///< Set 2nd column
 	void setZAxis(const Vec3& v3); ///< Set 3rd column
 	void setZAxis(const Vec3& v3); ///< Set 3rd column
-	void setRotationX(const float rad);
-	void setRotationY(const float rad);
-	void setRotationZ(const float rad);
+	void setRotationX(const F32 rad);
+	void setRotationY(const F32 rad);
+	void setRotationZ(const F32 rad);
 	/// It rotates "this" in the axis defined by the rotation AND not the
 	/// It rotates "this" in the axis defined by the rotation AND not the
 	/// world axis
 	/// world axis
-	void rotateXAxis(const float rad);
-	void rotateYAxis(const float rad); ///< @copybrief rotateXAxis
-	void rotateZAxis(const float rad); ///< @copybrief rotateXAxis
+	void rotateXAxis(const F32 rad);
+	void rotateYAxis(const F32 rad); ///< @copybrief rotateXAxis
+	void rotateZAxis(const F32 rad); ///< @copybrief rotateXAxis
 	void transpose();
 	void transpose();
 	Mat3 getTransposed() const;
 	Mat3 getTransposed() const;
 	void reorthogonalize();
 	void reorthogonalize();
-	float getDet() const;
+	F32 getDet() const;
 	void invert();
 	void invert();
 	Mat3 getInverse() const;
 	Mat3 getInverse() const;
 	void setIdentity();
 	void setIdentity();
@@ -106,10 +106,10 @@ public:
 
 
 	/// @name Friends
 	/// @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 Mat3 operator+(F32 f, const Mat3& m3);
+	friend Mat3 operator-(F32 f, const Mat3& m3);
+	friend Mat3 operator*(F32 f, const Mat3& m3);
+	friend Mat3 operator/(F32 f, const Mat3& m3);
 	friend std::ostream& operator<<(std::ostream& s, const Mat3& m);
 	friend std::ostream& operator<<(std::ostream& s, const Mat3& m);
 	/// @}
 	/// @}
 
 
@@ -118,16 +118,16 @@ private:
 	/// @{
 	/// @{
 	union
 	union
 	{
 	{
-		std::array<float, 9> arr1;
-		std::array<std::array<float, 3>, 3> arr2;
-		float carr1[9]; ///< For gdb
-		float carr2[3][3]; ///< For gdb
+		std::array<F32, 9> arr1;
+		std::array<std::array<F32, 3>, 3> arr2;
+		F32 carr1[9]; ///< For gdb
+		F32 carr2[3][3]; ///< For gdb
 	};
 	};
 	/// @}
 	/// @}
 };
 };
 /// @}
 /// @}
 
 
-static_assert(sizeof(Mat3) == sizeof(float) * 3 * 3, "Incorrect size");
+static_assert(sizeof(Mat3) == sizeof(F32) * 3 * 3, "Incorrect size");
 
 
 } // end namespace
 } // end namespace
 
 

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

@@ -6,28 +6,28 @@ namespace anki {
 // Constructors                                                                =
 // Constructors                                                                =
 //==============================================================================
 //==============================================================================
 
 
-// constructor [float]
-inline Mat3::Mat3(const float f)
+// constructor [F32]
+inline Mat3::Mat3(const F32 f)
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] = f;
 		(*this)[i] = f;
 	}
 	}
 }
 }
 
 
-// float[]
-inline Mat3::Mat3(const float arr [])
+// F32[]
+inline Mat3::Mat3(const F32 arr [])
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] = arr[i];
 		(*this)[i] = arr[i];
 	}
 	}
 }
 }
 
 
-// many floats
-inline Mat3::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)
+// many F32s
+inline Mat3::Mat3(const F32 m00, const F32 m01, const F32 m02,
+	const F32 m10, const F32 m11, const F32 m12,
+	const F32 m20, const F32 m21, const F32 m22)
 {
 {
 	(*this)(0, 0) = m00;
 	(*this)(0, 0) = m00;
 	(*this)(0, 1) = m01;
 	(*this)(0, 1) = m01;
@@ -43,7 +43,7 @@ inline Mat3::Mat3(const float m00, const float m01, const float m02,
 // Copy
 // Copy
 inline Mat3::Mat3(const Mat3& b)
 inline Mat3::Mat3(const Mat3& b)
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] = b[i];
 		(*this)[i] = b[i];
 	}
 	}
@@ -55,7 +55,7 @@ inline Mat3::Mat3(const Quat& q)
 	// If length is > 1 + 0.002 or < 1 - 0.002 then not normalized quat
 	// If length is > 1 + 0.002 or < 1 - 0.002 then not normalized quat
 	ANKI_ASSERT(fabs(1.0 - q.getLength()) <= 0.002);
 	ANKI_ASSERT(fabs(1.0 - q.getLength()) <= 0.002);
 
 
-	float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
+	F32 xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
 
 	xs = q.x() + q.x();
 	xs = q.x() + q.x();
 	ys = q.y() + q.y();
 	ys = q.y() + q.y();
@@ -86,7 +86,7 @@ inline Mat3::Mat3(const Quat& q)
 // Euler
 // Euler
 inline Mat3::Mat3(const Euler& e)
 inline Mat3::Mat3(const Euler& e)
 {
 {
-	float ch, sh, ca, sa, cb, sb;
+	F32 ch, sh, ca, sa, cb, sb;
 	Math::sinCos(e.y(), sh, ch);
 	Math::sinCos(e.y(), sh, ch);
 	Math::sinCos(e.z(), sa, ca);
 	Math::sinCos(e.z(), sa, ca);
 	Math::sinCos(e.x(), sb, cb);
 	Math::sinCos(e.x(), sb, cb);
@@ -108,17 +108,17 @@ inline Mat3::Mat3(const Axisang& axisang)
 	// Not normalized axis
 	// Not normalized axis
 	ANKI_ASSERT(Math::isZero(1.0 - axisang.getAxis().getLength()));
 	ANKI_ASSERT(Math::isZero(1.0 - axisang.getAxis().getLength()));
 
 
-	float c, s;
+	F32 c, s;
 	Math::sinCos(axisang.getAngle(), s, c);
 	Math::sinCos(axisang.getAngle(), s, c);
-	float t = 1.0 - c;
+	F32 t = 1.0 - c;
 
 
 	const Vec3& axis = axisang.getAxis();
 	const Vec3& axis = axisang.getAxis();
 	(*this)(0, 0) = c + axis.x() * axis.x() * t;
 	(*this)(0, 0) = c + axis.x() * axis.x() * t;
 	(*this)(1, 1) = c + axis.y() * axis.y() * t;
 	(*this)(1, 1) = c + axis.y() * axis.y() * t;
 	(*this)(2, 2) = c + axis.z() * axis.z() * t;
 	(*this)(2, 2) = c + axis.z() * axis.z() * t;
 
 
-	float tmp1 = axis.x() * axis.y() * t;
-	float tmp2 = axis.z() * s;
+	F32 tmp1 = axis.x() * axis.y() * t;
+	F32 tmp2 = axis.z() * s;
 	(*this)(1, 0) = tmp1 + tmp2;
 	(*this)(1, 0) = tmp1 + tmp2;
 	(*this)(0, 1) = tmp1 - tmp2;
 	(*this)(0, 1) = tmp1 - tmp2;
 	tmp1 = axis.x() * axis.z() * t;
 	tmp1 = axis.x() * axis.z() * t;
@@ -135,22 +135,22 @@ inline Mat3::Mat3(const Axisang& axisang)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float& Mat3::operator()(const size_t i, const size_t j)
+inline F32& Mat3::operator()(const U i, const U j)
 {
 {
 	return arr2[i][j];
 	return arr2[i][j];
 }
 }
 
 
-inline const float& Mat3::operator()(const size_t i, const size_t j) const
+inline const F32& Mat3::operator()(const U i, const U j) const
 {
 {
 	return arr2[i][j];
 	return arr2[i][j];
 }
 }
 
 
-inline float& Mat3::operator[](const size_t i)
+inline F32& Mat3::operator[](const U i)
 {
 {
 	return arr1[i];
 	return arr1[i];
 }
 }
 
 
-inline const float& Mat3::operator[](const size_t i) const
+inline const F32& Mat3::operator[](const U i) const
 {
 {
 	return arr1[i];
 	return arr1[i];
 }
 }
@@ -162,7 +162,7 @@ inline const float& Mat3::operator[](const size_t i) const
 // =
 // =
 inline Mat3& Mat3::operator=(const Mat3& b)
 inline Mat3& Mat3::operator=(const Mat3& b)
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] = b[i];
 		(*this)[i] = b[i];
 	}
 	}
@@ -173,7 +173,7 @@ inline Mat3& Mat3::operator=(const Mat3& b)
 inline Mat3 Mat3::operator+(const Mat3& b) const
 inline Mat3 Mat3::operator+(const Mat3& b) const
 {
 {
 	Mat3 c;
 	Mat3 c;
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		c[i] = (*this)[i] + b[i];
 		c[i] = (*this)[i] + b[i];
 	}
 	}
@@ -183,7 +183,7 @@ inline Mat3 Mat3::operator+(const Mat3& b) const
 // +=
 // +=
 inline Mat3& Mat3::operator+=(const Mat3& b)
 inline Mat3& Mat3::operator+=(const Mat3& b)
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] += b[i];
 		(*this)[i] += b[i];
 	}
 	}
@@ -194,7 +194,7 @@ inline Mat3& Mat3::operator+=(const Mat3& b)
 inline Mat3 Mat3::operator-(const Mat3& b) const
 inline Mat3 Mat3::operator-(const Mat3& b) const
 {
 {
 	Mat3 c;
 	Mat3 c;
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		c[i] = (*this)[i] - b[i];
 		c[i] = (*this)[i] - b[i];
 	}
 	}
@@ -204,7 +204,7 @@ inline Mat3 Mat3::operator-(const Mat3& b) const
 // -=
 // -=
 inline Mat3& Mat3::operator-=(const Mat3& b)
 inline Mat3& Mat3::operator-=(const Mat3& b)
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] -= b[i];
 		(*this)[i] -= b[i];
 	}
 	}
@@ -244,9 +244,9 @@ inline Mat3& Mat3::operator*=(const Mat3& b)
 }
 }
 
 
 // ==
 // ==
-inline bool Mat3::operator==(const Mat3& b) const
+inline Bool Mat3::operator==(const Mat3& b) const
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		if(!Math::isZero((*this)[i] - b[i]))
 		if(!Math::isZero((*this)[i] - b[i]))
 		{
 		{
@@ -257,9 +257,9 @@ inline bool Mat3::operator==(const Mat3& b) const
 }
 }
 
 
 // !=
 // !=
-inline bool Mat3::operator!=(const Mat3& b) const
+inline Bool Mat3::operator!=(const Mat3& b) const
 {
 {
-	for(int i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		if(!Math::isZero((*this)[i] - b[i]))
 		if(!Math::isZero((*this)[i] - b[i]))
 		{
 		{
@@ -270,87 +270,87 @@ inline bool Mat3::operator!=(const Mat3& b) const
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-// Operators with float                                                        =
+// Operators with F32                                                        =
 //==============================================================================
 //==============================================================================
 
 
-// 3x3 + float
-inline Mat3 Mat3::operator+(const float f) const
+// 3x3 + F32
+inline Mat3 Mat3::operator+(const F32 f) const
 {
 {
 	Mat3 c;
 	Mat3 c;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		c[i] = (*this)[i] + f;
 		c[i] = (*this)[i] + f;
 	}
 	}
 	return c;
 	return c;
 }
 }
 
 
-// 3x3 += float
-inline Mat3& Mat3::operator+=(const float f)
+// 3x3 += F32
+inline Mat3& Mat3::operator+=(const F32 f)
 {
 {
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] += f;
 		(*this)[i] += f;
 	}
 	}
 	return (*this);
 	return (*this);
 }
 }
 
 
-// 3x3 - float
-inline Mat3 Mat3::operator-(const float f) const
+// 3x3 - F32
+inline Mat3 Mat3::operator-(const F32 f) const
 {
 {
 	Mat3 c;
 	Mat3 c;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		c[i] = (*this)[i] - f;
 		c[i] = (*this)[i] - f;
 	}
 	}
 	return c;
 	return c;
 }
 }
 
 
-// 3x3 -= float
-inline Mat3& Mat3::operator-=(const float f)
+// 3x3 -= F32
+inline Mat3& Mat3::operator-=(const F32 f)
 {
 {
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] -= f;
 		(*this)[i] -= f;
 	}
 	}
 	return (*this);
 	return (*this);
 }
 }
 
 
-// 3x3 * float
-inline Mat3 Mat3::operator*(const float f) const
+// 3x3 * F32
+inline Mat3 Mat3::operator*(const F32 f) const
 {
 {
 	Mat3 c;
 	Mat3 c;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		c[i] = (*this)[i] * f;
 		c[i] = (*this)[i] * f;
 	}
 	}
 	return c;
 	return c;
 }
 }
 
 
-// 3x3 *= float
-inline Mat3& Mat3::operator*=(const float f)
+// 3x3 *= F32
+inline Mat3& Mat3::operator*=(const F32 f)
 {
 {
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] *= f;
 		(*this)[i] *= f;
 	}
 	}
 	return (*this);
 	return (*this);
 }
 }
 
 
-// 3x3 / float
-inline Mat3 Mat3::operator/(const float f) const
+// 3x3 / F32
+inline Mat3 Mat3::operator/(const F32 f) const
 {
 {
 	Mat3 c;
 	Mat3 c;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		c[i] = (*this)[i] / f;
 		c[i] = (*this)[i] / f;
 	}
 	}
 	return c;
 	return c;
 }
 }
 
 
-// 3x3 / float (self)
-inline Mat3& Mat3::operator/=(const float f)
+// 3x3 / F32 (self)
+inline Mat3& Mat3::operator/=(const F32 f)
 {
 {
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		(*this)[i] /= f;
 		(*this)[i] /= f;
 	}
 	}
@@ -431,7 +431,7 @@ inline void Mat3::getColumns(Vec3& a, Vec3& b, Vec3& c) const
 }
 }
 
 
 // setRow
 // setRow
-inline void Mat3::setRow(const size_t i, const Vec3& v)
+inline void Mat3::setRow(const U i, const Vec3& v)
 {
 {
 	(*this)(i, 0) = v.x();
 	(*this)(i, 0) = v.x();
 	(*this)(i, 1) = v.y();
 	(*this)(i, 1) = v.y();
@@ -439,13 +439,13 @@ inline void Mat3::setRow(const size_t i, const Vec3& v)
 }
 }
 
 
 // getRow
 // getRow
-inline Vec3 Mat3::getRow(const size_t i) const
+inline Vec3 Mat3::getRow(const U i) const
 {
 {
 	return Vec3((*this)(i, 0), (*this)(i, 1), (*this)(i, 2));
 	return Vec3((*this)(i, 0), (*this)(i, 1), (*this)(i, 2));
 }
 }
 
 
 // setColumn
 // setColumn
-inline void Mat3::setColumn(const size_t i, const Vec3& v)
+inline void Mat3::setColumn(const U i, const Vec3& v)
 {
 {
 	(*this)(0, i) = v.x();
 	(*this)(0, i) = v.x();
 	(*this)(1, i) = v.y();
 	(*this)(1, i) = v.y();
@@ -453,7 +453,7 @@ inline void Mat3::setColumn(const size_t i, const Vec3& v)
 }
 }
 
 
 // getColumn
 // getColumn
-inline Vec3 Mat3::getColumn(const size_t i) const
+inline Vec3 Mat3::getColumn(const U i) const
 {
 {
 	return Vec3((*this)(0,i), (*this)(1,i), (*this)(2,i));
 	return Vec3((*this)(0,i), (*this)(1,i), (*this)(2,i));
 }
 }
@@ -495,9 +495,9 @@ inline void Mat3::setZAxis(const Vec3& v3)
 }
 }
 
 
 // setRotationX
 // setRotationX
-inline void Mat3::setRotationX(const float rad)
+inline void Mat3::setRotationX(const F32 rad)
 {
 {
-	float sintheta, costheta;
+	F32 sintheta, costheta;
 	Math::sinCos(rad, sintheta, costheta);
 	Math::sinCos(rad, sintheta, costheta);
 
 
 	(*this)(0, 0) = 1.0;
 	(*this)(0, 0) = 1.0;
@@ -512,9 +512,9 @@ inline void Mat3::setRotationX(const float rad)
 }
 }
 
 
 // setRotationY
 // setRotationY
-inline void Mat3::setRotationY(const float rad)
+inline void Mat3::setRotationY(const F32 rad)
 {
 {
-	float sintheta, costheta;
+	F32 sintheta, costheta;
 	Math::sinCos(rad, sintheta, costheta);
 	Math::sinCos(rad, sintheta, costheta);
 
 
 	(*this)(0, 0) = costheta;
 	(*this)(0, 0) = costheta;
@@ -529,9 +529,9 @@ inline void Mat3::setRotationY(const float rad)
 }
 }
 
 
 // loadRotationZ
 // loadRotationZ
-inline void Mat3::setRotationZ(const float rad)
+inline void Mat3::setRotationZ(const F32 rad)
 {
 {
-	float sintheta, costheta;
+	F32 sintheta, costheta;
 	Math::sinCos(rad, sintheta, costheta);
 	Math::sinCos(rad, sintheta, costheta);
 
 
 	(*this)(0, 0) = costheta;
 	(*this)(0, 0) = costheta;
@@ -546,7 +546,7 @@ inline void Mat3::setRotationZ(const float rad)
 }
 }
 
 
 // rotateXAxis
 // rotateXAxis
-inline void Mat3::rotateXAxis(const float rad)
+inline void Mat3::rotateXAxis(const F32 rad)
 {
 {
 	// If we analize the mat3 we can extract the 3 unit vectors rotated by the 
 	// If we analize the mat3 we can extract the 3 unit vectors rotated by the 
 	// mat3. The 3 rotated vectors are in mat's columns. This means that:
 	// mat3. The 3 rotated vectors are in mat's columns. This means that:
@@ -554,7 +554,7 @@ inline void Mat3::rotateXAxis(const float rad)
 	// vector (aka x axis) but from the vector from colomn 0
 	// vector (aka x axis) but from the vector from colomn 0
 	// NOTE: See the clean code from < r664
 	// NOTE: See the clean code from < r664
 
 
-	float sina, cosa;
+	F32 sina, cosa;
 	Math::sinCos(rad, sina, cosa);
 	Math::sinCos(rad, sina, cosa);
 
 
 	// zAxis = zAxis*cosa - yAxis*sina;
 	// zAxis = zAxis*cosa - yAxis*sina;
@@ -563,7 +563,7 @@ inline void Mat3::rotateXAxis(const float rad)
 	(*this)(2, 2) = (*this)(2, 2) * cosa - (*this)(2, 1) * sina;
 	(*this)(2, 2) = (*this)(2, 2) * cosa - (*this)(2, 1) * sina;
 
 
 	// zAxis.normalize();
 	// zAxis.normalize();
-	float len = sqrt((*this)(0, 2) * (*this)(0, 2)
+	F32 len = sqrt((*this)(0, 2) * (*this)(0, 2)
 		+ (*this)(1, 2) * (*this)(1, 2) + (*this)(2, 2) * (*this)(2, 2));
 		+ (*this)(1, 2) * (*this)(1, 2) + (*this)(2, 2) * (*this)(2, 2));
 	(*this)(0, 2) /= len;
 	(*this)(0, 2) /= len;
 	(*this)(1, 2) /= len;
 	(*this)(1, 2) /= len;
@@ -581,10 +581,10 @@ inline void Mat3::rotateXAxis(const float rad)
 }
 }
 
 
 // rotateYAxis
 // rotateYAxis
-inline void Mat3::rotateYAxis(const float rad)
+inline void Mat3::rotateYAxis(const F32 rad)
 {
 {
 	// NOTE: See the clean code from < r664
 	// NOTE: See the clean code from < r664
-	float sina, cosa;
+	F32 sina, cosa;
 	Math::sinCos(rad, sina, cosa);
 	Math::sinCos(rad, sina, cosa);
 
 
 	// zAxis = zAxis*cosa + xAxis*sina;
 	// zAxis = zAxis*cosa + xAxis*sina;
@@ -593,7 +593,7 @@ inline void Mat3::rotateYAxis(const float rad)
 	(*this)(2, 2) = (*this)(2, 2) * cosa + (*this)(2, 0) * sina;
 	(*this)(2, 2) = (*this)(2, 2) * cosa + (*this)(2, 0) * sina;
 
 
 	// zAxis.normalize();
 	// zAxis.normalize();
-	float len = sqrt((*this)(0, 2) * (*this)(0, 2)
+	F32 len = sqrt((*this)(0, 2) * (*this)(0, 2)
 		+ (*this)(1, 2) * (*this)(1, 2) + (*this)(2, 2) * (*this)(2, 2));
 		+ (*this)(1, 2) * (*this)(1, 2) + (*this)(2, 2) * (*this)(2, 2));
 	(*this)(0, 2) /= len;
 	(*this)(0, 2) /= len;
 	(*this)(1, 2) /= len;
 	(*this)(1, 2) /= len;
@@ -609,10 +609,10 @@ inline void Mat3::rotateYAxis(const float rad)
 }
 }
 
 
 // rotateZAxis
 // rotateZAxis
-inline void Mat3::rotateZAxis(const float rad)
+inline void Mat3::rotateZAxis(const F32 rad)
 {
 {
 	// NOTE: See the clean code from < r664
 	// NOTE: See the clean code from < r664
-	float sina, cosa;
+	F32 sina, cosa;
 	Math::sinCos(rad, sina, cosa);
 	Math::sinCos(rad, sina, cosa);
 
 
 	// xAxis = xAxis*cosa + yAxis*sina;
 	// xAxis = xAxis*cosa + yAxis*sina;
@@ -621,7 +621,7 @@ inline void Mat3::rotateZAxis(const float rad)
 	(*this)(2, 0) = (*this)(2, 0) * cosa + (*this)(2, 1) * sina;
 	(*this)(2, 0) = (*this)(2, 0) * cosa + (*this)(2, 1) * sina;
 
 
 	// xAxis.normalize();
 	// xAxis.normalize();
-	float len = sqrt((*this)(0, 0) * (*this)(0, 0)
+	F32 len = sqrt((*this)(0, 0) * (*this)(0, 0)
 		+ (*this)(1, 0) * (*this)(1, 0) + (*this)(2, 0) * (*this)(2, 0));
 		+ (*this)(1, 0) * (*this)(1, 0) + (*this)(2, 0) * (*this)(2, 0));
 	(*this)(0, 0) /= len;
 	(*this)(0, 0) /= len;
 	(*this)(1, 0) /= len;
 	(*this)(1, 0) /= len;
@@ -639,7 +639,7 @@ inline void Mat3::rotateZAxis(const float rad)
 // transpose
 // transpose
 inline void Mat3::transpose()
 inline void Mat3::transpose()
 {
 {
-	float temp = (*this)(0, 1);
+	F32 temp = (*this)(0, 1);
 	(*this)(0, 1) = (*this)(1, 0);
 	(*this)(0, 1) = (*this)(1, 0);
 	(*this)(1, 0) = temp;
 	(*this)(1, 0) = temp;
 	temp = (*this)(0, 2);
 	temp = (*this)(0, 2);
@@ -685,7 +685,7 @@ inline void Mat3::reorthogonalize()
 }
 }
 
 
 // Determinant
 // Determinant
-inline float Mat3::getDet() const
+inline F32 Mat3::getDet() const
 {
 {
 	// For the accurate method see < r664
 	// For the accurate method see < r664
 	return (*this)(0, 0) * ((*this)(1, 1) * (*this)(2, 2)
 	return (*this)(0, 0) * ((*this)(1, 1) * (*this)(2, 2)
@@ -701,19 +701,19 @@ inline Mat3 Mat3::getInverse() const
 	Mat3 r;
 	Mat3 r;
 
 
 	// compute determinant
 	// compute determinant
-	float cofactor0 = (*this)(1, 1) * (*this)(2, 2)
+	F32 cofactor0 = (*this)(1, 1) * (*this)(2, 2)
 		- (*this)(1, 2) * (*this)(2, 1);
 		- (*this)(1, 2) * (*this)(2, 1);
-	float cofactor3 = (*this)(0, 2) * (*this)(2, 1)
+	F32 cofactor3 = (*this)(0, 2) * (*this)(2, 1)
 		- (*this)(0, 1) * (*this)(2, 2);
 		- (*this)(0, 1) * (*this)(2, 2);
-	float cofactor6 = (*this)(0, 1) * (*this)(1, 2)
+	F32 cofactor6 = (*this)(0, 1) * (*this)(1, 2)
 		- (*this)(0, 2) * (*this)(1, 1);
 		- (*this)(0, 2) * (*this)(1, 1);
-	float det = (*this)(0, 0) * cofactor0 + (*this)(1, 0) * cofactor3
+	F32 det = (*this)(0, 0) * cofactor0 + (*this)(1, 0) * cofactor3
 		+ (*this)(2, 0) * cofactor6;
 		+ (*this)(2, 0) * cofactor6;
 
 
 	ANKI_ASSERT(!Math::isZero(det)); // Cannot invert det == 0
 	ANKI_ASSERT(!Math::isZero(det)); // Cannot invert det == 0
 
 
 	// create adjoint matrix and multiply by 1/det to get inverse
 	// create adjoint matrix and multiply by 1/det to get inverse
-	float invDet = 1.0 / det;
+	F32 invDet = 1.0 / det;
 	r(0, 0) = invDet * cofactor0;
 	r(0, 0) = invDet * cofactor0;
 	r(0, 1) = invDet * cofactor3;
 	r(0, 1) = invDet * cofactor3;
 	r(0, 2) = invDet * cofactor6;
 	r(0, 2) = invDet * cofactor6;
@@ -766,39 +766,39 @@ inline const Mat3& Mat3::getIdentity()
 // Friends                                                                     =
 // Friends                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-// float + 3x3
-inline Mat3 operator+(const float f, const Mat3& m3)
+// F32 + 3x3
+inline Mat3 operator+(const F32 f, const Mat3& m3)
 {
 {
 	return m3 + f;
 	return m3 + f;
 }
 }
 
 
-// float - 3x3
-inline Mat3 operator-(const float f, const Mat3& m3)
+// F32 - 3x3
+inline Mat3 operator-(const F32 f, const Mat3& m3)
 {
 {
 	Mat3 out;
 	Mat3 out;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		out[i] = f - m3[i];
 		out[i] = f - m3[i];
 	}
 	}
 	return out;
 	return out;
 }
 }
 
 
-// float * 3x3
-inline Mat3 operator*(const float f, const Mat3& m3)
+// F32 * 3x3
+inline Mat3 operator*(const F32 f, const Mat3& m3)
 {
 {
 	Mat3 out;
 	Mat3 out;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		out[i] = f * m3[i];
 		out[i] = f * m3[i];
 	}
 	}
 	return out;
 	return out;
 }
 }
 
 
-// float / 3x3
-inline Mat3 operator/(const float f, const Mat3& m3)
+// F32 / 3x3
+inline Mat3 operator/(const F32 f, const Mat3& m3)
 {
 {
 	Mat3 out;
 	Mat3 out;
-	for(size_t i = 0; i < 9; i++)
+	for(U i = 0; i < 9; i++)
 	{
 	{
 		out[i] = f / m3[i];
 		out[i] = f / m3[i];
 	}
 	}
@@ -808,9 +808,9 @@ inline Mat3 operator/(const float f, const Mat3& m3)
 // Print
 // Print
 inline std::ostream& operator<<(std::ostream& s, const Mat3& m)
 inline std::ostream& operator<<(std::ostream& s, const Mat3& m)
 {
 {
-	for(int i = 0; i < 3; i++)
+	for(U i = 0; i < 3; i++)
 	{
 	{
-		for(int j = 0; j < 3; j++)
+		for(U j = 0; j < 3; j++)
 		{
 		{
 			s << m(i, j) << ' ';
 			s << m(i, j) << ' ';
 		}
 		}

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

@@ -17,32 +17,32 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Mat4() {}
 	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[]);
+	explicit Mat4(const F32 f);
+	explicit Mat4(const F32 m00, const F32 m01, const F32 m02,
+		const F32 m03, const F32 m10, const F32 m11,
+		const F32 m12, const F32 m13, const F32 m20,
+		const F32 m21, const F32 m22, const F32 m23,
+		const F32 m30, const F32 m31, const F32 m32,
+		const F32 m33);
+	explicit Mat4(const F32 arr[]);
 	Mat4(const Mat4& b);
 	Mat4(const Mat4& b);
 	explicit Mat4(const Mat3& m3);
 	explicit Mat4(const Mat3& m3);
 	explicit Mat4(const Vec3& v);
 	explicit Mat4(const Vec3& v);
 	explicit Mat4(const Vec4& v);
 	explicit Mat4(const Vec4& v);
 	explicit Mat4(const Vec3& transl, const Mat3& rot);
 	explicit Mat4(const Vec3& transl, const Mat3& rot);
-	explicit Mat4(const Vec3& transl, const Mat3& rot, const float scale);
+	explicit Mat4(const Vec3& transl, const Mat3& rot, const F32 scale);
 	explicit Mat4(const Transform& t);
 	explicit Mat4(const Transform& t);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @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;
+	F32& operator()(const U i, const U j);
+	const F32& operator()(const U i, const U j) const;
+	F32& operator[](const U i);
+	const F32& operator[](const U i) const;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	__m128& getMm(const size_t i);
-	const __m128& getMm(const size_t i) const;
+	__m128& getMm(const U i);
+	const __m128& getMm(const U i) const;
 #endif
 #endif
 	/// @}
 	/// @}
 
 
@@ -57,20 +57,20 @@ public:
 	Mat4& operator*=(const Mat4& b);
 	Mat4& operator*=(const Mat4& b);
 	Mat4 operator/(const Mat4& b) const;
 	Mat4 operator/(const Mat4& b) const;
 	Mat4& operator/=(const Mat4& b);
 	Mat4& operator/=(const Mat4& b);
-	bool operator==(const Mat4& b) const;
-	bool operator!=(const Mat4& b) const;
+	Bool operator==(const Mat4& b) const;
+	Bool operator!=(const Mat4& b) const;
 	/// @}
 	/// @}
 
 
-	/// @name Operators with float
+	/// @name Operators with F32
 	/// @{
 	/// @{
-	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);
+	Mat4  operator+(const F32 f) const;
+	Mat4& operator+=(const F32 f);
+	Mat4  operator-(const F32 f) const;
+	Mat4& operator-=(const F32 f);
+	Mat4  operator*(const F32 f) const;
+	Mat4& operator*=(const F32 f);
+	Mat4  operator/(const F32 f) const;
+	Mat4& operator/=(const F32 f);
 	/// @}
 	/// @}
 
 
 	/// @name Operators with other types
 	/// @name Operators with other types
@@ -82,10 +82,10 @@ public:
 	/// @{
 	/// @{
 	void setRows(const Vec4& a, const Vec4& b, const Vec4& c,
 	void setRows(const Vec4& a, const Vec4& b, const Vec4& c,
 		const Vec4& d);
 		const Vec4& d);
-	void setRow(const size_t i, const Vec4& v);
+	void setRow(const U i, const Vec4& v);
 	void setColumns(const Vec4& a, const Vec4& b, const Vec4& c,
 	void setColumns(const Vec4& a, const Vec4& b, const Vec4& c,
 		const Vec4& d);
 		const Vec4& d);
-	void setColumn(const size_t i, const Vec4& v);
+	void setColumn(const U i, const Vec4& v);
 	void setRotationPart(const Mat3& m3);
 	void setRotationPart(const Mat3& m3);
 	void setTranslationPart(const Vec4& v4);
 	void setTranslationPart(const Vec4& v4);
 	Mat3 getRotationPart() const;
 	Mat3 getRotationPart() const;
@@ -93,13 +93,13 @@ public:
 	Vec3 getTranslationPart() const;
 	Vec3 getTranslationPart() const;
 	void transpose();
 	void transpose();
 	Mat4 getTransposed() const;
 	Mat4 getTransposed() const;
-	float getDet() const;
+	F32 getDet() const;
 	Mat4 getInverse() const; ///< Invert using Cramer's rule
 	Mat4 getInverse() const; ///< Invert using Cramer's rule
 	void invert(); ///< See getInverse
 	void invert(); ///< See getInverse
 	/// If we suppose this matrix represents a transformation, return the
 	/// If we suppose this matrix represents a transformation, return the
 	/// inverted transformation
 	/// inverted transformation
 	Mat4 getInverseTransformation() const;
 	Mat4 getInverseTransformation() const;
-	Mat4 lerp(const Mat4& b, float t) const;
+	Mat4 lerp(const Mat4& b, F32 t) const;
 	void setIdentity();
 	void setIdentity();
 	/// 12 muls, 27 adds. Something like m4 = m0 * m1 but without touching
 	/// 12 muls, 27 adds. Something like m4 = m0 * m1 but without touching
 	/// the 4rth row and allot faster
 	/// the 4rth row and allot faster
@@ -110,10 +110,10 @@ public:
 
 
 	/// @name Friends
 	/// @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 Mat4 operator+(const F32 f, const Mat4& m4);
+	friend Mat4 operator-(const F32 f, const Mat4& m4);
+	friend Mat4 operator*(const F32 f, const Mat4& m4);
+	friend Mat4 operator/(const F32 f, const Mat4& m4);
 	friend std::ostream& operator<<(std::ostream& s, const Mat4& m);
 	friend std::ostream& operator<<(std::ostream& s, const Mat4& m);
 	/// @}
 	/// @}
 
 
@@ -122,10 +122,10 @@ private:
 	/// @{
 	/// @{
 	union
 	union
 	{
 	{
-		std::array<float, 16> arr1;
-		std::array<std::array<float, 4>, 4> arr2;
-		float carr1[16]; ///< For gdb
-		float carr2[4][4]; ///< For gdb
+		std::array<F32, 16> arr1;
+		std::array<std::array<F32, 4>, 4> arr2;
+		F32 carr1[16]; ///< For gdb
+		F32 carr2[4][4]; ///< For gdb
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 		std::array<__m128, 4> arrMm;
 		std::array<__m128, 4> arrMm;
 #endif
 #endif
@@ -134,7 +134,7 @@ private:
 };
 };
 /// @}
 /// @}
 
 
-static_assert(sizeof(Mat4) == sizeof(float) * 4 * 4, "Incorrect size");
+static_assert(sizeof(Mat4) == sizeof(F32) * 4 * 4, "Incorrect size");
 
 
 } // end namespace
 } // end namespace
 
 

+ 103 - 99
include/anki/math/Mat4.inl.h

@@ -10,50 +10,50 @@ namespace anki {
 inline Mat4::Mat4(const Mat4& b)
 inline Mat4::Mat4(const Mat4& b)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = b.arrMm[i];
 		arrMm[i] = b.arrMm[i];
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] = b[i];
 		(*this)[i] = b[i];
 	}
 	}
 #endif
 #endif
 }
 }
 
 
-// float
-inline Mat4::Mat4(const float f)
+// F32
+inline Mat4::Mat4(const F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_set1_ps(f);
 		arrMm[i] = _mm_set1_ps(f);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] = f;
 		(*this)[i] = f;
 	}
 	}
 #endif
 #endif
 }
 }
 
 
-// float[]
-inline Mat4::Mat4(const float arr_[])
+// F32[]
+inline Mat4::Mat4(const F32 arr_[])
 {
 {
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] = arr_[i];
 		(*this)[i] = arr_[i];
 	}
 	}
 }
 }
 
 
-// many floats
-inline Mat4::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)
+// many F32s
+inline Mat4::Mat4(const F32 m00, const F32 m01, const F32 m02,
+	const F32 m03, const F32 m10, const F32 m11,
+	const F32 m12, const F32 m13, const F32 m20,
+	const F32 m21, const F32 m22, const F32 m23,
+	const F32 m30, const F32 m31, const F32 m32,
+	const F32 m33)
 {
 {
 	(*this)(0, 0) = m00;
 	(*this)(0, 0) = m00;
 	(*this)(0, 1) = m01;
 	(*this)(0, 1) = m01;
@@ -79,14 +79,18 @@ inline Mat4::Mat4(const Mat3& m3)
 	(*this)(0, 0) = m3(0, 0);
 	(*this)(0, 0) = m3(0, 0);
 	(*this)(0, 1) = m3(0, 1);
 	(*this)(0, 1) = m3(0, 1);
 	(*this)(0, 2) = m3(0, 2);
 	(*this)(0, 2) = m3(0, 2);
+	(*this)(0, 3) = 0.0;
 	(*this)(1, 0) = m3(1, 0);
 	(*this)(1, 0) = m3(1, 0);
 	(*this)(1, 1) = m3(1, 1);
 	(*this)(1, 1) = m3(1, 1);
 	(*this)(1, 2) = m3(1, 2);
 	(*this)(1, 2) = m3(1, 2);
+	(*this)(1, 3) = 0.0;
 	(*this)(2, 0) = m3(2, 0);
 	(*this)(2, 0) = m3(2, 0);
 	(*this)(2, 1) = m3(2, 1);
 	(*this)(2, 1) = m3(2, 1);
 	(*this)(2, 2) = m3(2, 2);
 	(*this)(2, 2) = m3(2, 2);
-	(*this)(3, 0) = (*this)(3, 1) = (*this)(3, 2) = (*this)(0, 3) =
-		(*this)(1, 3) = (*this)(2, 3) = 0.0;
+	(*this)(2, 3) = 0.0;
+	(*this)(3, 0) = 0.0;
+	(*this)(3, 1) = 0.0;
+	(*this)(3, 2) = 0.0;
 	(*this)(3, 3) = 1.0;
 	(*this)(3, 3) = 1.0;
 }
 }
 
 
@@ -141,8 +145,8 @@ inline Mat4::Mat4(const Vec3& transl, const Mat3& rot)
 	(*this)(3, 3) = 1.0;
 	(*this)(3, 3) = 1.0;
 }
 }
 
 
-// Vec3, Mat3, float
-inline Mat4::Mat4(const Vec3& translate, const Mat3& rotate, const float scale)
+// Vec3, Mat3, F32
+inline Mat4::Mat4(const Vec3& translate, const Mat3& rotate, const F32 scale)
 {
 {
 	if(!Math::isZero(scale - 1.0))
 	if(!Math::isZero(scale - 1.0))
 	{
 	{
@@ -169,33 +173,33 @@ inline Mat4::Mat4(const Transform& t)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float& Mat4::operator()(const size_t i, const size_t j)
+inline F32& Mat4::operator()(const U i, const U j)
 {
 {
 	return arr2[i][j];
 	return arr2[i][j];
 }
 }
 
 
-inline const float& Mat4::operator()(const size_t i, const size_t j) const
+inline const F32& Mat4::operator()(const U i, const U j) const
 {
 {
 	return arr2[i][j];
 	return arr2[i][j];
 }
 }
 
 
-inline float& Mat4::operator[](const size_t i)
+inline F32& Mat4::operator[](const U i)
 {
 {
 	return arr1[i];
 	return arr1[i];
 }
 }
 
 
-inline const float& Mat4::operator[](const size_t i) const
+inline const F32& Mat4::operator[](const U i) const
 {
 {
 	return arr1[i];
 	return arr1[i];
 }
 }
 
 
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-inline const __m128& Mat4::getMm(const size_t i) const
+inline const __m128& Mat4::getMm(const U i) const
 {
 {
 	return arrMm[i];
 	return arrMm[i];
 }
 }
 
 
-inline __m128& Mat4::getMm(const size_t i)
+inline __m128& Mat4::getMm(const U i)
 {
 {
 	return arrMm[i];
 	return arrMm[i];
 }
 }
@@ -209,12 +213,12 @@ inline __m128& Mat4::getMm(const size_t i)
 inline Mat4& Mat4::operator=(const Mat4& b)
 inline Mat4& Mat4::operator=(const Mat4& b)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = b.arrMm[i];
 		arrMm[i] = b.arrMm[i];
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] = b[i];
 		(*this)[i] = b[i];
 	}
 	}
@@ -227,12 +231,12 @@ inline Mat4 Mat4::operator+(const Mat4& b) const
 {
 {
 	Mat4 c;
 	Mat4 c;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		c.arrMm[i] = _mm_add_ps(arrMm[i], b.arrMm[i]);
 		c.arrMm[i] = _mm_add_ps(arrMm[i], b.arrMm[i]);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		c[i] = (*this)[i] + b[i];
 		c[i] = (*this)[i] + b[i];
 	}
 	}
@@ -244,12 +248,12 @@ inline Mat4 Mat4::operator+(const Mat4& b) const
 inline Mat4& Mat4::operator+=(const Mat4& b)
 inline Mat4& Mat4::operator+=(const Mat4& b)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_add_ps(arrMm[i], b.arrMm[i]);
 		arrMm[i] = _mm_add_ps(arrMm[i], b.arrMm[i]);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] += b[i];
 		(*this)[i] += b[i];
 	}
 	}
@@ -262,12 +266,12 @@ inline Mat4 Mat4::operator-(const Mat4& b) const
 {
 {
 	Mat4 c;
 	Mat4 c;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		c.arrMm[i] = _mm_sub_ps(arrMm[i], b.arrMm[i]);
 		c.arrMm[i] = _mm_sub_ps(arrMm[i], b.arrMm[i]);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		c[i] = (*this)[i] - b[i];
 		c[i] = (*this)[i] - b[i];
 	}
 	}
@@ -279,12 +283,12 @@ inline Mat4 Mat4::operator-(const Mat4& b) const
 inline Mat4& Mat4::operator-=(const Mat4& b)
 inline Mat4& Mat4::operator-=(const Mat4& b)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_sub_ps(arrMm[i], b.arrMm[i]);
 		arrMm[i] = _mm_sub_ps(arrMm[i], b.arrMm[i]);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] -= b[i];
 		(*this)[i] -= b[i];
 	}
 	}
@@ -299,17 +303,17 @@ inline Mat4 Mat4::operator*(const Mat4& b) const
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	Mat4 t(b);
 	Mat4 t(b);
 	t.transpose();
 	t.transpose();
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
-		for(int j = 0; j < 4; j++)
+		for(U j = 0; j < 4; j++)
 		{
 		{
 			_mm_store_ss(&c(i, j), _mm_dp_ps(arrMm[i], t.arrMm[j], 0xF1));
 			_mm_store_ss(&c(i, j), _mm_dp_ps(arrMm[i], t.arrMm[j], 0xF1));
 		}
 		}
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
-		for(int j = 0; j < 4; j++)
+		for(U j = 0; j < 4; j++)
 		{
 		{
 			c(i, j) = (*this)(i, 0) * b(0, j) + (*this)(i, 1) * b(1, j) 
 			c(i, j) = (*this)(i, 0) * b(0, j) + (*this)(i, 1) * b(1, j) 
 				+ (*this)(i, 2) * b(2, j) + (*this)(i, 3) * b(3, j);
 				+ (*this)(i, 2) * b(2, j) + (*this)(i, 3) * b(3, j);
@@ -327,9 +331,9 @@ inline Mat4& Mat4::operator*=(const Mat4& b)
 }
 }
 
 
 // ==
 // ==
-inline bool Mat4::operator==(const Mat4& b) const
+inline Bool Mat4::operator==(const Mat4& b) const
 {
 {
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		if(!Math::isZero((*this)[i] - b[i]))
 		if(!Math::isZero((*this)[i] - b[i]))
 		{
 		{
@@ -340,9 +344,9 @@ inline bool Mat4::operator==(const Mat4& b) const
 }
 }
 
 
 // !=
 // !=
-inline bool Mat4::operator!=(const Mat4& b) const
+inline Bool Mat4::operator!=(const Mat4& b) const
 {
 {
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		if(!Math::isZero((*this)[i]-b[i]))
 		if(!Math::isZero((*this)[i]-b[i]))
 		{
 		{
@@ -353,22 +357,22 @@ inline bool Mat4::operator!=(const Mat4& b) const
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-// Operators with float                                                        =
+// Operators with F32                                                        =
 //==============================================================================
 //==============================================================================
 
 
-// 4x4 + float
-inline Mat4 Mat4::operator+(const float f) const
+// 4x4 + F32
+inline Mat4 Mat4::operator+(const F32 f) const
 {
 {
 	Mat4 c;
 	Mat4 c;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		c.arrMm[i] = _mm_add_ps(arrMm[i], mm);
 		c.arrMm[i] = _mm_add_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		c[i] = (*this)[i] + f;
 		c[i] = (*this)[i] + f;
 	}
 	}
@@ -376,18 +380,18 @@ inline Mat4 Mat4::operator+(const float f) const
 	return c;
 	return c;
 }
 }
 
 
-// 4x4 += float
-inline Mat4& Mat4::operator+=(const float f)
+// 4x4 += F32
+inline Mat4& Mat4::operator+=(const F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_add_ps(arrMm[i], mm);
 		arrMm[i] = _mm_add_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] += f;
 		(*this)[i] += f;
 	}
 	}
@@ -395,19 +399,19 @@ inline Mat4& Mat4::operator+=(const float f)
 	return (*this);
 	return (*this);
 }
 }
 
 
-// 4x4 - float
-inline Mat4 Mat4::operator-(const float f) const
+// 4x4 - F32
+inline Mat4 Mat4::operator-(const F32 f) const
 {
 {
 	Mat4 r;
 	Mat4 r;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		r.arrMm[i] = _mm_sub_ps(arrMm[i], mm);
 		r.arrMm[i] = _mm_sub_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		r[i] = (*this)[i] - f;
 		r[i] = (*this)[i] - f;
 	}
 	}
@@ -415,18 +419,18 @@ inline Mat4 Mat4::operator-(const float f) const
 	return r;
 	return r;
 }
 }
 
 
-// 4x4 -= float
-inline Mat4& Mat4::operator-=(const float f)
+// 4x4 -= F32
+inline Mat4& Mat4::operator-=(const F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_sub_ps(arrMm[i], mm);
 		arrMm[i] = _mm_sub_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] -= f;
 		(*this)[i] -= f;
 	}
 	}
@@ -434,19 +438,19 @@ inline Mat4& Mat4::operator-=(const float f)
 	return (*this);
 	return (*this);
 }
 }
 
 
-// 4x4 * float
-inline Mat4 Mat4::operator*(const float f) const
+// 4x4 * F32
+inline Mat4 Mat4::operator*(const F32 f) const
 {
 {
 	Mat4 r;
 	Mat4 r;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		r.arrMm[i] = _mm_mul_ps(arrMm[i], mm);
 		r.arrMm[i] = _mm_mul_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		r[i] = (*this)[i] * f;
 		r[i] = (*this)[i] * f;
 	}
 	}
@@ -454,18 +458,18 @@ inline Mat4 Mat4::operator*(const float f) const
 	return r;
 	return r;
 }
 }
 
 
-// 4x4 *= float
-inline Mat4& Mat4::operator*=(const float f)
+// 4x4 *= F32
+inline Mat4& Mat4::operator*=(const F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_mul_ps(arrMm[i], mm);
 		arrMm[i] = _mm_mul_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] *= f;
 		(*this)[i] *= f;
 	}
 	}
@@ -473,19 +477,19 @@ inline Mat4& Mat4::operator*=(const float f)
 	return (*this);
 	return (*this);
 }
 }
 
 
-// 4x4 / float
-inline Mat4 Mat4::operator/(const float f) const
+// 4x4 / F32
+inline Mat4 Mat4::operator/(const F32 f) const
 {
 {
 	Mat4 r;
 	Mat4 r;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		r.arrMm[i] = _mm_div_ps(arrMm[i], mm);
 		r.arrMm[i] = _mm_div_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		r[i] = (*this)[i] / f;
 		r[i] = (*this)[i] / f;
 	}
 	}
@@ -493,18 +497,18 @@ inline Mat4 Mat4::operator/(const float f) const
 	return r;
 	return r;
 }
 }
 
 
-// 4x4 /= float
-inline Mat4& Mat4::operator/=(const float f)
+// 4x4 /= F32
+inline Mat4& Mat4::operator/=(const F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		arrMm[i] = _mm_div_ps(arrMm[i], mm);
 		arrMm[i] = _mm_div_ps(arrMm[i], mm);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		(*this)[i] /= f;
 		(*this)[i] /= f;
 	}
 	}
@@ -521,7 +525,7 @@ inline Vec4 Mat4::operator*(const Vec4& b) const
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	Vec4 v;
 	Vec4 v;
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		_mm_store_ss(&v[i], _mm_dp_ps(arrMm[i], b.getMm(), 0xF1));
 		_mm_store_ss(&v[i], _mm_dp_ps(arrMm[i], b.getMm(), 0xF1));
 	}
 	}
@@ -579,7 +583,7 @@ inline void Mat4::setRows(const Vec4& a, const Vec4& b, const Vec4& c,
 }
 }
 
 
 // setRow
 // setRow
-inline void Mat4::setRow(const size_t i, const Vec4& v)
+inline void Mat4::setRow(const U i, const Vec4& v)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	arrMm[i] = v.getMm();
 	arrMm[i] = v.getMm();
@@ -614,7 +618,7 @@ inline void Mat4::setColumns(const Vec4& a, const Vec4& b, const Vec4& c,
 }
 }
 
 
 // setColumn
 // setColumn
-inline void Mat4::setColumn(const size_t i, const Vec4& v)
+inline void Mat4::setColumn(const U i, const Vec4& v)
 {
 {
 	(*this)(0, i) = v.x();
 	(*this)(0, i) = v.x();
 	(*this)(1, i) = v.y();
 	(*this)(1, i) = v.y();
@@ -628,7 +632,7 @@ inline void Mat4::transpose()
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	_MM_TRANSPOSE4_PS(arrMm[0], arrMm[1], arrMm[2], arrMm[3]);
 	_MM_TRANSPOSE4_PS(arrMm[0], arrMm[1], arrMm[2], arrMm[3]);
 #else
 #else
-	float tmp = (*this)(0, 1);
+	F32 tmp = (*this)(0, 1);
 	(*this)(0, 1) = (*this)(1, 0);
 	(*this)(0, 1) = (*this)(1, 0);
 	(*this)(1, 0) = tmp;
 	(*this)(1, 0) = tmp;
 	tmp = (*this)(0, 2);
 	tmp = (*this)(0, 2);
@@ -741,7 +745,7 @@ inline const Mat4& Mat4::getZero()
 }
 }
 
 
 // Determinant
 // Determinant
-inline float Mat4::getDet() const
+inline F32 Mat4::getDet() const
 {
 {
 	const Mat4& t = *this;
 	const Mat4& t = *this;
 	return t(0, 3) * t(1, 2) * t(2, 1) * t(3, 0) 
 	return t(0, 3) * t(1, 2) * t(2, 1) * t(3, 0) 
@@ -773,7 +777,7 @@ inline float Mat4::getDet() const
 // getInverse
 // getInverse
 inline Mat4 Mat4::getInverse() const
 inline Mat4 Mat4::getInverse() const
 {
 {
-	std::array<float, 12> tmp;
+	std::array<F32, 12> tmp;
 	const Mat4& in = (*this);
 	const Mat4& in = (*this);
 	Mat4 m4;
 	Mat4 m4;
 
 
@@ -837,7 +841,7 @@ inline Mat4 Mat4::getInverse() const
 	m4(3, 3) =  tmp[10] * in(2, 2) + tmp[4] * in(0, 2) + tmp[9] * in(1, 2);
 	m4(3, 3) =  tmp[10] * in(2, 2) + tmp[4] * in(0, 2) + tmp[9] * in(1, 2);
 	m4(3, 3) -= tmp[8] * in(1, 2) + tmp[11] * in(2, 2) + tmp[5] * in(0, 2);
 	m4(3, 3) -= tmp[8] * in(1, 2) + tmp[11] * in(2, 2) + tmp[5] * in(0, 2);
 
 
-	float det = in(0, 0) * m4(0, 0) + in(1, 0) * m4(0, 1) 
+	F32 det = in(0, 0) * m4(0, 0) + in(1, 0) * m4(0, 1) 
 		+ in(2, 0) * m4(0, 2) + in(3, 0) * m4(0, 3);
 		+ in(2, 0) * m4(0, 2) + in(3, 0) * m4(0, 3);
 
 
 	ANKI_ASSERT(!Math::isZero(det)); // Cannot invert, det == 0
 	ANKI_ASSERT(!Math::isZero(det)); // Cannot invert, det == 0
@@ -862,7 +866,7 @@ inline Mat4 Mat4::getInverseTransformation() const
 }
 }
 
 
 // lerp
 // lerp
-inline Mat4 Mat4::lerp(const Mat4& b, const float t) const
+inline Mat4 Mat4::lerp(const Mat4& b, const F32 t) const
 {
 {
 	return ((*this) * (1.0 - t)) + (b * t);
 	return ((*this) * (1.0 - t)) + (b * t);
 }
 }
@@ -913,25 +917,25 @@ inline Mat4 Mat4::combineTransformations(const Mat4& m0, const Mat4& m1)
 // Friends                                                                     =
 // Friends                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-// float + 4x4
-inline Mat4 operator+(const float f, const Mat4& m4)
+// F32 + 4x4
+inline Mat4 operator+(const F32 f, const Mat4& m4)
 {
 {
 	return m4 + f;
 	return m4 + f;
 }
 }
 
 
-// float - 4x4
-inline Mat4 operator-(const float f, const Mat4& m4)
+// F32 - 4x4
+inline Mat4 operator-(const F32 f, const Mat4& m4)
 {
 {
 	Mat4 r;
 	Mat4 r;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		r.arrMm[i] = _mm_sub_ps(mm, m4.arrMm[i]);
 		r.arrMm[i] = _mm_sub_ps(mm, m4.arrMm[i]);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		r[i] = f - m4[i];
 		r[i] = f - m4[i];
 	}
 	}
@@ -939,25 +943,25 @@ inline Mat4 operator-(const float f, const Mat4& m4)
 	return r;
 	return r;
 }
 }
 
 
-// float * 4x4
-inline Mat4 operator*(const float f, const Mat4& m4)
+// F32 * 4x4
+inline Mat4 operator*(const F32 f, const Mat4& m4)
 {
 {
 	return m4 * f;
 	return m4 * f;
 }
 }
 
 
-// float / 4x4
-inline Mat4 operator/(const float f, const Mat4& m4)
+// F32 / 4x4
+inline Mat4 operator/(const F32 f, const Mat4& m4)
 {
 {
 	Mat4 r;
 	Mat4 r;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm;
 	__m128 mm;
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
 		r.arrMm[i] = _mm_div_ps(mm, m4.arrMm[i]);
 		r.arrMm[i] = _mm_div_ps(mm, m4.arrMm[i]);
 	}
 	}
 #else
 #else
-	for(int i = 0; i < 16; i++)
+	for(U i = 0; i < 16; i++)
 	{
 	{
 		r[i] = f / m4[i];
 		r[i] = f / m4[i];
 	}
 	}
@@ -968,9 +972,9 @@ inline Mat4 operator/(const float f, const Mat4& m4)
 // Print
 // Print
 inline std::ostream& operator<<(std::ostream& s, const Mat4& m)
 inline std::ostream& operator<<(std::ostream& s, const Mat4& m)
 {
 {
-	for(int i = 0; i < 4; i++)
+	for(U i = 0; i < 4; i++)
 	{
 	{
-		for(int j = 0; j < 4; j++)
+		for(U j = 0; j < 4; j++)
 		{
 		{
 			s << m(i, j) << ' ';
 			s << m(i, j) << ' ';
 		}
 		}

+ 14 - 14
include/anki/math/Math.h

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

+ 10 - 10
include/anki/math/Math.inl.h

@@ -3,12 +3,12 @@
 namespace anki {
 namespace anki {
 
 
 //==============================================================================
 //==============================================================================
-inline float Math::sqrt(const float f)
+inline F32 Math::sqrt(const F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128 mm = _mm_set_ss(f);
 	__m128 mm = _mm_set_ss(f);
 	mm = _mm_sqrt_ss(mm);
 	mm = _mm_sqrt_ss(mm);
-	float o;
+	F32 o;
 	_mm_store_ss(&o, mm);
 	_mm_store_ss(&o, mm);
 	return o;
 	return o;
 #else
 #else
@@ -17,40 +17,40 @@ inline float Math::sqrt(const float f)
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-inline float Math::toRad(const float degrees)
+inline F32 Math::toRad(const F32 degrees)
 {
 {
 	return degrees * (Math::PI / 180.0);
 	return degrees * (Math::PI / 180.0);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-inline float Math::toDegrees(const float rad)
+inline F32 Math::toDegrees(const F32 rad)
 {
 {
 	return rad * (180.0 / Math::PI);
 	return rad * (180.0 / Math::PI);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-inline float Math::sin(const float rad)
+inline F32 Math::sin(const F32 rad)
 {
 {
 	return ::sin(rad);
 	return ::sin(rad);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-inline float Math::cos(const float rad)
+inline F32 Math::cos(const F32 rad)
 {
 {
 	return ::cos(rad);
 	return ::cos(rad);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-inline bool Math::isZero(const float f)
+inline Bool Math::isZero(const F32 f)
 {
 {
 	return fabs(f) < EPSILON;
 	return fabs(f) < EPSILON;
 }
 }
 
 
 //==============================================================================
 //==============================================================================
 inline void Math::combineTransformations(
 inline void Math::combineTransformations(
-	const Vec3& t0, const Mat3& r0, const float s0,
-	const Vec3& t1, const Mat3& r1, const float s1,
-	Vec3& tf, Mat3& rf, float& sf)
+	const Vec3& t0, const Mat3& r0, const F32 s0,
+	const Vec3& t1, const Mat3& r1, const F32 s1,
+	Vec3& tf, Mat3& rf, F32& sf)
 {
 {
 	tf = t1.getTransformed(t0, r0, s0);
 	tf = t1.getTransformed(t0, r0, s0);
 	rf = r0 * r1;
 	rf = r0 * r1;

+ 1 - 0
include/anki/math/MathCommonIncludes.h

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

+ 1 - 0
include/anki/math/MathCommonSrc.h

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

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

@@ -15,11 +15,11 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Quat();
 	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 F32 f);
+	explicit Quat(const F32 x, const F32 y, const F32 z,
+		const F32 w);
+	explicit Quat(const Vec2& v2, const F32 z, const F32 w);
+	explicit Quat(const Vec3& v3, const F32 w);
 	explicit Quat(const Vec4& v4);
 	explicit Quat(const Vec4& v4);
 			 Quat(const Quat& b);
 			 Quat(const Quat& b);
 	explicit Quat(const Mat3& m3);
 	explicit Quat(const Mat3& m3);
@@ -29,14 +29,14 @@ public:
 
 
 	/// @name Accessors
 	/// @name Accessors
 	/// @{
 	/// @{
-	float x() const;
-	float& x();
-	float y() const;
-	float& y();
-	float z() const;
-	float& z();
-	float w() const;
-	float& w();
+	F32 x() const;
+	F32& x();
+	F32 y() const;
+	F32& y();
+	F32 z() const;
+	F32& z();
+	F32 w() const;
+	F32& w();
 	/// @}
 	/// @}
 
 
 	/// Operators with same type
 	/// Operators with same type
@@ -44,8 +44,8 @@ public:
 	Quat& operator=(const Quat& b);
 	Quat& operator=(const Quat& b);
 	Quat operator*(const Quat& b) const; ///< 16 muls, 12 adds
 	Quat operator*(const Quat& b) const; ///< 16 muls, 12 adds
 	Quat& operator*=(const Quat& b);
 	Quat& operator*=(const Quat& b);
-	bool operator==(const Quat& b) const;
-	bool operator!=(const Quat& b) const;
+	Bool operator==(const Quat& b) const;
+	Bool operator!=(const Quat& b) const;
 	/// @}
 	/// @}
 
 
 	/// @name Other
 	/// @name Other
@@ -53,16 +53,16 @@ public:
 
 
 	/// Calculates the rotation from Vec3 v0 to v1
 	/// Calculates the rotation from Vec3 v0 to v1
 	void setFrom2Vec3(const Vec3& v0, const Vec3& v1);
 	void setFrom2Vec3(const Vec3& v0, const Vec3& v1);
-	float getLength() const;
+	F32 getLength() const;
 	Quat getInverted() const;
 	Quat getInverted() const;
 	void invert();
 	void invert();
 	void conjugate();
 	void conjugate();
 	Quat getConjugated() const;
 	Quat getConjugated() const;
 	void normalize();
 	void normalize();
 	Quat getNormalized() const;
 	Quat getNormalized() const;
-	float dot(const Quat& b) const;
+	F32 dot(const Quat& b) const;
 	/// Returns slerp(this, q1, t)
 	/// Returns slerp(this, q1, t)
-	Quat slerp(const Quat& q1, const float t) const;
+	Quat slerp(const Quat& q1, const F32 t) const;
 	Quat getRotated(const Quat& b) const; ///< The same as Quat * Quat
 	Quat getRotated(const Quat& b) const; ///< The same as Quat * Quat
 	void rotate(const Quat& b); ///< @see getRotated
 	void rotate(const Quat& b); ///< @see getRotated
 	void setIdentity();
 	void setIdentity();
@@ -79,7 +79,7 @@ private:
 	/// @{
 	/// @{
 	struct
 	struct
 	{
 	{
-		float x, y, z, w;
+		F32 x, y, z, w;
 	} vec;
 	} vec;
 	/// @}
 	/// @}
 };
 };

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

@@ -12,15 +12,15 @@ inline Quat::Quat()
 	x() = y() = z() = w() = 0.0;
 	x() = y() = z() = w() = 0.0;
 }
 }
 
 
-// float
-inline Quat::Quat(const float f)
+// F32
+inline Quat::Quat(const F32 f)
 {
 {
 	x() = y() = z() = w() = f;
 	x() = y() = z() = w() = f;
 }
 }
 
 
-// float, float, float, float
-inline Quat::Quat(const float x_, const float y_, const float z_,
-	const float w_)
+// F32, F32, F32, F32
+inline Quat::Quat(const F32 x_, const F32 y_, const F32 z_,
+	const F32 w_)
 {
 {
 	x() = x_;
 	x() = x_;
 	y() = y_;
 	y() = y_;
@@ -28,8 +28,8 @@ inline Quat::Quat(const float x_, const float y_, const float z_,
 	w() = w_;
 	w() = w_;
 }
 }
 
 
-// constructor [vec2, float, float]
-inline Quat::Quat(const Vec2& v, const float z_, const float w_)
+// constructor [vec2, F32, F32]
+inline Quat::Quat(const Vec2& v, const F32 z_, const F32 w_)
 {
 {
 	x() = v.x();
 	x() = v.x();
 	y() = v.y();
 	y() = v.y();
@@ -37,8 +37,8 @@ inline Quat::Quat(const Vec2& v, const float z_, const float w_)
 	w() = w_;
 	w() = w_;
 }
 }
 
 
-// constructor [vec3, float]
-inline Quat::Quat(const Vec3& v, const float w_)
+// constructor [vec3, F32]
+inline Quat::Quat(const Vec3& v, const F32 w_)
 {
 {
 	x() = v.x();
 	x() = v.x();
 	y() = v.y();
 	y() = v.y();
@@ -67,10 +67,10 @@ inline Quat::Quat(const Quat& b)
 // mat3
 // mat3
 inline Quat::Quat(const Mat3& m3)
 inline Quat::Quat(const Mat3& m3)
 {
 {
-	float trace = m3(0, 0) + m3(1, 1) + m3(2, 2) + 1.0;
+	F32 trace = m3(0, 0) + m3(1, 1) + m3(2, 2) + 1.0;
 	if(trace > Math::EPSILON)
 	if(trace > Math::EPSILON)
 	{
 	{
-		float s = 0.5 / sqrt(trace);
+		F32 s = 0.5 / sqrt(trace);
 		w() = 0.25 / s;
 		w() = 0.25 / s;
 		x() = (m3(2, 1) - m3(1, 2)) * s;
 		x() = (m3(2, 1) - m3(1, 2)) * s;
 		y() = (m3(0, 2) - m3(2, 0)) * s;
 		y() = (m3(0, 2) - m3(2, 0)) * s;
@@ -80,7 +80,7 @@ inline Quat::Quat(const Mat3& m3)
 	{
 	{
 		if(m3(0, 0) > m3(1, 1) && m3(0, 0) > m3(2, 2))
 		if(m3(0, 0) > m3(1, 1) && m3(0, 0) > m3(2, 2))
 		{
 		{
-			float s = 0.5 / sqrt(1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2));
+			F32 s = 0.5 / sqrt(1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2));
 			w() = (m3(1, 2) - m3(2, 1)) * s;
 			w() = (m3(1, 2) - m3(2, 1)) * s;
 			x() = 0.25 / s;
 			x() = 0.25 / s;
 			y() = (m3(0, 1) + m3(1, 0)) * s;
 			y() = (m3(0, 1) + m3(1, 0)) * s;
@@ -88,7 +88,7 @@ inline Quat::Quat(const Mat3& m3)
 		}
 		}
 		else if(m3(1, 1) > m3(2, 2))
 		else if(m3(1, 1) > m3(2, 2))
 		{
 		{
-			float s = 0.5 / sqrt(1.0 + m3(1, 1) - m3(0, 0) - m3(2, 2));
+			F32 s = 0.5 / sqrt(1.0 + m3(1, 1) - m3(0, 0) - m3(2, 2));
 			w() = (m3(0, 2) - m3(2, 0)) * s;
 			w() = (m3(0, 2) - m3(2, 0)) * s;
 			x() = (m3(0, 1) + m3(1, 0)) * s;
 			x() = (m3(0, 1) + m3(1, 0)) * s;
 			y() = 0.25 / s;
 			y() = 0.25 / s;
@@ -96,7 +96,7 @@ inline Quat::Quat(const Mat3& m3)
 		}
 		}
 		else
 		else
 		{
 		{
-			float s = 0.5 / sqrt(1.0 + m3(2, 2) - m3(0, 0) - m3(1, 1));
+			F32 s = 0.5 / sqrt(1.0 + m3(2, 2) - m3(0, 0) - m3(1, 1));
 			w() = (m3(0, 1) - m3(1, 0)) * s;
 			w() = (m3(0, 1) - m3(1, 0)) * s;
 			x() = (m3(0, 2) + m3(2, 0)) * s;
 			x() = (m3(0, 2) + m3(2, 0)) * s;
 			y() = (m3(1, 2) + m3(2, 1)) * s;
 			y() = (m3(1, 2) + m3(2, 1)) * s;
@@ -108,17 +108,17 @@ inline Quat::Quat(const Mat3& m3)
 // euler
 // euler
 inline Quat::Quat(const Euler& eu)
 inline Quat::Quat(const Euler& eu)
 {
 {
-	float cx, sx;
+	F32 cx, sx;
 	Math::sinCos(eu.y() * 0.5, sx, cx);
 	Math::sinCos(eu.y() * 0.5, sx, cx);
 
 
-	float cy, sy;
+	F32 cy, sy;
 	Math::sinCos(eu.z() * 0.5, sy, cy);
 	Math::sinCos(eu.z() * 0.5, sy, cy);
 
 
-	float cz, sz;
+	F32 cz, sz;
 	Math::sinCos(eu.x() * 0.5, sz, cz);
 	Math::sinCos(eu.x() * 0.5, sz, cz);
 
 
-	float cxcy = cx * cy;
-	float sxsy = sx * sy;
+	F32 cxcy = cx * cy;
+	F32 sxsy = sx * sy;
 	x() = cxcy * sz + sxsy * cz;
 	x() = cxcy * sz + sxsy * cz;
 	y() = sx * cy * cz + cx * sy * sz;
 	y() = sx * cy * cz + cx * sy * sz;
 	z() = cx * sy * cz - sx * cy * sz;
 	z() = cx * sy * cz - sx * cy * sz;
@@ -128,19 +128,19 @@ inline Quat::Quat(const Euler& eu)
 // euler
 // euler
 inline Quat::Quat(const Axisang& axisang)
 inline Quat::Quat(const Axisang& axisang)
 {
 {
-	float lengthsq = axisang.getAxis().getLengthSquared();
+	F32 lengthsq = axisang.getAxis().getLengthSquared();
 	if(Math::isZero(lengthsq))
 	if(Math::isZero(lengthsq))
 	{
 	{
 		(*this) = getIdentity();
 		(*this) = getIdentity();
 		return;
 		return;
 	}
 	}
 
 
-	float rad = axisang.getAngle() * 0.5;
+	F32 rad = axisang.getAngle() * 0.5;
 
 
-	float sintheta, costheta;
+	F32 sintheta, costheta;
 	Math::sinCos(rad, sintheta, costheta);
 	Math::sinCos(rad, sintheta, costheta);
 
 
-	float scalefactor = sintheta / sqrt(lengthsq);
+	F32 scalefactor = sintheta / sqrt(lengthsq);
 
 
 	x() = scalefactor * axisang.getAxis().x();
 	x() = scalefactor * axisang.getAxis().x();
 	y() = scalefactor * axisang.getAxis().y();
 	y() = scalefactor * axisang.getAxis().y();
@@ -152,42 +152,42 @@ inline Quat::Quat(const Axisang& axisang)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float Quat::x() const
+inline F32 Quat::x() const
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float& Quat::x()
+inline F32& Quat::x()
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float Quat::y() const
+inline F32 Quat::y() const
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float& Quat::y()
+inline F32& Quat::y()
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float Quat::z() const
+inline F32 Quat::z() const
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float& Quat::z()
+inline F32& Quat::z()
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float Quat::w() const
+inline F32 Quat::w() const
 {
 {
 	return vec.w;
 	return vec.w;
 }
 }
 
 
-inline float& Quat::w()
+inline F32& Quat::w()
 {
 {
 	return vec.w;
 	return vec.w;
 }
 }
@@ -225,7 +225,7 @@ inline Quat& Quat::operator *=(const Quat& b)
 }
 }
 
 
 // ==
 // ==
-inline bool Quat::operator ==(const Quat& b) const
+inline Bool Quat::operator ==(const Quat& b) const
 {
 {
 	return Math::isZero(x() - b.x()) &&
 	return Math::isZero(x() - b.x()) &&
 		Math::isZero(y() - b.y()) &&
 		Math::isZero(y() - b.y()) &&
@@ -234,7 +234,7 @@ inline bool Quat::operator ==(const Quat& b) const
 }
 }
 
 
 // !=
 // !=
-inline bool Quat::operator !=(const Quat& b) const
+inline Bool Quat::operator !=(const Quat& b) const
 {
 {
 	return !(Math::isZero(x() - b.x()) &&
 	return !(Math::isZero(x() - b.x()) &&
 		Math::isZero(y() - b.y()) &&
 		Math::isZero(y() - b.y()) &&
@@ -273,7 +273,7 @@ inline void Quat::normalize()
 }
 }
 
 
 // getLength
 // getLength
-inline float Quat::getLength() const
+inline F32 Quat::getLength() const
 {
 {
 	return Math::sqrt(w() * w() + x() * x() + y() * y() + z() * z());
 	return Math::sqrt(w() * w() + x() * x() + y() * y() + z() * z());
 }
 }
@@ -281,11 +281,11 @@ inline float Quat::getLength() const
 // getInverted
 // getInverted
 inline Quat Quat::getInverted() const
 inline Quat Quat::getInverted() const
 {
 {
-	float norm = w() * w() + x() * x() + y() * y() + z() * z();
+	F32 norm = w() * w() + x() * x() + y() * y() + z() * z();
 
 
 	ANKI_ASSERT(!Math::isZero(norm)); // Norm is zero
 	ANKI_ASSERT(!Math::isZero(norm)); // Norm is zero
 
 
-	float normi = 1.0 / norm;
+	F32 normi = 1.0 / norm;
 	return Quat(-normi * x(), -normi * y(), -normi * z(), normi * w());
 	return Quat(-normi * x(), -normi * y(), -normi * z(), normi * w());
 }
 }
 
 
@@ -330,17 +330,17 @@ inline void Quat::rotate(const Quat& b)
 }
 }
 
 
 // dot
 // dot
-inline float Quat::dot(const Quat& b) const
+inline F32 Quat::dot(const Quat& b) const
 {
 {
 	return w() * b.w() + x() * b.x() + y() * b.y() + z() * b.z();
 	return w() * b.w() + x() * b.x() + y() * b.y() + z() * b.z();
 }
 }
 
 
 // SLERP
 // SLERP
-inline Quat Quat::slerp(const Quat& q1_, const float t) const
+inline Quat Quat::slerp(const Quat& q1_, const F32 t) const
 {
 {
 	const Quat& q0 = (*this);
 	const Quat& q0 = (*this);
 	Quat q1(q1_);
 	Quat q1(q1_);
-	float cosHalfTheta = q0.w() * q1.w() + q0.x() * q1.x() + q0.y() * q1.y() 
+	F32 cosHalfTheta = q0.w() * q1.w() + q0.x() * q1.x() + q0.y() * q1.y() 
 		+ q0.z() * q1.z();
 		+ q0.z() * q1.z();
 	if(cosHalfTheta < 0.0)
 	if(cosHalfTheta < 0.0)
 	{
 	{
@@ -353,15 +353,15 @@ inline Quat Quat::slerp(const Quat& q1_, const float t) const
 		return Quat(q0);
 		return Quat(q0);
 	}
 	}
 
 
-	float halfTheta = acos(cosHalfTheta);
-	float sinHalfTheta = Math::sqrt(1.0 - cosHalfTheta * cosHalfTheta);
+	F32 halfTheta = acos(cosHalfTheta);
+	F32 sinHalfTheta = Math::sqrt(1.0 - cosHalfTheta * cosHalfTheta);
 
 
 	if(fabs(sinHalfTheta) < 0.001)
 	if(fabs(sinHalfTheta) < 0.001)
 	{
 	{
 		return Quat((Vec4(q0) + Vec4(q1)) * 0.5);
 		return Quat((Vec4(q0) + Vec4(q1)) * 0.5);
 	}
 	}
-	float ratioA = sin((1.0 - t) * halfTheta) / sinHalfTheta;
-	float ratio_b = sin(t * halfTheta) / sinHalfTheta;
+	F32 ratioA = sin((1.0 - t) * halfTheta) / sinHalfTheta;
+	F32 ratio_b = sin(t * halfTheta) / sinHalfTheta;
 	Vec4 tmp, tmp1, sum;
 	Vec4 tmp, tmp1, sum;
 	tmp = Vec4(q0) * ratioA;
 	tmp = Vec4(q0) * ratioA;
 	tmp1 = Vec4(q1) * ratio_b;
 	tmp1 = Vec4(q1) * ratio_b;

+ 7 - 7
include/anki/math/Transform.h

@@ -20,7 +20,7 @@ public:
 	Transform(const Transform& b);
 	Transform(const Transform& b);
 	explicit Transform(const Mat4& m4);
 	explicit Transform(const Mat4& m4);
 	explicit Transform(const Vec3& origin, const Mat3& rotation,
 	explicit Transform(const Vec3& origin, const Mat3& rotation,
-		const float scale);
+		const F32 scale);
 	/// @}
 	/// @}
 
 
 	/// @name Accessors
 	/// @name Accessors
@@ -33,16 +33,16 @@ public:
 	Mat3& getRotation();
 	Mat3& getRotation();
 	void setRotation(const Mat3& r);
 	void setRotation(const Mat3& r);
 
 
-	float getScale() const;
-	float& getScale();
-	void setScale(const float s);
+	F32 getScale() const;
+	F32& getScale();
+	void setScale(const F32 s);
 	/// @}
 	/// @}
 
 
 	/// @name Operators with same type
 	/// @name Operators with same type
 	/// @{
 	/// @{
 	Transform& operator=(const Transform& b);
 	Transform& operator=(const Transform& b);
-	bool operator==(const Transform& b) const;
-	bool operator!=(const Transform& b) const;
+	Bool operator==(const Transform& b) const;
+	Bool operator!=(const Transform& b) const;
 	/// @}
 	/// @}
 
 
 	/// @name Other
 	/// @name Other
@@ -68,7 +68,7 @@ private:
 	/// @{
 	/// @{
 	Vec3 origin; ///< The rotation
 	Vec3 origin; ///< The rotation
 	Mat3 rotation; ///< The translation
 	Mat3 rotation; ///< The translation
-	float scale; ///< The uniform scaling
+	F32 scale; ///< The uniform scaling
 	/// @}
 	/// @}
 };
 };
 /// @}
 /// @}

+ 7 - 7
include/anki/math/Transform.inl.h

@@ -23,9 +23,9 @@ inline Transform::Transform(const Mat4& m4)
 	scale = 1.0;
 	scale = 1.0;
 }
 }
 
 
-// Vec3, Quat, float
+// Vec3, Quat, F32
 inline Transform::Transform(const Vec3& origin, const Mat3& rotation_,
 inline Transform::Transform(const Vec3& origin, const Mat3& rotation_,
-	const float scale_)
+	const F32 scale_)
 	: origin(origin), rotation(rotation_), scale(scale_)
 	: origin(origin), rotation(rotation_), scale(scale_)
 {}
 {}
 
 
@@ -63,17 +63,17 @@ inline void Transform::setRotation(const Mat3& r)
 	rotation = r;
 	rotation = r;
 }
 }
 
 
-inline float Transform::getScale() const
+inline F32 Transform::getScale() const
 {
 {
 	return scale;
 	return scale;
 }
 }
 
 
-inline float& Transform::getScale()
+inline F32& Transform::getScale()
 {
 {
 	return scale;
 	return scale;
 }
 }
 
 
-inline void Transform::setScale(const float s)
+inline void Transform::setScale(const F32 s)
 {
 {
 	scale = s;
 	scale = s;
 }
 }
@@ -92,13 +92,13 @@ inline Transform& Transform::operator=(const Transform& b)
 }
 }
 
 
 // ==
 // ==
-inline bool Transform::operator==(const Transform& b) const
+inline Bool Transform::operator==(const Transform& b) const
 {
 {
 	return origin == b.origin && rotation == b.rotation && scale == b.scale;
 	return origin == b.origin && rotation == b.rotation && scale == b.scale;
 }
 }
 
 
 // !=
 // !=
-inline bool Transform::operator!=(const Transform& b) const
+inline Bool Transform::operator!=(const Transform& b) const
 {
 {
 	return !operator==(b);
 	return !operator==(b);
 }
 }

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

@@ -15,9 +15,9 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Vec2();
 	explicit Vec2();
-	explicit Vec2(const float x, const float y);
-	explicit Vec2(const float f);
-	explicit Vec2(const float arr[]);
+	explicit Vec2(const F32 x, const F32 y);
+	explicit Vec2(const F32 f);
+	explicit Vec2(const F32 arr[]);
 	Vec2(const Vec2& b);
 	Vec2(const Vec2& b);
 	explicit Vec2(const Vec3& v3);
 	explicit Vec2(const Vec3& v3);
 	explicit Vec2(const Vec4& v4);
 	explicit Vec2(const Vec4& v4);
@@ -25,12 +25,12 @@ public:
 
 
 	/// @name Accessors
 	/// @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;
+	F32& x();
+	F32 x() const;
+	F32& y();
+	F32 y() const;
+	F32& operator[](const U i);
+	F32 operator[](const U i) const;
 	/// @}
 	/// @}
 
 
 	/// @name Operators with same type
 	/// @name Operators with same type
@@ -45,39 +45,39 @@ public:
 	Vec2 operator/(const Vec2& b) const;
 	Vec2 operator/(const Vec2& b) const;
 	Vec2& operator/=(const Vec2& b);
 	Vec2& operator/=(const Vec2& b);
 	Vec2 operator-() const;
 	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;
+	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
+	/// @name Operators with F32
 	/// @{
 	/// @{
-	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);
+	Vec2 operator+(const F32 f) const;
+	Vec2& operator+=(const F32 f);
+	Vec2 operator-(const F32 f) const;
+	Vec2& operator-=(const F32 f);
+	Vec2 operator*(const F32 f) const;
+	Vec2& operator*=(const F32 f);
+	Vec2 operator/(const F32 f) const;
+	Vec2& operator/=(const F32 f);
 	/// @}
 	/// @}
 
 
 	/// @name Other
 	/// @name Other
 	/// @{
 	/// @{
-	float getLength() const;
+	F32 getLength() const;
 	Vec2 getNormalized() const;
 	Vec2 getNormalized() const;
 	void normalize();
 	void normalize();
-	float dot(const Vec2& b) const;
+	F32 dot(const Vec2& b) const;
 	/// @}
 	/// @}
 
 
 	/// @name Friends
 	/// @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 Vec2 operator+(const F32 f, const Vec2& v2);
+	friend Vec2 operator-(const F32 f, const Vec2& v2);
+	friend Vec2 operator*(const F32 f, const Vec2& v2);
+	friend Vec2 operator/(const F32 f, const Vec2& v2);
 	friend std::ostream& operator<<(std::ostream& s, const Vec2& v);
 	friend std::ostream& operator<<(std::ostream& s, const Vec2& v);
 	///@]
 	///@]
 
 
@@ -88,16 +88,16 @@ private:
 	{
 	{
 		struct
 		struct
 		{
 		{
-			float x, y;
+			F32 x, y;
 		} vec;
 		} vec;
 
 
-		std::array<float, 2> arr;
+		std::array<F32, 2> arr;
 	};
 	};
 	/// @}
 	/// @}
 };
 };
 /// @
 /// @
 
 
-static_assert(sizeof(Vec2) == sizeof(float) * 2, "Incorrect size");
+static_assert(sizeof(Vec2) == sizeof(F32) * 2, "Incorrect size");
 
 
 } // end namespace anki
 } // end namespace anki
 
 

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

@@ -12,21 +12,21 @@ inline Vec2::Vec2()
 	x() = y() = 0.0;
 	x() = y() = 0.0;
 }
 }
 
 
-// float
-inline Vec2::Vec2(const float f)
+// F32
+inline Vec2::Vec2(const F32 f)
 {
 {
 	x() = y() = f;
 	x() = y() = f;
 }
 }
 
 
-// float, float
-inline Vec2::Vec2(const float x_, const float y_)
+// F32, F32
+inline Vec2::Vec2(const F32 x_, const F32 y_)
 {
 {
 	x() = x_;
 	x() = x_;
 	y() = y_;
 	y() = y_;
 }
 }
 
 
-// float[]
-inline Vec2::Vec2(const float arr[])
+// F32[]
+inline Vec2::Vec2(const F32 arr[])
 {
 {
 	x() = arr[0];
 	x() = arr[0];
 	y() = arr[1];
 	y() = arr[1];
@@ -57,32 +57,32 @@ inline Vec2::Vec2(const Vec4& v4)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float& Vec2::x()
+inline F32& Vec2::x()
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float Vec2::x() const
+inline F32 Vec2::x() const
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float& Vec2::y()
+inline F32& Vec2::y()
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float Vec2::y() const
+inline F32 Vec2::y() const
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float& Vec2::operator[](const size_t i)
+inline F32& Vec2::operator[](const U i)
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
-inline float Vec2::operator[](const size_t i) const
+inline F32 Vec2::operator[](const U i) const
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
@@ -162,81 +162,81 @@ inline Vec2 Vec2::operator-() const
 }
 }
 
 
 // ==
 // ==
-inline bool Vec2::operator==(const Vec2& b) const
+inline Bool Vec2::operator==(const Vec2& b) const
 {
 {
 	return Math::isZero(x() - b.x()) &&
 	return Math::isZero(x() - b.x()) &&
 		Math::isZero(y() - b.y());
 		Math::isZero(y() - b.y());
 }
 }
 
 
 // !=
 // !=
-inline bool Vec2::operator!=(const Vec2& b) const
+inline Bool Vec2::operator!=(const Vec2& b) const
 {
 {
 	return !(*this == b);
 	return !(*this == b);
 }
 }
 
 
 // <
 // <
-inline bool Vec2::operator<(const Vec2& b) const
+inline Bool Vec2::operator<(const Vec2& b) const
 {
 {
 	return vec.x < b.vec.x && vec.y < b.vec.y;
 	return vec.x < b.vec.x && vec.y < b.vec.y;
 }
 }
 
 
 // <=
 // <=
-inline bool Vec2::operator<=(const Vec2& b) const
+inline Bool Vec2::operator<=(const Vec2& b) const
 {
 {
 	return vec.x <= b.vec.x && vec.y <= b.vec.y;
 	return vec.x <= b.vec.x && vec.y <= b.vec.y;
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-// Operators with float                                                        =
+// Operators with F32                                                        =
 //==============================================================================
 //==============================================================================
 
 
-// vec2 + float
-inline Vec2 Vec2::operator+(float f) const
+// vec2 + F32
+inline Vec2 Vec2::operator+(F32 f) const
 {
 {
 	return (*this) + Vec2(f);
 	return (*this) + Vec2(f);
 }
 }
 
 
-// vec2 += float
-inline Vec2& Vec2::operator+=(float f)
+// vec2 += F32
+inline Vec2& Vec2::operator+=(F32 f)
 {
 {
 	(*this) += Vec2(f);
 	(*this) += Vec2(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// vec2 - float
-inline Vec2 Vec2::operator-(float f) const
+// vec2 - F32
+inline Vec2 Vec2::operator-(F32 f) const
 {
 {
 	return (*this) - Vec2(f);
 	return (*this) - Vec2(f);
 }
 }
 
 
-// vec2 -= float
-inline Vec2& Vec2::operator-=(float f)
+// vec2 -= F32
+inline Vec2& Vec2::operator-=(F32 f)
 {
 {
 	(*this) -= Vec2(f);
 	(*this) -= Vec2(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// vec2 * float
-inline Vec2 Vec2::operator*(float f) const
+// vec2 * F32
+inline Vec2 Vec2::operator*(F32 f) const
 {
 {
 	return (*this) * Vec2(f);
 	return (*this) * Vec2(f);
 }
 }
 
 
-// vec2 *= float
-inline Vec2& Vec2::operator*=(float f)
+// vec2 *= F32
+inline Vec2& Vec2::operator*=(F32 f)
 {
 {
 	(*this) *= Vec2(f);
 	(*this) *= Vec2(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// vec2 / float
-inline Vec2 Vec2::operator/(float f) const
+// vec2 / F32
+inline Vec2 Vec2::operator/(F32 f) const
 {
 {
 	return (*this) / Vec2(f);
 	return (*this) / Vec2(f);
 }
 }
 
 
-// vec2 /= float
-inline Vec2& Vec2::operator/=(float f)
+// vec2 /= F32
+inline Vec2& Vec2::operator/=(F32 f)
 {
 {
 	(*this) /= Vec2(f);
 	(*this) /= Vec2(f);
 	return (*this);
 	return (*this);
@@ -247,7 +247,7 @@ inline Vec2& Vec2::operator/=(float f)
 //==============================================================================
 //==============================================================================
 
 
 // getLength
 // getLength
-inline float Vec2::getLength() const
+inline F32 Vec2::getLength() const
 {
 {
 	return Math::sqrt(x() * x() + y() * y());
 	return Math::sqrt(x() * x() + y() * y());
 }
 }
@@ -265,7 +265,7 @@ inline Vec2 Vec2::getNormalized() const
 }
 }
 
 
 // dot
 // dot
-inline float Vec2::dot(const Vec2& b) const
+inline F32 Vec2::dot(const Vec2& b) const
 {
 {
 	return x() * b.x() + y() * b.y();
 	return x() * b.x() + y() * b.y();
 }
 }
@@ -274,26 +274,26 @@ inline float Vec2::dot(const Vec2& b) const
 // Friends                                                                     =
 // Friends                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-// float + vec2
-inline Vec2 operator+(float f, const Vec2& v2)
+// F32 + vec2
+inline Vec2 operator+(F32 f, const Vec2& v2)
 {
 {
 	return v2 + f;
 	return v2 + f;
 }
 }
 
 
-// float - vec2
-inline Vec2 operator-(float f, const Vec2& v2)
+// F32 - vec2
+inline Vec2 operator-(F32 f, const Vec2& v2)
 {
 {
 	return Vec2(f - v2.x(), f - v2.y());
 	return Vec2(f - v2.x(), f - v2.y());
 }
 }
 
 
-// float * vec2
-inline Vec2 operator*(float f, const Vec2& v2)
+// F32 * vec2
+inline Vec2 operator*(F32 f, const Vec2& v2)
 {
 {
 	return v2 * f;
 	return v2 * f;
 }
 }
 
 
-// float / vec2
-inline Vec2 operator/(float f, const Vec2& v2)
+// F32 / vec2
+inline Vec2 operator/(F32 f, const Vec2& v2)
 {
 {
 	return Vec2(f / v2.x(), f / v2.y());
 	return Vec2(f / v2.x(), f / v2.y());
 }
 }

+ 44 - 43
include/anki/math/Vec3.h

@@ -15,10 +15,10 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Vec3();
 	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);
+	explicit Vec3(const F32 x, const F32 y, const F32 z);
+	explicit Vec3(const F32 f);
+	explicit Vec3(const F32 arr[]);
+	explicit Vec3(const Vec2& v2, const F32 z);
 	Vec3(const Vec3& b);
 	Vec3(const Vec3& b);
 	explicit Vec3(const Vec4& v4);
 	explicit Vec3(const Vec4& v4);
 	explicit Vec3(const Quat& q);
 	explicit Vec3(const Quat& q);
@@ -26,14 +26,15 @@ public:
 
 
 	/// @name Accessors
 	/// @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;
+	F32& x();
+	F32 x() const;
+	F32& y();
+	F32 y() const;
+	F32& z();
+	F32 z() const;
+	F32& operator[](const U i);
+	F32 operator[](const U i) const;
+	Vec2 xy() const;
 	/// @}
 	/// @}
 
 
 	/// @name Operators with same type
 	/// @name Operators with same type
@@ -48,24 +49,24 @@ public:
 	Vec3 operator/(const Vec3& b) const;
 	Vec3 operator/(const Vec3& b) const;
 	Vec3& operator/=(const Vec3& b);
 	Vec3& operator/=(const Vec3& b);
 	Vec3 operator-() const;
 	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;
+	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
+	/// @name Operators with F32
 	/// @{
 	/// @{
-	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);
+	Vec3 operator+(const F32 f) const;
+	Vec3& operator+=(const F32 f);
+	Vec3 operator-(const F32 f) const;
+	Vec3& operator-=(const F32 f);
+	Vec3 operator*(const F32 f) const;
+	Vec3& operator*=(const F32 f);
+	Vec3 operator/(const F32 f) const;
+	Vec3& operator/=(const F32 f);
 	/// @}
 	/// @}
 
 
 	/// @name Operators with other types
 	/// @name Operators with other types
@@ -75,11 +76,11 @@ public:
 
 
 	/// @name Other
 	/// @name Other
 	/// @{
 	/// @{
-	float dot(const Vec3& b) const; ///< 3 muls, 2 adds
+	F32 dot(const Vec3& b) const; ///< 3 muls, 2 adds
 	Vec3 cross(const Vec3& b) const; ///< 6 muls, 3 adds
 	Vec3 cross(const Vec3& b) const; ///< 6 muls, 3 adds
-	float getLength() const;
-	float getLengthSquared() const;
-	float getDistanceSquared(const Vec3& b) const;
+	F32 getLength() const;
+	F32 getLengthSquared() const;
+	F32 getDistanceSquared(const Vec3& b) const;
 	void normalize();
 	void normalize();
 	Vec3 getNormalized() const;
 	Vec3 getNormalized() const;
 	Vec3 getProjection(const Vec3& toThis) const;
 	Vec3 getProjection(const Vec3& toThis) const;
@@ -87,7 +88,7 @@ public:
 	/// 18 muls, 12 adds
 	/// 18 muls, 12 adds
 	Vec3 getRotated(const Quat& q) const;
 	Vec3 getRotated(const Quat& q) const;
 	void rotate(const Quat& q);
 	void rotate(const Quat& q);
-	Vec3 lerp(const Vec3& v1, float t) const; ///< Return lerp(this, v1, t)
+	Vec3 lerp(const Vec3& v1, F32 t) const; ///< Return lerp(this, v1, t)
 	/// @}
 	/// @}
 
 
 	/// @name Transformations
 	/// @name Transformations
@@ -95,13 +96,13 @@ public:
 	/// getTransformed(const Vec3&, const Mat3&)
 	/// getTransformed(const Vec3&, const Mat3&)
 	/// @{
 	/// @{
 	Vec3 getTransformed(const Vec3& translate, const Mat3& rotate,
 	Vec3 getTransformed(const Vec3& translate, const Mat3& rotate,
-		float scale) const;
-	void transform(const Vec3& translate, const Mat3& rotate, float scale);
+		F32 scale) const;
+	void transform(const Vec3& translate, const Mat3& rotate, F32 scale);
 	Vec3 getTransformed(const Vec3& translate, const Mat3& rotate) const;
 	Vec3 getTransformed(const Vec3& translate, const Mat3& rotate) const;
 	void transform(const Vec3& translate, const Mat3& rotate);
 	void transform(const Vec3& translate, const Mat3& rotate);
 	Vec3 getTransformed(const Vec3& translate, const Quat& rotate,
 	Vec3 getTransformed(const Vec3& translate, const Quat& rotate,
-		float scale) const;
-	void transform(const Vec3& translate, const Quat& rotate, float scale);
+		F32 scale) const;
+	void transform(const Vec3& translate, const Quat& rotate, F32 scale);
 	Vec3 getTransformed(const Vec3& translate, const Quat& rotate) const;
 	Vec3 getTransformed(const Vec3& translate, const Quat& rotate) const;
 	void transform(const Vec3& translate, const Quat& rotate);
 	void transform(const Vec3& translate, const Quat& rotate);
 	Vec3 getTransformed(const Mat4& transform) const;  ///< 9 muls, 9 adds
 	Vec3 getTransformed(const Mat4& transform) const;  ///< 9 muls, 9 adds
@@ -112,10 +113,10 @@ public:
 
 
 	/// @name Friends
 	/// @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 Vec3 operator+(const F32 f, const Vec3& v);
+	friend Vec3 operator-(const F32 f, const Vec3& v);
+	friend Vec3 operator*(const F32 f, const Vec3& v);
+	friend Vec3 operator/(const F32 f, const Vec3& v);
 	friend std::ostream& operator<<(std::ostream& s, const Vec3& v);
 	friend std::ostream& operator<<(std::ostream& s, const Vec3& v);
 	/// @}
 	/// @}
 
 
@@ -126,16 +127,16 @@ private:
 	{
 	{
 		struct
 		struct
 		{
 		{
-			float x, y, z;
+			F32 x, y, z;
 		} vec;
 		} vec;
 
 
-		std::array<float, 3> arr;
+		std::array<F32, 3> arr;
 	};
 	};
 	/// @}
 	/// @}
 };
 };
 /// @}
 /// @}
 
 
-static_assert(sizeof(Vec3) == sizeof(float) * 3, "Incorrect size");
+static_assert(sizeof(Vec3) == sizeof(F32) * 3, "Incorrect size");
 
 
 } // end namespace
 } // end namespace
 
 

+ 62 - 57
include/anki/math/Vec3.inl.h

@@ -12,22 +12,22 @@ inline Vec3::Vec3()
 	arr[0] = arr[1] = arr[2] = 0.0;
 	arr[0] = arr[1] = arr[2] = 0.0;
 }
 }
 
 
-// float, float, float
-inline Vec3::Vec3(const float x_, const float y_, const float z_)
+// F32, F32, F32
+inline Vec3::Vec3(const F32 x_, const F32 y_, const F32 z_)
 {
 {
 	x() = x_;
 	x() = x_;
 	y() = y_;
 	y() = y_;
 	z() = z_;
 	z() = z_;
 }
 }
 
 
-// float
-inline Vec3::Vec3(const float f)
+// F32
+inline Vec3::Vec3(const F32 f)
 {
 {
 	arr[0] = arr[1] = arr[2] = f;
 	arr[0] = arr[1] = arr[2] = f;
 }
 }
 
 
-// float[]
-inline Vec3::Vec3(const float arr_[])
+// F32[]
+inline Vec3::Vec3(const F32 arr_[])
 {
 {
 	arr[0] = arr_[0];
 	arr[0] = arr_[0];
 	arr[1] = arr_[1];
 	arr[1] = arr_[1];
@@ -42,8 +42,8 @@ inline Vec3::Vec3(const Vec3& b)
 	arr[2] = b.arr[2];
 	arr[2] = b.arr[2];
 }
 }
 
 
-// Vec2, float
-inline Vec3::Vec3(const Vec2& v2, const float z_)
+// Vec2, F32
+inline Vec3::Vec3(const Vec2& v2, const F32 z_)
 {
 {
 	x() = v2.x();
 	x() = v2.x();
 	y() = v2.y();
 	y() = v2.y();
@@ -70,46 +70,51 @@ inline Vec3::Vec3(const Quat& q)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float& Vec3::x()
+inline F32& Vec3::x()
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float Vec3::x() const
+inline F32 Vec3::x() const
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float& Vec3::y()
+inline F32& Vec3::y()
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float Vec3::y() const
+inline F32 Vec3::y() const
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float& Vec3::z()
+inline F32& Vec3::z()
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float Vec3::z() const
+inline F32 Vec3::z() const
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float& Vec3::operator[](const size_t i)
+inline F32& Vec3::operator[](const U i)
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
-inline float Vec3::operator[](const size_t i) const
+inline F32 Vec3::operator[](const U i) const
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
+inline Vec2 Vec3::xy() const
+{
+	return Vec2(x(), y());
+}
+
 //==============================================================================
 //==============================================================================
 // Operators with same type                                                    =
 // Operators with same type                                                    =
 //==============================================================================
 //==============================================================================
@@ -190,7 +195,7 @@ inline Vec3 Vec3::operator-() const
 }
 }
 
 
 // ==
 // ==
-inline bool Vec3::operator==(const Vec3& b) const
+inline Bool Vec3::operator==(const Vec3& b) const
 {
 {
 	return Math::isZero(x() - b.x()) 
 	return Math::isZero(x() - b.x()) 
 		&& Math::isZero(y() - b.y()) 
 		&& Math::isZero(y() - b.y()) 
@@ -198,86 +203,86 @@ inline bool Vec3::operator==(const Vec3& b) const
 }
 }
 
 
 // !=
 // !=
-inline bool Vec3::operator!=(const Vec3& b) const
+inline Bool Vec3::operator!=(const Vec3& b) const
 {
 {
 	return !operator==(b);
 	return !operator==(b);
 }
 }
 
 
 // <
 // <
-inline bool Vec3::operator<(const Vec3& b) const
+inline Bool Vec3::operator<(const Vec3& b) const
 {
 {
 	return x() < b.x() && y() < b.y() && z() < b.z();
 	return x() < b.x() && y() < b.y() && z() < b.z();
 }
 }
 
 
 // <=
 // <=
-inline bool Vec3::operator<=(const Vec3& b) const
+inline Bool Vec3::operator<=(const Vec3& b) const
 {
 {
 	return x() <= b.x() && y() <= b.y() && z() <= b.z();
 	return x() <= b.x() && y() <= b.y() && z() <= b.z();
 }
 }
 
 
 // >
 // >
-inline bool Vec3::operator>(const Vec3& b) const
+inline Bool Vec3::operator>(const Vec3& b) const
 {
 {
 	return x() > b.x() && y() > b.y() && z() > b.z();
 	return x() > b.x() && y() > b.y() && z() > b.z();
 }
 }
 
 
 // >=
 // >=
-inline bool Vec3::operator>=(const Vec3& b) const
+inline Bool Vec3::operator>=(const Vec3& b) const
 {
 {
 	return x() >= b.x() && y() >= b.y() && z() >= b.z();
 	return x() >= b.x() && y() >= b.y() && z() >= b.z();
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-// Operators with float                                                        =
+// Operators with F32                                                        =
 //==============================================================================
 //==============================================================================
 
 
-// Vec3 + float
-inline Vec3 Vec3::operator+(float f) const
+// Vec3 + F32
+inline Vec3 Vec3::operator+(F32 f) const
 {
 {
 	return (*this) + Vec3(f);
 	return (*this) + Vec3(f);
 }
 }
 
 
-// Vec3 += float
-inline Vec3& Vec3::operator+=(float f)
+// Vec3 += F32
+inline Vec3& Vec3::operator+=(F32 f)
 {
 {
 	(*this) += Vec3(f);
 	(*this) += Vec3(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// Vec3 - float
-inline Vec3 Vec3::operator-(float f) const
+// Vec3 - F32
+inline Vec3 Vec3::operator-(F32 f) const
 {
 {
 	return (*this) - Vec3(f);
 	return (*this) - Vec3(f);
 }
 }
 
 
-// Vec3 -= float
-inline Vec3& Vec3::operator-=(float f)
+// Vec3 -= F32
+inline Vec3& Vec3::operator-=(F32 f)
 {
 {
 	(*this) -= Vec3(f);
 	(*this) -= Vec3(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// Vec3 * float
-inline Vec3 Vec3::operator*(float f) const
+// Vec3 * F32
+inline Vec3 Vec3::operator*(F32 f) const
 {
 {
 	return (*this) * Vec3(f);
 	return (*this) * Vec3(f);
 }
 }
 
 
-// Vec3 *= float
-inline Vec3& Vec3::operator*=(float f)
+// Vec3 *= F32
+inline Vec3& Vec3::operator*=(F32 f)
 {
 {
 	(*this) *= Vec3(f);
 	(*this) *= Vec3(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// Vec3 / float
-inline Vec3 Vec3::operator/(float f) const
+// Vec3 / F32
+inline Vec3 Vec3::operator/(F32 f) const
 {
 {
 	return (*this) / Vec3(f);
 	return (*this) / Vec3(f);
 }
 }
 
 
-// Vec3 /= float
-inline Vec3& Vec3::operator/=(float f)
+// Vec3 /= F32
+inline Vec3& Vec3::operator/=(F32 f)
 {
 {
 	(*this) /= Vec3(f);
 	(*this) /= Vec3(f);
 	return (*this);
 	return (*this);
@@ -288,7 +293,7 @@ inline Vec3& Vec3::operator/=(float f)
 //==============================================================================
 //==============================================================================
 
 
 // dot
 // dot
-inline float Vec3::dot(const Vec3& b) const
+inline F32 Vec3::dot(const Vec3& b) const
 {
 {
 	return x() * b.x() + y() * b.y() + z() * b.z();
 	return x() * b.x() + y() * b.y() + z() * b.z();
 }
 }
@@ -302,19 +307,19 @@ inline Vec3 Vec3::cross(const Vec3& b) const
 }
 }
 
 
 // getLength
 // getLength
-inline float Vec3::getLength() const
+inline F32 Vec3::getLength() const
 {
 {
 	return Math::sqrt(getLengthSquared());
 	return Math::sqrt(getLengthSquared());
 }
 }
 
 
 // getLengthSquared
 // getLengthSquared
-inline float Vec3::getLengthSquared() const
+inline F32 Vec3::getLengthSquared() const
 {
 {
 	return x() * x() + y() * y() + z() * z();
 	return x() * x() + y() * y() + z() * z();
 }
 }
 
 
 // getDistanceSquared
 // getDistanceSquared
-inline float Vec3::getDistanceSquared(const Vec3& b) const
+inline F32 Vec3::getDistanceSquared(const Vec3& b) const
 {
 {
 	return ((*this) - b).getLengthSquared();
 	return ((*this) - b).getLengthSquared();
 }
 }
@@ -352,7 +357,7 @@ inline void Vec3::rotate(const Quat& q)
 }
 }
 
 
 // lerp
 // lerp
-inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
+inline Vec3 Vec3::lerp(const Vec3& v1, F32 t) const
 {
 {
 	return ((*this) * (1.0 - t)) + (v1 * t);
 	return ((*this) * (1.0 - t)) + (v1 * t);
 }
 }
@@ -363,14 +368,14 @@ inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
 
 
 // Mat3
 // Mat3
 inline Vec3 Vec3::getTransformed(const Vec3& translate, const Mat3& rotate,
 inline Vec3 Vec3::getTransformed(const Vec3& translate, const Mat3& rotate,
-	float scale) const
+	F32 scale) const
 {
 {
 	return (rotate * ((*this) * scale)) + translate;
 	return (rotate * ((*this) * scale)) + translate;
 }
 }
 
 
 // Mat3
 // Mat3
 inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
 inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
-	float scale)
+	F32 scale)
 {
 {
 	(*this) = getTransformed(translate, rotate, scale);
 	(*this) = getTransformed(translate, rotate, scale);
 }
 }
@@ -390,14 +395,14 @@ inline void Vec3::transform(const Vec3& translate, const Mat3& rotate)
 
 
 // Quat
 // Quat
 inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
 inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
-	float scale) const
+	F32 scale) const
 {
 {
 	return ((*this) * scale).getRotated(rotate) + translate;
 	return ((*this) * scale).getRotated(rotate) + translate;
 }
 }
 
 
 // Quat
 // Quat
 inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
 inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
-	float scale)
+	F32 scale)
 {
 {
 	(*this) = getTransformed(translate, rotate, scale);
 	(*this) = getTransformed(translate, rotate, scale);
 }
 }
@@ -408,7 +413,7 @@ inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	Vec3 out;
 	Vec3 out;
 	Vec4 v4((*this), 1.0);
 	Vec4 v4((*this), 1.0);
-	for(int i = 0; i < 3; i++)
+	for(U i = 0; i < 3; i++)
 	{
 	{
 		_mm_store_ss(&out[i], _mm_dp_ps(transform.getMm(i), v4.getMm(), 0xF1));
 		_mm_store_ss(&out[i], _mm_dp_ps(transform.getMm(i), v4.getMm(), 0xF1));
 	}
 	}
@@ -447,26 +452,26 @@ inline void Vec3::transform(const Transform& transform)
 // Friends                                                                     =
 // Friends                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-// float + Vec3
-inline Vec3 operator+(const float f, const Vec3& v)
+// F32 + Vec3
+inline Vec3 operator+(const F32 f, const Vec3& v)
 {
 {
 	return v + f;
 	return v + f;
 }
 }
 
 
-// float - Vec3
-inline Vec3 operator-(const float f, const Vec3& v)
+// F32 - Vec3
+inline Vec3 operator-(const F32 f, const Vec3& v)
 {
 {
 	return Vec3(f - v.x(), f - v.y(), f - v.z());
 	return Vec3(f - v.x(), f - v.y(), f - v.z());
 }
 }
 
 
-// float * Vec3
-inline Vec3 operator*(const float f, const Vec3& v)
+// F32 * Vec3
+inline Vec3 operator*(const F32 f, const Vec3& v)
 {
 {
 	return v * f;
 	return v * f;
 }
 }
 
 
-// float / Vec3
-inline Vec3 operator/(const float f, const Vec3& v)
+// F32 / Vec3
+inline Vec3 operator/(const F32 f, const Vec3& v)
 {
 {
 	return Vec3(f / v.x(), f / v.y(), f / v.z());
 	return Vec3(f / v.x(), f / v.y(), f / v.z());
 }
 }

+ 42 - 40
include/anki/math/Vec4.h

@@ -15,13 +15,13 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	explicit Vec4();
 	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 F32 x, const F32 y, const F32 z,
+		const F32 w);
+	explicit Vec4(const F32 f);
+	explicit Vec4(const F32 arr[]);
+	explicit Vec4(const Vec2& v2, const F32 z, const F32 w);
 	explicit Vec4(const Vec2& av2, const Vec2& bv2);
 	explicit Vec4(const Vec2& av2, const Vec2& bv2);
-	explicit Vec4(const Vec3& v3, const float w);
+	explicit Vec4(const Vec3& v3, const F32 w);
 	Vec4(const Vec4& b);
 	Vec4(const Vec4& b);
 	explicit Vec4(const Quat& q);
 	explicit Vec4(const Quat& q);
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
@@ -31,20 +31,22 @@ public:
 
 
 	/// @name Accessors
 	/// @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;
+	F32& x();
+	F32 x() const;
+	F32& y();
+	F32 y() const;
+	F32& z();
+	F32 z() const;
+	F32& w();
+	F32 w() const;
+	F32& operator[](const U i);
+	F32 operator[](const U i) const;
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	__m128& getMm();
 	__m128& getMm();
 	const __m128& getMm() const;
 	const __m128& getMm() const;
 #endif
 #endif
+	Vec2 xy() const;
+	Vec3 xyz() const;
 	/// @}
 	/// @}
 
 
 	/// @name Operators with same type
 	/// @name Operators with same type
@@ -59,24 +61,24 @@ public:
 	Vec4 operator/(const Vec4& b) const;
 	Vec4 operator/(const Vec4& b) const;
 	Vec4& operator/=(const Vec4& b);
 	Vec4& operator/=(const Vec4& b);
 	Vec4 operator-() const;
 	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;
+	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
+	/// @name Operators with F32
 	/// @{
 	/// @{
-	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);
+	Vec4 operator+(const F32 f) const;
+	Vec4& operator+=(const F32 f);
+	Vec4 operator-(const F32 f) const;
+	Vec4& operator-=(const F32 f);
+	Vec4 operator*(const F32 f) const;
+	Vec4& operator*=(const F32 f);
+	Vec4 operator/(const F32 f) const;
+	Vec4& operator/=(const F32 f);
 	/// @}
 	/// @}
 
 
 	/// @name Operators with other
 	/// @name Operators with other
@@ -86,18 +88,18 @@ public:
 
 
 	/// @name Other
 	/// @name Other
 	/// @{
 	/// @{
-	float getLength() const;
+	F32 getLength() const;
 	Vec4 getNormalized() const;
 	Vec4 getNormalized() const;
 	void normalize();
 	void normalize();
-	float dot(const Vec4& b) const;
+	F32 dot(const Vec4& b) const;
 	/// @}
 	/// @}
 
 
 	/// @name Friends
 	/// @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 Vec4 operator+(const F32 f, const Vec4& v4);
+	friend Vec4 operator-(const F32 f, const Vec4& v4);
+	friend Vec4 operator*(const F32 f, const Vec4& v4);
+	friend Vec4 operator/(const F32 f, const Vec4& v4);
 	friend std::ostream& operator<<(std::ostream& s, const Vec4& v);
 	friend std::ostream& operator<<(std::ostream& s, const Vec4& v);
 	/// @}
 	/// @}
 
 
@@ -108,10 +110,10 @@ private:
 	{
 	{
 		struct
 		struct
 		{
 		{
-			float x, y, z, w;
+			F32 x, y, z, w;
 		} vec;
 		} vec;
 
 
-		std::array<float, 4> arr;
+		std::array<F32, 4> arr;
 
 
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 		__m128 mm;
 		__m128 mm;
@@ -121,7 +123,7 @@ private:
 };
 };
 /// @}
 /// @}
 
 
-static_assert(sizeof(Vec4) == sizeof(float) * 4, "Incorrect size");
+static_assert(sizeof(Vec4) == sizeof(F32) * 4, "Incorrect size");
 
 
 } // end namespace
 } // end namespace
 
 

+ 63 - 53
include/anki/math/Vec4.inl.h

@@ -16,8 +16,8 @@ inline Vec4::Vec4()
 #endif
 #endif
 }
 }
 
 
-// float
-inline Vec4::Vec4(float f)
+// F32
+inline Vec4::Vec4(F32 f)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	mm = _mm_set1_ps(f);
 	mm = _mm_set1_ps(f);
@@ -26,8 +26,8 @@ inline Vec4::Vec4(float f)
 #endif
 #endif
 }
 }
 
 
-// float[]
-inline Vec4::Vec4(const float arr_[])
+// F32[]
+inline Vec4::Vec4(const F32 arr_[])
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	mm = _mm_load_ps(arr_);
 	mm = _mm_load_ps(arr_);
@@ -39,9 +39,9 @@ inline Vec4::Vec4(const float arr_[])
 #endif
 #endif
 }
 }
 
 
-// float, float, float, float
-inline Vec4::Vec4(const float x_, const float y_, const float z_,
-	const float w_)
+// F32, F32, F32, F32
+inline Vec4::Vec4(const F32 x_, const F32 y_, const F32 z_,
+	const F32 w_)
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
 	mm = _mm_set_ps(w_, z_, y_, x_);
 	mm = _mm_set_ps(w_, z_, y_, x_);
@@ -53,8 +53,8 @@ inline Vec4::Vec4(const float x_, const float y_, const float z_,
 #endif
 #endif
 }
 }
 
 
-// vec2, float, float
-inline Vec4::Vec4(const Vec2& v2, const float z_, const float w_)
+// vec2, F32, F32
+inline Vec4::Vec4(const Vec2& v2, const F32 z_, const F32 w_)
 {
 {
 	x() = v2.x();
 	x() = v2.x();
 	y() = v2.y();
 	y() = v2.y();
@@ -71,8 +71,8 @@ inline Vec4::Vec4(const Vec2& av2, const Vec2& bv2)
 	w() = bv2.y();
 	w() = bv2.y();
 }
 }
 
 
-// vec3, float
-inline Vec4::Vec4(const Vec3& v3, const float w_)
+// vec3, F32
+inline Vec4::Vec4(const Vec3& v3, const F32 w_)
 {
 {
 	x() = v3.x();
 	x() = v3.x();
 	y() = v3.y();
 	y() = v3.y();
@@ -114,52 +114,52 @@ inline Vec4::Vec4(const __m128& mm_)
 // Accessors                                                                   =
 // Accessors                                                                   =
 //==============================================================================
 //==============================================================================
 
 
-inline float& Vec4::operator[](const size_t i)
+inline F32& Vec4::operator[](const U i)
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
-inline float Vec4::operator[](const size_t i) const
+inline F32 Vec4::operator[](const U i) const
 {
 {
 	return arr[i];
 	return arr[i];
 }
 }
 
 
-inline float& Vec4::x()
+inline F32& Vec4::x()
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float Vec4::x() const
+inline F32 Vec4::x() const
 {
 {
 	return vec.x;
 	return vec.x;
 }
 }
 
 
-inline float& Vec4::y()
+inline F32& Vec4::y()
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float Vec4::y() const
+inline F32 Vec4::y() const
 {
 {
 	return vec.y;
 	return vec.y;
 }
 }
 
 
-inline float& Vec4::z()
+inline F32& Vec4::z()
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float Vec4::z() const
+inline F32 Vec4::z() const
 {
 {
 	return vec.z;
 	return vec.z;
 }
 }
 
 
-inline float& Vec4::w()
+inline F32& Vec4::w()
 {
 {
 	return vec.w;
 	return vec.w;
 }
 }
 
 
-inline float Vec4::w() const
+inline F32 Vec4::w() const
 {
 {
 	return vec.w;
 	return vec.w;
 }
 }
@@ -177,6 +177,16 @@ inline const __m128& Vec4::getMm() const
 }
 }
 #endif
 #endif
 
 
+inline Vec2 Vec4::xy() const
+{
+	return Vec2(x(), y());
+}
+
+inline Vec3 Vec4::xyz() const
+{
+	return Vec3(x(), y(), z());
+}
+
 //==============================================================================
 //==============================================================================
 // Operators with same                                                         =
 // Operators with same                                                         =
 //==============================================================================
 //==============================================================================
@@ -298,7 +308,7 @@ inline Vec4 Vec4::operator-() const
 }
 }
 
 
 // ==
 // ==
-inline bool Vec4::operator==(const Vec4& b) const
+inline Bool Vec4::operator==(const Vec4& b) const
 {
 {
 	Vec4 sub = (*this) - b;
 	Vec4 sub = (*this) - b;
 	return Math::isZero(sub.x()) 
 	return Math::isZero(sub.x()) 
@@ -308,74 +318,74 @@ inline bool Vec4::operator==(const Vec4& b) const
 }
 }
 
 
 // !=
 // !=
-inline bool Vec4::operator!=(const Vec4& b) const
+inline Bool Vec4::operator!=(const Vec4& b) const
 {
 {
 	return !operator==(b);
 	return !operator==(b);
 }
 }
 
 
 // <
 // <
-inline bool Vec4::operator<(const Vec4& b) const
+inline Bool Vec4::operator<(const Vec4& b) const
 {
 {
 	return x() < b.x() && y() < b.y() && z() < b.z() && w() < b.w();
 	return x() < b.x() && y() < b.y() && z() < b.z() && w() < b.w();
 }
 }
 
 
 // <=
 // <=
-inline bool Vec4::operator<=(const Vec4& b) const
+inline Bool Vec4::operator<=(const Vec4& b) const
 {
 {
 	return x() <= b.x() && y() <= b.y() && z() <= b.z() && w() <= b.w();
 	return x() <= b.x() && y() <= b.y() && z() <= b.z() && w() <= b.w();
 }
 }
 
 
 //==============================================================================
 //==============================================================================
-// Operators with float                                                        =
+// Operators with F32                                                        =
 //==============================================================================
 //==============================================================================
 
 
-// Vec4 + float
-inline Vec4 Vec4::operator+(const float f) const
+// Vec4 + F32
+inline Vec4 Vec4::operator+(const F32 f) const
 {
 {
 	return (*this) + Vec4(f);
 	return (*this) + Vec4(f);
 }
 }
 
 
-// Vec4 += float
-inline Vec4& Vec4::operator+=(const float f)
+// Vec4 += F32
+inline Vec4& Vec4::operator+=(const F32 f)
 {
 {
 	(*this) += Vec4(f);
 	(*this) += Vec4(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// Vec4 - float
-inline Vec4 Vec4::operator-(const float f) const
+// Vec4 - F32
+inline Vec4 Vec4::operator-(const F32 f) const
 {
 {
 	return (*this) - Vec4(f);
 	return (*this) - Vec4(f);
 }
 }
 
 
-// Vec4 -= float
-inline Vec4& Vec4::operator-=(const float f)
+// Vec4 -= F32
+inline Vec4& Vec4::operator-=(const F32 f)
 {
 {
 	(*this) -= Vec4(f);
 	(*this) -= Vec4(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// Vec4 * float
-inline Vec4 Vec4::operator*(const float f) const
+// Vec4 * F32
+inline Vec4 Vec4::operator*(const F32 f) const
 {
 {
 	return (*this) * Vec4(f);
 	return (*this) * Vec4(f);
 }
 }
 
 
-// Vec4 *= float
-inline Vec4& Vec4::operator*=(const float f)
+// Vec4 *= F32
+inline Vec4& Vec4::operator*=(const F32 f)
 {
 {
 	(*this) *= Vec4(f);
 	(*this) *= Vec4(f);
 	return (*this);
 	return (*this);
 }
 }
 
 
-// Vec4 / float
-inline Vec4 Vec4::operator/(const float f) const
+// Vec4 / F32
+inline Vec4 Vec4::operator/(const F32 f) const
 {
 {
 	return (*this) / Vec4(f);
 	return (*this) / Vec4(f);
 }
 }
 
 
-// Vec4 /= float
-inline Vec4& Vec4::operator/=(const float f)
+// Vec4 /= F32
+inline Vec4& Vec4::operator/=(const F32 f)
 {
 {
 	(*this) /= Vec4(f);
 	(*this) /= Vec4(f);
 	return (*this);
 	return (*this);
@@ -400,10 +410,10 @@ inline Vec4 Vec4::operator*(const Mat4& m4) const
 //==============================================================================
 //==============================================================================
 
 
 // dot
 // dot
-inline float Vec4::dot(const Vec4& b) const
+inline F32 Vec4::dot(const Vec4& b) const
 {
 {
 #if defined(ANKI_MATH_INTEL_SIMD)
 #if defined(ANKI_MATH_INTEL_SIMD)
-	float o;
+	F32 o;
 	_mm_store_ss(&o, _mm_dp_ps(mm, b.mm, 0xF1));
 	_mm_store_ss(&o, _mm_dp_ps(mm, b.mm, 0xF1));
 	return o;
 	return o;
 #else
 #else
@@ -412,7 +422,7 @@ inline float Vec4::dot(const Vec4& b) const
 }
 }
 
 
 // getLength
 // getLength
-inline float Vec4::getLength() const
+inline F32 Vec4::getLength() const
 {
 {
 	return Math::sqrt(dot((*this)));
 	return Math::sqrt(dot((*this)));
 }
 }
@@ -433,26 +443,26 @@ inline void Vec4::normalize()
 // Friends                                                                     =
 // Friends                                                                     =
 //==============================================================================
 //==============================================================================
 
 
-// float + Vec4
-inline Vec4 operator+(const float f, const Vec4& v4)
+// F32 + Vec4
+inline Vec4 operator+(const F32 f, const Vec4& v4)
 {
 {
 	return v4 + f;
 	return v4 + f;
 }
 }
 
 
-// float - Vec4
-inline Vec4 operator-(const float f, const Vec4& v4)
+// F32 - Vec4
+inline Vec4 operator-(const F32 f, const Vec4& v4)
 {
 {
 	return Vec4(f) - v4;
 	return Vec4(f) - v4;
 }
 }
 
 
-// float * Vec4
-inline Vec4 operator*(const float f, const Vec4& v4)
+// F32 * Vec4
+inline Vec4 operator*(const F32 f, const Vec4& v4)
 {
 {
 	return v4 * f;
 	return v4 * f;
 }
 }
 
 
-// float / Vec4
-inline Vec4 operator/(const float f, const Vec4& v4)
+// F32 / Vec4
+inline Vec4 operator/(const F32 f, const Vec4& v4)
 {
 {
 	return Vec4(f) / v4;
 	return Vec4(f) / v4;
 }
 }

+ 11 - 7
include/anki/renderer/Is.h

@@ -10,6 +10,7 @@
 #include "anki/renderer/Sm.h"
 #include "anki/renderer/Sm.h"
 #include "anki/renderer/Smo.h"
 #include "anki/renderer/Smo.h"
 #include "anki/util/StdTypes.h"
 #include "anki/util/StdTypes.h"
+#include "anki/util/Array.h"
 
 
 namespace anki {
 namespace anki {
 
 
@@ -66,9 +67,9 @@ private:
 		/// @note The coords are in NDC
 		/// @note The coords are in NDC
 		/// @note coords[0] is the bottom left coord, and the coords[1] the 
 		/// @note coords[0] is the bottom left coord, and the coords[1] the 
 		///       top right
 		///       top right
-		Vec2 coords[2]; 
+		Array<Vec2, 2> coords;
 
 
-		std::array<U32, MAX_LIGHTS_PER_TILE> lightIndices;
+		Array<U32, MAX_LIGHTS_PER_TILE> lightIndices;
 		U lightsCount = 0;
 		U lightsCount = 0;
 	};
 	};
 
 
@@ -101,7 +102,7 @@ private:
 	ShaderProgramResourcePointer minMaxPassSprog;
 	ShaderProgramResourcePointer minMaxPassSprog;
 
 
 	/// Light shaders
 	/// Light shaders
-	std::array<ShaderProgramResourcePointer, LST_COUNT> lightSProgs;
+	Array<ShaderProgramResourcePointer, LST_COUNT> lightSProgs;
 
 
 	Sm sm;
 	Sm sm;
 
 
@@ -110,25 +111,28 @@ private:
 		const Sphere& sphere, Vec2& circleCenter, F32& circleRadius);
 		const Sphere& sphere, Vec2& circleCenter, F32& circleRadius);
 	/// Project a perspective frustum to a triangle
 	/// Project a perspective frustum to a triangle
 	static void projectShape(const Mat4& projectionMat,
 	static void projectShape(const Mat4& projectionMat,
-		const PerspectiveFrustum& fr, std::array<Vec2, 3>& coords);
+		const PerspectiveFrustum& fr, Array<Vec2, 3>& coords);
 
 
 	/// For intersecting of point lights
 	/// For intersecting of point lights
 	static Bool circleIntersects(const Tile& tile, const Vec2& circleCenter, 
 	static Bool circleIntersects(const Tile& tile, const Vec2& circleCenter, 
 		F32 circleRadius);
 		F32 circleRadius);
 	/// For intersecting of spot lights
 	/// For intersecting of spot lights
 	static Bool triangleIntersects(const Tile& tile, 
 	static Bool triangleIntersects(const Tile& tile, 
-		const std::array<Vec2, 3>& coords);
+		const Array<Vec2, 3>& coords);
 
 
 	/// Fill the minMaxFai
 	/// Fill the minMaxFai
 	void minMaxPass();
 	void minMaxPass();
 
 
-	/// See if the light is inside the tile and if it is assign it to the tile
-	void cullLight(Tile& tile, Light& light);
+	/// See if the light is inside the tile
+	Bool cullLight(const PointLight& light, const Tile& tile);
+	Bool cullLight(const SpotLight& light, const Tile& tile);
 
 
 	/// Do the light culling
 	/// Do the light culling
 	void tileCulling();
 	void tileCulling();
 
 
 	void initInternal(const RendererInitializer& initializer);
 	void initInternal(const RendererInitializer& initializer);
+
+	void pointLightsPass();
 };
 };
 
 
 } // end namespace anki
 } // end namespace anki

+ 5 - 0
include/anki/scene/Light.h

@@ -145,6 +145,11 @@ public:
 		sphereW.setRadius(x);
 		sphereW.setRadius(x);
 		spatialMarkUpdated();
 		spatialMarkUpdated();
 	}
 	}
+
+	const Sphere& getSphere() const
+	{
+		return sphereW;
+	}
 	/// @}
 	/// @}
 
 
 	/// @name Movable virtuals
 	/// @name Movable virtuals

+ 5 - 2
include/anki/util/StdTypes.h

@@ -6,19 +6,21 @@
 
 
 namespace anki {
 namespace anki {
 
 
+/// @addtogroup util
+/// @{
 typedef int8_t I8;
 typedef int8_t I8;
 typedef int16_t I16;
 typedef int16_t I16;
 typedef int32_t I32;
 typedef int32_t I32;
 typedef int64_t I64;
 typedef int64_t I64;
 
 
-typedef int_fast32_t I; ///< Fast integer
+typedef int_fast32_t I; ///< Fast integer at least 32bit
 
 
 typedef uint8_t U8;
 typedef uint8_t U8;
 typedef uint16_t U16;
 typedef uint16_t U16;
 typedef uint32_t U32;
 typedef uint32_t U32;
 typedef uint64_t U64;
 typedef uint64_t U64;
 
 
-typedef uint_fast32_t U; ///< fast unigned integer
+typedef uint_fast32_t U; ///< fast unsigned integer at least 32bit
 
 
 typedef size_t PtrSize; ///< Like size_t
 typedef size_t PtrSize; ///< Like size_t
 
 
@@ -26,6 +28,7 @@ typedef float F32;
 typedef double F64;
 typedef double F64;
 
 
 typedef bool Bool;
 typedef bool Bool;
+/// @}
 
 
 } // end namespace anki
 } // end namespace anki
 
 

+ 22 - 3
src/renderer/Dbg.cpp

@@ -90,17 +90,36 @@ void Dbg::run()
 	Vec4 l = cam.getViewProjectionMatrix() * Vec4(0.0, 0.0, 0.0, 1.0);
 	Vec4 l = cam.getViewProjectionMatrix() * Vec4(0.0, 0.0, 0.0, 1.0);
 	l /= l.w();
 	l /= l.w();
 
 
-	std::cout << (p1 - p0).getLength() << ", " << l << std::endl;
+	//std::cout << (p1 - p0).getLength() << ", " << l << std::endl;
+
+	//
+	F32 r = s.getRadius();
+	Vec3 e = cam.getWorldTransform().getOrigin();
+	Vec4 c(s.getCenter(), 1.0);
+	Vec4 a = Vec4(c.xyz() + cam.getWorldTransform().getRotation() * Vec3(r, 0.0, 0.0), 1.0);
+
+	c = cam.getViewProjectionMatrix() * c;
+	c /= c.w();
+
+	a = cam.getViewProjectionMatrix() * a;
+	a /= a.w();
+
+	Vec2 circleCenter = c.xy();
+	F32 circleRadius = (c.xy() - a.xy()).getLength();
+	//
 
 
 	drawer->setViewProjectionMatrix(Mat4::getIdentity());
 	drawer->setViewProjectionMatrix(Mat4::getIdentity());
 	drawer->setModelMatrix(Mat4::getIdentity());
 	drawer->setModelMatrix(Mat4::getIdentity());
 
 
-	drawer->drawLine(Vec3(p0.x(), p0.y(), 0.0),
+	/*drawer->drawLine(Vec3(p0.x(), p0.y(), 0.0),
 		Vec3(p0.x(), p0.y(), 0.0) + Vec3(2.0 / w, 0.0, 0.0),
 		Vec3(p0.x(), p0.y(), 0.0) + Vec3(2.0 / w, 0.0, 0.0),
 		Vec4(0.0, 1.0, 0.0, 0.0));
 		Vec4(0.0, 1.0, 0.0, 0.0));
 
 
 	drawer->drawLine(Vec3(p0.x(), p0.y(), 0.0),
 	drawer->drawLine(Vec3(p0.x(), p0.y(), 0.0),
-		Vec3(p1.x(), p1.y(), 0.0), Vec4(0.0, 1.0, 1.0, 0.0));
+		Vec3(p1.x(), p1.y(), 0.0), Vec4(0.0, 1.0, 1.0, 0.0));*/
+
+	drawer->drawLine(Vec3(circleCenter, 0.0),
+		Vec3(circleCenter, 0.0) + Vec3(circleRadius, 0.0, 0.0), Vec4(0.0, 1.0, 1.0, 0.0));
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 70 - 13
src/renderer/Is.cpp

@@ -128,8 +128,6 @@ void Is::initInternal(const RendererInitializer& initializer)
 		GL_RGB, GL_UNSIGNED_INT, fai);
 		GL_RGB, GL_UNSIGNED_INT, fai);
 	fbo.create();
 	fbo.create();
 	fbo.setColorAttachments({&fai});
 	fbo.setColorAttachments({&fai});
-	fbo.setOtherAttachment(GL_DEPTH_STENCIL_ATTACHMENT,
-		r->getMs().getDepthFai());
 
 
 	if(!fbo.isComplete())
 	if(!fbo.isComplete())
 	{
 	{
@@ -176,6 +174,7 @@ void Is::initInternal(const RendererInitializer& initializer)
 	{
 	{
 		for(U j = 0; j < TILES_Y_COUNT; j++)
 		for(U j = 0; j < TILES_Y_COUNT; j++)
 		{
 		{
+			// XXX
 		}
 		}
 	}
 	}
 }
 }
@@ -185,9 +184,9 @@ void Is::projectShape(const Camera& cam,
 	const Sphere& sphere, Vec2& circleCenter, F32& circleRadius)
 	const Sphere& sphere, Vec2& circleCenter, F32& circleRadius)
 {
 {
 	F32 r = sphere.getRadius();
 	F32 r = sphere.getRadius();
-	Vec4 e(cam.getWorldTransform().getOrigin(), 1.0);
 	Vec4 c(sphere.getCenter(), 1.0);
 	Vec4 c(sphere.getCenter(), 1.0);
-	Vec4 a = c + (c - e).getNormalized() * r;
+	Vec4 a = Vec4(sphere.getCenter()
+		+ cam.getWorldTransform().getRotation() * Vec3(r, 0.0, 0.0), 1.0);
 
 
 	c = cam.getViewProjectionMatrix() * c;
 	c = cam.getViewProjectionMatrix() * c;
 	c /= c.w();
 	c /= c.w();
@@ -195,8 +194,27 @@ void Is::projectShape(const Camera& cam,
 	a = cam.getViewProjectionMatrix() * a;
 	a = cam.getViewProjectionMatrix() * a;
 	a /= a.w();
 	a /= a.w();
 
 
-	circleCenter = Vec2(c.x(), c.y());
-	circleRadius = (c - a).getLength();
+	circleCenter = c.xy();
+	circleRadius = (c.xy() - a.xy()).getLength();
+}
+
+//==============================================================================
+Bool Is::circleIntersects(const Tile& tile, const Vec2& circleCenter,
+	F32 circleRadius)
+{
+	// XXX
+	return true;
+}
+
+//==============================================================================
+Bool Is::cullLight(const PointLight& light, const Tile& tile)
+{
+	const Camera& cam = r->getScene().getActiveCamera();
+	Vec2 cc;
+	F32 r;
+	const PointLight& plight = static_cast<const PointLight&>(light);
+	projectShape(cam, plight.getSphere(), cc, r);
+	return circleIntersects(tile, cc, r);
 }
 }
 
 
 //==============================================================================
 //==============================================================================
@@ -206,8 +224,6 @@ void Is::minMaxPass()
 	//
 	//
 	const Camera& cam = r->getScene().getActiveCamera();
 	const Camera& cam = r->getScene().getActiveCamera();
 
 
-	GlStateSingleton::get().disable(GL_DEPTH_TEST);
-
 	minMaxTilerFbo.bind();
 	minMaxTilerFbo.bind();
 	minMaxPassSprog->bind();
 	minMaxPassSprog->bind();
 	GlStateSingleton::get().setViewport(0, 0, TILES_X_COUNT, TILES_Y_COUNT);
 	GlStateSingleton::get().setViewport(0, 0, TILES_X_COUNT, TILES_Y_COUNT);
@@ -236,17 +252,58 @@ void Is::minMaxPass()
 	}
 	}
 }
 }
 
 
+//==============================================================================
+void Is::pointLightsPass()
+{
+	Camera& cam = r->getScene().getActiveCamera();
+	VisibilityInfo& vi = cam.getFrustumable()->getVisibilityInfo();
+
+	for(U i = 0; i < TILES_X_COUNT; i++)
+	{
+		for(U j = 0; j < TILES_Y_COUNT; j++)
+		{
+			Tile& tile = tiles[i][j];
+
+			U lightsCount = 0;
+			U ids = 0;
+
+			for(auto it = vi.getLightsBegin(); it != vi.getLightsEnd(); ++it)
+			{
+				const Light& light = *(*it);
+				if(light.getLightType() != Light::LT_POINT)
+				{
+					continue;
+				}
+
+				const PointLight& plight =
+					static_cast<const PointLight&>(light);
+
+				if(cullLight(plight, tile))
+				{
+					tile.lightIndices[ids] = lightsCount;
+					++ids;
+				}
+
+				++lightsCount;
+			}
+
+			tile.lightsCount = lightsCount;
+		}
+	}
+}
+
 //==============================================================================
 //==============================================================================
 void Is::run()
 void Is::run()
 {
 {
-	/*fbo.bind();
-	GlStateSingleton::get().setViewport(0, 0, r->getWidth(), r->getHeight());
-	const Camera& cam = r->getScene().getActiveCamera();*/
+	GlStateSingleton::get().disable(GL_DEPTH_TEST);
+	GlStateSingleton::get().disable(GL_BLEND);
 
 
-	//minMaxPass();
+	minMaxPass();
 
 
 	fbo.bind();
 	fbo.bind();
-	glClear(GL_COLOR_BUFFER_BIT);
+	GlStateSingleton::get().setViewport(0, 0, r->getWidth(), r->getHeight());
+
+	pointLightsPass();
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki