Jelajahi Sumber

Refactoring

Panagiotis Christopoulos Charitos 15 tahun lalu
induk
melakukan
154d65649a

+ 1 - 3
src/Math/Axisang.h

@@ -8,9 +8,7 @@
 namespace M {
 
 
-/**
- * @brief Used for rotations
- */
+/// Used for rotations
 class Axisang
 {
 	public:

+ 1 - 3
src/Math/Euler.h

@@ -8,9 +8,7 @@
 namespace M {
 
 
-/**
- * @brief Usef for rotations. It cannot describe a rotation accurately though
- */
+/// Used for rotations. It cannot describe a rotation accurately though
 class Euler
 {
 	public:

+ 1 - 3
src/Math/Mat3.h

@@ -8,9 +8,7 @@
 namespace M {
 
 
-/**
- * @brief Mainly used for rotations. It includes many helpful member functions
- */
+/// Mainly used for rotations. It includes many helpful member functions
 class Mat3
 {
 	private:

+ 1 - 3
src/Math/Mat4.h

@@ -8,9 +8,7 @@
 namespace M {
 
 
-/**
- * @brief Used mainly for transformations but not necessarily
- */
+/// Used mainly for transformations but not necessarily
 class Mat4
 {
 	private:

+ 5 - 0
src/Math/MathDfltHeader.h

@@ -1,3 +1,8 @@
+/**
+ * @file
+ * For Internal use in math lib
+ */
+
 #include "Vec2.h"
 #include "Vec3.h"
 #include "Vec4.h"

+ 5 - 0
src/Math/MathForwardDecls.h

@@ -1,3 +1,8 @@
+/**
+ * @file
+ * For Internal use in math lib
+ */
+
 #ifndef _MATHFORWARDDECLS_H_
 #define _MATHFORWARDDECLS_H_
 

+ 7 - 7
src/Math/MathFuncs.h

@@ -12,25 +12,25 @@ const float PI = 3.14159265358979323846;
 const float EPSILON = 1.0e-6;
 
 
-void  mathSanityChecks();
-void  sinCos( float rad, float& sin_, float& cos_ );
-float invSqrt( float f );
-float sqrt( float f );
+void  mathSanityChecks(); ///< Used to test the compiler
+void  sinCos( float rad, float& sin_, float& cos_ ); ///< A fast func that given the angle in rads it returns the sin and cos
+float invSqrt( float f ); ///< Inverted square root
+float sqrt( float f ); ///< Square root
 float toRad( float degrees );
 float toDegrees( float rad );
 float sin( float rad );
 float cos( float rad );
-bool  isZero( float f );
+bool  isZero( float f ); ///< The proper way to test if a float is zero
 
 /**
- * @brief mat4(t0,r0,s0)*mat4(t1,r1,s1) == mat4(tf,rf,sf)
+ * mat4(t0,r0,s0)*mat4(t1,r1,s1) == mat4(tf,rf,sf)
  */
 void combineTransformations( const Vec3& t0, const Mat3& r0, float s0, // in 0
                              const Vec3& t1, const Mat3& r1, float s1, // in 1
                              Vec3& tf, Mat3& rf, float& sf ); // out
 
 /**
- * @brief 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)
  */
 void combineTransformations( const Vec3& t0, const Mat3& r0, // in 0
                              const Vec3& t1, const Mat3& r1, // in 1

+ 1 - 3
src/Math/Quat.h

@@ -8,9 +8,7 @@
 namespace M {
 
 
-/**
- * Used in rotations
- */
+/// Used in rotations
 class Quat
 {
 	public:

+ 1 - 3
src/Math/Transform.h

@@ -8,9 +8,7 @@
 namespace M {
 
 
-/**
- * @brief For transformations
- */
+/// For transformations
 class Transform
 {
 	PROPERTY_RW( Mat3, rotation, setRotation, getRotation ) ///< @ref PROPERTY_RW : The rotation

+ 1 - 0
src/Math/Vec2.h

@@ -8,6 +8,7 @@
 namespace M {
 
 
+/// 2D vector
 class Vec2
 {
 	public:

+ 1 - 0
src/Math/Vec3.h

@@ -8,6 +8,7 @@
 namespace M {
 
 
+/// 3D vector. One of the most used classes
 class Vec3
 {
 	public:

+ 1 - 0
src/Math/Vec4.h

@@ -8,6 +8,7 @@
 namespace M {
 
 
+/// 4D vector
 class Vec4
 {
 	public:

+ 23 - 18
src/Util/Common.h

@@ -52,7 +52,7 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
 	#define __G_FUNCTION__ __func__
 #endif
 
-#if defined( _TERMINAL_COLORING_ )
+#if defined( _TERMINAL_COLORING_ ) && defined( _PLATFORM_LINUX_ )
 		// for the colors and formating see http://www.dreamincode.net/forums/showtopic75171.htm
     #define COL_ERROR "\033[6;31;6m"
     #define COL_WARNING "\033[6;33;6m"
@@ -69,29 +69,31 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
     #define COL_DEFAULT ""
 #endif
 
+/// For internal use
 #define GENERAL_ERR( x, y, col ) \
 	cerr << col << x << " (" << __FILENAME__ << ":" << __LINE__ << " " << __G_FUNCTION__ << "): " << y << COL_DEFAULT << endl;
 
+/// For internal use
 #define GENERAL_MSG( x, y, col ) \
 	cout << col << x << " (" << __FILENAME__ << ":" << __LINE__ << " " << __G_FUNCTION__ << "): " << y << COL_DEFAULT << endl;
 
-/// in ERROR you can write something like this: ERROR( "tralala" << 10 << ' ' )
+/// Use it like this: ERROR( "tralala" << 10 << ' ' )
 #define ERROR( x ) GENERAL_ERR( "Error", x, COL_ERROR )
 
-/// WARNING
+/// Show a warning
 #define WARNING( x ) GENERAL_ERR( "Warning", x, COL_WARNING );
 
-/// FATAL ERROR
+/// Show an error and exit application
 #define FATAL( x ) { GENERAL_ERR( "Fatal", x << ". Bye!", COL_FATAL ); exit( EXIT_FAILURE ); };
 
-/// INFO
+/// Show an info message
 #define INFO( x ) { GENERAL_MSG( "Info", x, COL_INFO ) }
 
-/// DEBUG_ERR
+/// Reverse assertion
 #ifdef _DEBUG_
 	#define DEBUG_ERR( x ) \
 		if( x ) \
-			GENERAL_ERR( "Assertion", #x, COL_DEBUG_ERR );
+			GENERAL_ERR( "Debug err", #x, COL_DEBUG_ERR );
 #else
     #define DEBUG_ERR( x )
 #endif
@@ -110,12 +112,12 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
 
 
 /**
- * @brief Read write property
+ * Read write property
  *
- * - It concatenates and creates a unique type so it can accept pointers
+ * - It creates a unique type so it can work with pointers
  * - The get funcs are coming into two flavors, one const and one non-const. The property is read-write after all so the non-const is
  *   acceptable
- * - Dont use it with semicolon at the end eg PROPERTY_RW( .... );
+ * - Dont use it with semicolon at the end (eg PROPERTY_RW( .... );) because of a doxygen bug
  */
 #define PROPERTY_RW( __Type__, __varName__, __setFunc__, __getFunc__ ) \
 	private: \
@@ -133,10 +135,10 @@ extern string getFunctionFromPrettyFunction( const char* pretty_function );
 		}
 
 /**
- * @brief Read only property
+ * Read only property
  *
- * - It concatenates and creates a unique type so it can accept pointers
- * - Dont use it with semicolon at the end eg PROPERTY_R( .... );
+ * - It creates a unique type so it can work with pointers
+ * - Dont use it with semicolon at the end (eg PROPERTY_RW( .... );) because of a doxygen bug
  */
 #define PROPERTY_R( __Type__, __varName__, __getFunc__ ) \
 	private: \
@@ -170,7 +172,7 @@ template <typename Type> inline void MemZero( Type& t )
 // Vec                                                                                                                              =
 //=====================================================================================================================================
 /**
- * @brief This is a wrapper of std::vector that adds new functionality
+ * This is a wrapper of std::vector that adds new functionality
  */
 template<typename Type> class Vec: public vector<Type>
 {
@@ -198,9 +200,9 @@ template<typename Type> class Vec: public vector<Type>
 };
 
 
-//====================================================================================================================================
-// Memory allocation information for Linux                                                                                           =
-//====================================================================================================================================
+//=====================================================================================================================================
+// Memory allocation information for Linux                                                                                            =
+//=====================================================================================================================================
 #if defined( _PLATFORM_LINUX_ )
 
 #include <malloc.h>
@@ -234,8 +236,11 @@ inline void printMallInfoDiff( const Mallinfo& prev, const Mallinfo& now )
 
 
 //=====================================================================================================================================
-//                                                                                                                                    =
+// Application                                                                                                                        =
 //=====================================================================================================================================
+/**
+ * The only public variable @see App
+ */
 extern class App* app;
 
 

+ 2 - 4
src/Util/Input.h

@@ -6,10 +6,9 @@
 #include "App.h"
 #include "Math.h"
 
-/// input namespace
+/// Handle the SDL input
 namespace I {
 
-
 extern void reset();
 extern void handleEvents();
 
@@ -24,7 +23,6 @@ extern Vec2 mouseVelocity;
 extern bool warpMouse;
 extern bool hideCursor;
 
-
-
 } // end namespace
+
 #endif

+ 0 - 2
src/Util/Util.cpp

@@ -71,7 +71,6 @@ Vec<string> getFileLines( const char* filename )
 //=====================================================================================================================================
 // cutPath                                                                                                                            =
 //=====================================================================================================================================
-/// Used only to cut the path from __FILE__ and return the actual file name and some other cases
 char* cutPath( const char* path )
 {
 	char* str = (char*)path + strlen(path) - 1;
@@ -107,7 +106,6 @@ string getPath( const char* path )
 //=====================================================================================================================================
 // getFunctionFromPrettyFunction                                                                                                      =
 //=====================================================================================================================================
-/// The function gets __PRETTY_FUNCTION__ and strips it to get only the function name with its namespace
 string getFunctionFromPrettyFunction( const char* prettyFunction )
 {
 	string ret( prettyFunction );

+ 15 - 12
src/Util/Util.h

@@ -3,21 +3,24 @@
 
 #include "Common.h"
 
+/**
+ * The namespace contains a few useful functions
+ */
 namespace Util {
 
-extern int    randRange( int min, int max );
-extern uint   randRange( uint min, uint max );
-extern float  randRange( float min, float max );
-extern double randRange( double min, double max );
+extern int    randRange( int min, int max ); ///< Pick a random number from min to max
+extern uint   randRange( uint min, uint max ); ///< Pick a random number from min to max
+extern float  randRange( float min, float max ); ///< Pick a random number from min to max
+extern double randRange( double min, double max ); ///< Pick a random number from min to max
 
-extern string      readFile( const char* filename );
-extern Vec<string> getFileLines( const char* filename );
-extern char*       getFileExtension( const char* path );
-extern char*       cutPath( const char* path );
-extern string      getPath( const char* path );
-extern string      getFunctionFromPrettyFunction( const char* pretty_function );
-extern string      intToStr( int );
-extern string      floatToStr( float );
+extern string      readFile( const char* filename ); ///< Open a text file and return its contents into a string
+extern Vec<string> getFileLines( const char* filename ); ///< Open a text file and return its lines into a string vector
+extern char*       getFileExtension( const char* path ); ///< Self explanatory
+extern char*       cutPath( const char* path ); ///< Given a full path return only the file. Used only to cut the path from __FILE__ and return the actual file name and some other cases
+extern string      getPath( const char* path ); ///< Get a file and get its path
+extern string      getFunctionFromPrettyFunction( const char* pretty_function ); /// The function gets __PRETTY_FUNCTION__ and strips it to get only the function name with its namespace
+extern string      intToStr( int ); ///< Self explanatory
+extern string      floatToStr( float ); ///< Self explanatory
 
 }