فهرست منبع

Remove Str dependecy from math

Daniele Bartolini 13 سال پیش
والد
کامیت
5ecadc8bfd

+ 0 - 12
src/core/math/Color4.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "MathUtils.h"
-#include "Str.h"
 
 namespace crown
 {
@@ -82,7 +81,6 @@ public:
 
 	float*					to_float_ptr();								//!< Returns the point32_ter to the color's data.
 	const float*			to_float_ptr() const;							//!< Returns the point32_ter to the color's data.
-	Str						to_str() const;								//!< Returns a Str containing the colors' components.
 
 	// SVG 1.0 color names
 	static const Color4		ALICEBLUE;
@@ -315,16 +313,6 @@ inline const float* Color4::to_float_ptr() const
 	return &r;
 }
 
-//-----------------------------------------------------------------------------
-inline Str Color4::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ r: ") + r + Str(" g: ") + g + Str(" b: ") + b + Str(" a: ") + a + Str(" ]\n");
-
-	return tmp;
-}
-
 //-----------------------------------------------------------------------------
 inline uint32_t Color4::get_as_rgb() const
 {

+ 0 - 13
src/core/math/Mat3.cpp

@@ -29,7 +29,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Mat4.h"
 #include "MathUtils.h"
 #include "Quat.h"
-#include "Str.h"
 #include "Vec3.h"
 
 namespace crown
@@ -609,17 +608,5 @@ Quat Mat3::to_quat() const
 	return tmp;
 }
 
-//-----------------------------------------------------------------------------
-Str Mat3::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ ") + m[0] + Str(" ") + m[3] + Str(" ") + m[6] + Str(" ]\n");
-	tmp += Str("| ") + m[1] + Str(" ") + m[4] + Str(" ") + m[7] + Str(" |\n");
-	tmp += Str("[ ") + m[2] + Str(" ") + m[5] + Str(" ") + m[8] + Str(" ]\n");
-
-	return tmp;
-}
-
 } // namespace crown
 

+ 0 - 2
src/core/math/Mat3.h

@@ -32,7 +32,6 @@ namespace crown
 
 class Mat4;
 class Quat;
-class Str;
 class Vec3;
 
 /**
@@ -110,7 +109,6 @@ public:
 
 	real*				to_float_ptr();								//!< Returns the point32_ter to the matrix's data
 	const real*			to_float_ptr() const;						//!< Returns the point32_ter to the matrix's data
-	Str					to_str() const;								//!< Returns a Str containing the matrix's components
 	Mat4				to_mat4() const;							//!< Returns a 4x4 matrix according to the matrix's rotation portion
 	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
 

+ 0 - 14
src/core/math/Mat4.cpp

@@ -29,7 +29,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Mat4.h"
 #include "MathUtils.h"
 #include "Quat.h"
-#include "Str.h"
 #include "Vec3.h"
 #include "Vec4.h"
 
@@ -1045,18 +1044,5 @@ Quat Mat4::to_quat() const
 	return tmp;
 }
 
-//-----------------------------------------------------------------------------
-Str Mat4::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ ") + m[0] + Str(" ") + m[4] + Str(" ") + m[8] + Str(" ") + m[12] + Str(" ]\n");
-	tmp += Str("| ") + m[1] + Str(" ") + m[5] + Str(" ") + m[9] + Str(" ") + m[13] + Str(" |\n");
-	tmp += Str("| ") + m[2] + Str(" ") + m[6] + Str(" ") + m[10] + Str(" ") + m[14] + Str(" |\n");
-	tmp += Str("[ ") + m[3] + Str(" ") + m[7] + Str(" ") + m[11] + Str(" ") + m[15] + Str(" ]\n");
-
-	return tmp;
-}
-
 } // namespace crown
 

+ 0 - 2
src/core/math/Mat4.h

@@ -32,7 +32,6 @@ namespace crown
 
 class Mat3;
 class Quat;
-class Str;
 class Vec3;
 class Vec4;
 
@@ -129,7 +128,6 @@ public:
 	const real*			to_float_ptr() const;						//!< Returns the point32_ter to the matrix's data
 	Mat3				to_mat3() const;							//!< Returns a 3x3 matrix according to the matrix's rotation portion
 	Quat				to_quat() const;							//!< Returns a quaternion according to the matrix's rotation portion
-	Str					to_str() const;								//!< Returns a Str containing the matrix's components
 
 	static const Mat4	IDENTITY;
 };

+ 15 - 27
src/core/math/Point2.h

@@ -28,7 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <cassert>
 #include "Types.h"
 #include "MathUtils.h"
-#include "Str.h"
 #include "Vec2.h"
 #include "Vec3.h"
 
@@ -45,23 +44,23 @@ public:
 	int32_t						x, y;
 
 							Point2();							//!< Constructor, does nothing for efficiency
-							Point2(int32_t nx, int32_t ny);				//! Constructs from two components
-							Point2(const int32_t a[2]);				//! Constructs from the array
+							Point2(int32_t nx, int32_t ny);		//! Constructs from two components
+							Point2(const int32_t a[2]);			//! Constructs from the array
 							Point2(const Point2& a);			//! Copy constructor
 							~Point2();							//! Destructor
 
-	int32_t					operator[](uint32_t i) const;			//! Random access by index
-	int32_t&				operator[](uint32_t i);					//! Random access by index
+	int32_t					operator[](uint32_t i) const;		//! Random access by index
+	int32_t&				operator[](uint32_t i);				//! Random access by index
 
 	Point2					operator+(const Point2& a) const;	//! Addition
 	Point2&					operator+=(const Point2& a);		//! Addition
 	Point2					operator-(const Point2& a) const;	//! Subtraction
 	Point2&					operator-=(const Point2& a);		//! Subtraction
-	Point2					operator*(int32_t k) const;				//! Multiplication by scalar
-	Point2&					operator*=(int32_t k);					//! Multiplication by scalar
-	Point2					operator/(int32_t k) const;				//! Division by scalar
-	Point2&					operator/=(int32_t k);					//! Division by scalar
-	int32_t						dot(const Point2& a);				//! dot product
+	Point2					operator*(int32_t k) const;			//! Multiplication by scalar
+	Point2&					operator*=(int32_t k);				//! Multiplication by scalar
+	Point2					operator/(int32_t k) const;			//! Division by scalar
+	Point2&					operator/=(int32_t k);				//! Division by scalar
+	int32_t					dot(const Point2& a);				//! dot product
 
 	friend Point2			operator*(int32_t k, const Point2& a);	//! For simmetry
 
@@ -81,11 +80,10 @@ public:
 
 	void					zero();								//! Builds the zero point32_t
 
-	int32_t*				to_int32_t_ptr();		//! Returns the point32_ter to the point32_t's data
-	const int32_t*			to_int32_t_ptr() const;	//! Returns the point32_ter to the point32_t's data
-	Vec2					to_vec2() const;	//! Returns a vector from this point32_t
-	Vec3					to_vec3() const;	//! Returns a vector from this point32_t
-	Str						to_str() const;		//! Returns a Str containing the point32_t's components
+	int32_t*				to_int_ptr();						//! Returns the point32_ter to the point32_t's data
+	const int32_t*			to_int_ptr() const;					//! Returns the point32_ter to the point32_t's data
+	Vec2					to_vec2() const;					//! Returns a vector from this point32_t
+	Vec3					to_vec3() const;					//! Returns a vector from this point32_t
 
 	static const Point2		ZERO;
 	static const Point2		ONE;
@@ -279,13 +277,13 @@ inline void Point2::zero()
 }
 
 //-----------------------------------------------------------------------------
-inline int32_t* Point2::to_int32_t_ptr()
+inline int32_t* Point2::to_int_ptr()
 {
 	return &x;
 }
 
 //-----------------------------------------------------------------------------
-inline const int32_t* Point2::to_int32_t_ptr() const
+inline const int32_t* Point2::to_int_ptr() const
 {
 	return &x;
 }
@@ -302,15 +300,5 @@ inline Vec3 Point2::to_vec3() const
 	return Vec3((real)x, (real)y, 0.0);
 }
 
-//-----------------------------------------------------------------------------
-inline Str Point2::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ x: ") + x + Str(" y: ") + y + Str(" ]\n");
-
-	return tmp;
-}
-
 } // namespace crown
 

+ 0 - 10
src/core/math/Quat.cpp

@@ -50,16 +50,6 @@ Quat::~Quat()
 {
 }
 
-//-----------------------------------------------------------------------------
-Str Quat::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ x: ") + v.x + Str(" y: ") + v.y + Str(" z: ") + v.z + Str(" w: ") + w + Str(" ]\n");
-
-	return tmp;
-}
-
 //-----------------------------------------------------------------------------
 void Quat::negate()
 {

+ 0 - 2
src/core/math/Quat.h

@@ -72,8 +72,6 @@ public:
 	Quat		operator*(const real& k) const;		//!< Multiplication by a scalar
 
 	Quat		power(real exp);
-
-	Str			to_str() const;						//!< Returns a Str containing the quaternion's components
 };
 
 } // namespace crown

+ 2 - 2
src/core/math/Random.h

@@ -37,11 +37,11 @@ class Random
 {
 public:
 
-			Random(int32_t seed);	//!< Constructor
+				Random(int32_t seed);	//!< Constructor
 
 	int32_t		get_int32_t();			//!< Returns a pseudo-random int32_teger in the range [0, 32767]
 	int32_t		get_int32_t(int32_t max);	//!< Returns a pseudo-random int32_teger in the range [0, max)
-	float	get_unit_float();	//!< Returns a pseudo-random float in the range [0.0, 1.0].
+	float		get_unit_float();	//!< Returns a pseudo-random float in the range [0.0, 1.0].
 
 private:
 

+ 4 - 16
src/core/math/Vec2.h

@@ -28,7 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <cassert>
 #include "Types.h"
 #include "MathUtils.h"
-#include "Str.h"
 
 namespace crown
 {
@@ -67,8 +66,8 @@ public:
 	bool				operator<(const Vec2& other) const;		//!< Returns whether all the components of this vector are smaller than all of the "other" vector
 	bool				operator>(const Vec2& other) const;		//!< Returns whether all the components of this vector are greater than all of the "other" vector
 
-	real				length() const;						//!< Returns the vector's length
-	real				squared_length() const;				//!< Returns the vector's squared length
+	real				length() const;							//!< Returns the vector's length
+	real				squared_length() const;					//!< Returns the vector's squared length
 	void				set_length(real len);					//!< Sets the vector's length
 	real				get_angle() const;
 	real				get_angle_2d() const;
@@ -77,14 +76,13 @@ public:
 	Vec2&				negate();								//!< Negates the vector (i.e. builds the inverse)
 	Vec2				operator-() const;						//!< Negates the vector (i.e. builds the inverse)
 
-	real				get_distance_to(const Vec2& a) const;		//!< Returns the distance
+	real				get_distance_to(const Vec2& a) const;	//!< Returns the distance
 	real				get_angle_between(const Vec2& a) const;	//!< Returns the angle in radians
 
 	void				zero();									//!< Builds the zero vector
 
 	real*				to_float_ptr();							//!< Returns the point32_ter to the vector's data
-	const real*			to_float_ptr() const;						//!< Returns the point32_ter to the vector's data
-	Str					to_str() const;							//!< Returns a Str containing the vector's components
+	const real*			to_float_ptr() const;					//!< Returns the point32_ter to the vector's data
 
 	static const Vec2	ZERO;
 	static const Vec2	ONE;
@@ -339,16 +337,6 @@ inline const real* Vec2::to_float_ptr() const
 	return &x;
 }
 
-//-----------------------------------------------------------------------------
-inline Str Vec2::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ x: ") + x + Str(" y: ") + y + Str(" ]\n");
-
-	return tmp;
-}
-
 //-----------------------------------------------------------------------------
 inline Vec2 get_projected_parallel(const Vec2& v, const Vec2& n)
 {

+ 0 - 12
src/core/math/Vec3.h

@@ -28,7 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <cassert>
 #include "Types.h"
 #include "MathUtils.h"
-#include "Str.h"
 #include "Vec2.h"
 
 namespace crown
@@ -87,7 +86,6 @@ public:
 	real*				to_float_ptr();							//!< Returns the point32_ter to the vector's data
 	const real*			to_float_ptr() const;					//!< Returns the point32_ter to the vector's data
 	Vec2				to_vec2() const;						//!< Returns a Vec2 with only x and y coordinates
-	Str					to_str() const;							//!< Returns a Str containing the vector's components
 
 	static const Vec3	ZERO;
 	static const Vec3	ONE;
@@ -359,16 +357,6 @@ inline Vec2 Vec3::to_vec2() const
 	return Vec2(x, y);
 }
 
-//-----------------------------------------------------------------------------
-inline Str Vec3::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ x: ") + x + Str(" y: ") + y + Str(" z: ") + z + Str(" ]\n");
-
-	return tmp;
-}
-
 //-----------------------------------------------------------------------------
 //!< Returns the parallel portion of "v" projected onto "n"
 inline Vec3 get_projected_parallel(const Vec3& v, const Vec3& n)

+ 1 - 13
src/core/math/Vec4.h

@@ -28,7 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <cassert>
 #include "Types.h"
 #include "MathUtils.h"
-#include "Str.h"
 
 namespace crown
 {
@@ -83,8 +82,7 @@ public:
 	void				zero();										//!< Builds the zero vector
 
 	real*				to_float_ptr();								//!< Returns the point32_ter to the vector's data
-	const real*			to_float_ptr() const;							//!< Returns the point32_ter to the vector's data
-	Str					to_str() const;								//!< Returns a Str containing the vector's components
+	const real*			to_float_ptr() const;						//!< Returns the point32_ter to the vector's data
 
 	static const Vec4	ZERO;
 	static const Vec4	ONE;
@@ -342,15 +340,5 @@ inline const real* Vec4::to_float_ptr() const
 	return &x;
 }
 
-//-----------------------------------------------------------------------------
-inline Str Vec4::to_str() const
-{
-	Str tmp;
-
-	tmp = Str("[ x: ") + x + Str(" y: ") + y + Str(" z: ") + z + Str(" w: ") + w + Str(" ]\n");
-
-	return tmp;
-}
-
 } // namespace crown