Explorar el Código

- Changes in the coding style
- Removing old particles.*
- Enhancing Material, scene ambient col

Panagiotis Christopoulos Charitos hace 15 años
padre
commit
b35854988d
Se han modificado 100 ficheros con 4108 adiciones y 4341 borrados
  1. 394 393
      build/debug/Makefile
  2. 106 107
      src/Main.cpp
  3. 4 4
      src/Math/Axisang.h
  4. 34 34
      src/Math/Axisang.inl.h
  5. 6 6
      src/Math/Euler.h
  6. 25 25
      src/Math/Euler.inl.h
  7. 51 51
      src/Math/Mat3.h
  8. 275 275
      src/Math/Mat3.inl.h
  9. 47 46
      src/Math/Mat4.h
  10. 276 277
      src/Math/Mat4.inl.h
  11. 12 12
      src/Math/MathFuncs.h
  12. 49 26
      src/Math/MathFuncs.inl.h
  13. 18 18
      src/Math/Quat.h
  14. 65 65
      src/Math/Quat.inl.h
  15. 7 7
      src/Math/Transform.h
  16. 6 6
      src/Math/Transform.inl.h
  17. 30 30
      src/Math/Vec2.h
  18. 43 43
      src/Math/Vec2.inl.h
  19. 51 51
      src/Math/Vec3.h
  20. 73 73
      src/Math/Vec3.inl.h
  21. 32 32
      src/Math/Vec4.h
  22. 49 49
      src/Math/Vec4.inl.h
  23. 214 214
      src/Misc/collision.cpp
  24. 95 95
      src/Misc/collision.h
  25. 41 41
      src/Misc/map.cpp
  26. 7 7
      src/Misc/map.h
  27. 166 166
      src/Misc/memory.cpp
  28. 17 17
      src/Misc/memory.h
  29. 0 219
      src/Misc/particles.cpp
  30. 0 82
      src/Misc/particles.h
  31. 28 28
      src/Misc/skybox.cpp
  32. 2 2
      src/Misc/skybox.h
  33. 10 10
      src/Physics/MotionState.h
  34. 7 7
      src/Physics/PhyCharacter.h
  35. 22 22
      src/Physics/PhyConversions.h
  36. 13 13
      src/Physics/PhyWorld.cpp
  37. 7 7
      src/Physics/PhyWorld.h
  38. 20 20
      src/Renderer/BufferObjects/BufferObject.h
  39. 16 16
      src/Renderer/BufferObjects/Fbo.h
  40. 5 5
      src/Renderer/BufferObjects/Vbo.h
  41. 73 73
      src/Renderer/Dbg.cpp
  42. 15 15
      src/Renderer/Ez.cpp
  43. 30 30
      src/Renderer/Hdr.cpp
  44. 99 99
      src/Renderer/Is.cpp
  45. 81 81
      src/Renderer/MainRenderer.cpp
  46. 8 8
      src/Renderer/MainRenderer.h
  47. 34 34
      src/Renderer/Ms.cpp
  48. 26 26
      src/Renderer/Pps.cpp
  49. 107 100
      src/Renderer/Renderer.cpp
  50. 61 60
      src/Renderer/Renderer.h
  51. 2 2
      src/Renderer/RendererInitializer.h
  52. 33 33
      src/Renderer/Sm.cpp
  53. 40 40
      src/Renderer/Smo.cpp
  54. 40 40
      src/Renderer/Ssao.cpp
  55. 9 9
      src/Resources/Extension.cpp
  56. 2 2
      src/Resources/Extension.h
  57. 69 69
      src/Resources/Helpers/Image.cpp
  58. 6 6
      src/Resources/Helpers/Image.h
  59. 128 107
      src/Resources/Helpers/ShaderPrePreprocessor.cpp
  60. 47 35
      src/Resources/Helpers/ShaderPrePreprocessor.h
  61. 30 30
      src/Resources/LightProps.cpp
  62. 8 8
      src/Resources/LightProps.h
  63. 89 86
      src/Resources/Material.cpp
  64. 8 7
      src/Resources/Material.h
  65. 84 84
      src/Resources/Mesh.cpp
  66. 1 1
      src/Resources/Mesh.h
  67. 1 1
      src/Resources/Path.h
  68. 28 28
      src/Resources/Resource.h
  69. 107 107
      src/Resources/ShaderProg.cpp
  70. 34 34
      src/Resources/ShaderProg.h
  71. 19 19
      src/Resources/SkelAnim.cpp
  72. 1 1
      src/Resources/SkelAnim.h
  73. 25 25
      src/Resources/Skeleton.cpp
  74. 4 4
      src/Resources/Skeleton.h
  75. 48 48
      src/Resources/Texture.cpp
  76. 13 13
      src/Resources/Texture.h
  77. 60 60
      src/Scene/Camera.cpp
  78. 11 11
      src/Scene/Camera.h
  79. 5 5
      src/Scene/Controllers/Controller.cpp
  80. 3 3
      src/Scene/Controllers/Controller.h
  81. 2 2
      src/Scene/Controllers/LightPropsScriptCtrl.h
  82. 5 5
      src/Scene/Controllers/MeshSkelNodeCtrl.h
  83. 39 39
      src/Scene/Controllers/SkelAnimCtrl.cpp
  84. 3 3
      src/Scene/Controllers/SkelAnimCtrl.h
  85. 2 2
      src/Scene/Controllers/TrfScriptCtrl.h
  86. 1 1
      src/Scene/GhostNode.h
  87. 11 11
      src/Scene/Light.cpp
  88. 8 8
      src/Scene/Light.h
  89. 51 51
      src/Scene/MeshNode.cpp
  90. 3 3
      src/Scene/MeshNode.h
  91. 49 49
      src/Scene/ParticleEmitter.cpp
  92. 2 2
      src/Scene/ParticleEmitter.h
  93. 31 31
      src/Scene/Scene.cpp
  94. 14 14
      src/Scene/Scene.h
  95. 25 25
      src/Scene/SceneNode.cpp
  96. 13 13
      src/Scene/SceneNode.h
  97. 19 19
      src/Scene/SkelModelNode.cpp
  98. 1 1
      src/Scene/SkelModelNode.h
  99. 15 15
      src/Scene/SkelNode.cpp
  100. 2 2
      src/Scene/SkelNode.h

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 394 - 393
build/debug/Makefile


+ 106 - 107
src/Main.cpp

@@ -10,7 +10,6 @@
 #include "Renderer.h"
 #include "Ui.h"
 #include "App.h"
-#include "particles.h"
 #include "Texture.h"
 #include "Mesh.h"
 #include "Light.h"
@@ -70,7 +69,7 @@ void initPhysics()
 
 	btTransform groundTransform;
 	groundTransform.setIdentity();
-	groundTransform.setOrigin(btVector3(0,-50,0));
+	groundTransform.setOrigin(btVector3(0,-50, 0));
 
 	//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
 	{
@@ -79,7 +78,7 @@ void initPhysics()
 		//rigidbody is dynamic if and only if mass is non zero, otherwise static
 		bool isDynamic = (mass != 0.f);
 
-		btVector3 localInertia(0,0,0);
+		btVector3 localInertia(0, 0, 0);
 		if (isDynamic)
 			groundShape->calculateLocalInertia(mass,localInertia);
 
@@ -106,7 +105,7 @@ void initPhysics()
 
 		btScalar	mass(1.0);
 
-		btVector3 localInertia(0,0,0);
+		btVector3 localInertia(0, 0, 0);
 		colShape->calculateLocalInertia(mass,localInertia);
 
 		float start_x = START_POS_X - ARRAY_SIZE_X/2;
@@ -128,25 +127,25 @@ void initPhysics()
 
 					//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
 					MeshNode* crate = new MeshNode;
-					crate->init( "models/crate0/crate0.mesh" );
-					crate->getLocalTransform().setScale( 1.11 );
+					crate->init("models/crate0/crate0.mesh");
+					crate->getLocalTransform().setScale(1.11);
 
-					Transform trf( SCALING*Vec3(2.0*i + start_x, 20+2.0*k + start_y, 2.0*j + start_z), Mat3::getIdentity(), 1.0 );
-					body = app->getScene()->getPhyWorld()->createNewRigidBody( mass, trf, colShape, crate );
+					Transform trf(SCALING*Vec3(2.0*i + start_x, 20+2.0*k + start_y, 2.0*j + start_z), Mat3::getIdentity(), 1.0);
+					body = app->getScene()->getPhyWorld()->createNewRigidBody(mass, trf, colShape, crate);
 
-					/*MotionState* myMotionState = new MotionState( startTransform, crate);
+					/*MotionState* myMotionState = new MotionState(startTransform, crate);
 					btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
 					//btRigidBody* body = new btRigidBody(rbInfo);
 					body = new btRigidBody(rbInfo);
 
-					//if( i=2 ) body->setActivationState(ISLAND_SLEEPING);
+					//if(i=2) body->setActivationState(ISLAND_SLEEPING);
 
 					//body->setActivationState(ISLAND_SLEEPING);
 
 
 					dynamicsWorld->addRigidBody(body);
-					//body->setGravity( toBt( Vec3( Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0) ) ) );*/
-					boxes.push_back( body );
+					//body->setGravity(toBt(Vec3(Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0), Util::randRange(-1.0, 1.0))));*/
+					boxes.push_back(body);
 				}
 			}
 		}
@@ -157,18 +156,18 @@ void initPhysics()
 
 
 
-	/*for( int i=0; i<app->getScene()->getPhyWorld()->getDynamicsWorld()->getCollisionObjectArray().size();i++ )
+	/*for(int i=0; i<app->getScene()->getPhyWorld()->getDynamicsWorld()->getCollisionObjectArray().size();i++)
 	{
 		btCollisionObject* colObj = app->getScene()->getPhyWorld()->getDynamicsWorld()->getCollisionObjectArray()[i];
 		btRigidBody* body = btRigidBody::upcast(colObj);
-		if( body )
+		if(body)
 		{
-			if( body->getMotionState() )
+			if(body->getMotionState())
 			{
 				MotionState* myMotionState = (MotionState*)body->getMotionState();
 				myMotionState->m_graphicsWorldTrans = myMotionState->m_startWorldTrans;
-				body->setCenterOfMassTransform( myMotionState->m_graphicsWorldTrans );
-				colObj->setInterpolationWorldTransform( myMotionState->m_startWorldTrans );
+				body->setCenterOfMassTransform(myMotionState->m_graphicsWorldTrans);
+				colObj->setInterpolationWorldTransform(myMotionState->m_startWorldTrans);
 				colObj->forceActivationState(ACTIVE_TAG);
 				colObj->activate();
 				colObj->setDeactivationTime(0);
@@ -180,8 +179,8 @@ void initPhysics()
 			btRigidBody* body = btRigidBody::upcast(colObj);
 			if (body && !body->isStaticObject())
 			{
-				btRigidBody::upcast(colObj)->setLinearVelocity(btVector3(0,0,0));
-				btRigidBody::upcast(colObj)->setAngularVelocity(btVector3(0,0,0));
+				btRigidBody::upcast(colObj)->setLinearVelocity(btVector3(0, 0, 0));
+				btRigidBody::upcast(colObj)->setAngularVelocity(btVector3(0, 0, 0));
 			}
 		}
 	}*/
@@ -194,9 +193,9 @@ void initPhysics()
 //======================================================================================================================
 void init()
 {
-	INFO( "Engine initializing..." );
+	INFO("Engine initializing...");
 
-	srand( unsigned(time(NULL)) );
+	srand(unsigned(time(NULL)));
 	mathSanityChecks();
 
 	app->initWindow();
@@ -217,90 +216,90 @@ void init()
 	initializer.pps.ssao.enabled = true;
 	initializer.pps.ssao.renderingQuality = 0.5;
 	initializer.mainRendererQuality = 1.0;
-	app->getMainRenderer()->init( initializer );
+	app->getMainRenderer()->init(initializer);
 	Ui::init();
 
 	// camera
-	Camera* cam = new Camera( app->getMainRenderer()->getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0 );
-	cam->moveLocalY( 3.0 );
-	cam->moveLocalZ( 5.7 );
-	cam->moveLocalX( -0.3 );
-	app->setActiveCam( cam );
+	Camera* cam = new Camera(app->getMainRenderer()->getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0);
+	cam->moveLocalY(3.0);
+	cam->moveLocalZ(5.7);
+	cam->moveLocalX(-0.3);
+	app->setActiveCam(cam);
 
 	// lights
 	point_lights[0] = new PointLight();
-	point_lights[0]->init( "maps/temple/light0.light" );
-	point_lights[0]->setLocalTransform( Transform( Vec3( -1.0, 2.4, 1.0 ), Mat3::getIdentity(), 1.0 ) );
+	point_lights[0]->init("maps/temple/light0.light");
+	point_lights[0]->setLocalTransform(Transform(Vec3(-1.0, 2.4, 1.0), Mat3::getIdentity(), 1.0));
 	point_lights[1] = new PointLight();
-	point_lights[1]->init( "maps/temple/light1.light" );
-	point_lights[1]->setLocalTransform( Transform( Vec3( 2.5, 1.4, 1.0 ), Mat3::getIdentity(), 1.0 ) );
+	point_lights[1]->init("maps/temple/light1.light");
+	point_lights[1]->setLocalTransform(Transform(Vec3(2.5, 1.4, 1.0), Mat3::getIdentity(), 1.0));
 
 	spot_lights[0] = new SpotLight();
-	spot_lights[0]->init( "maps/temple/light2.light" );
-	spot_lights[0]->setLocalTransform( Transform( Vec3( 1.3, 4.3, 3.0 ), Mat3( Euler(toRad(-20), toRad(20), 0.0) ), 1.0 ) );
+	spot_lights[0]->init("maps/temple/light2.light");
+	spot_lights[0]->setLocalTransform(Transform(Vec3(1.3, 4.3, 3.0), Mat3(Euler(toRad(-20), toRad(20), 0.0)), 1.0));
 	spot_lights[1] = new SpotLight();
-	spot_lights[1]->init( "maps/temple/light3.light" );
-	spot_lights[1]->setLocalTransform( Transform( Vec3( -2.3, 6.3, 2.9 ), Mat3( Euler(toRad(-70), toRad(-20), 0.0) ), 1.0 ) );
+	spot_lights[1]->init("maps/temple/light3.light");
+	spot_lights[1]->setLocalTransform(Transform(Vec3(-2.3, 6.3, 2.9), Mat3(Euler(toRad(-70), toRad(-20), 0.0)), 1.0));
 
 	// horse
 	horse = new MeshNode();
-	horse->init( "meshes/horse/horse.mesh" );
-	horse->setLocalTransform( Transform( Vec3( -2, 0, 1 ), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 0.5 ) );
+	horse->init("meshes/horse/horse.mesh");
+	horse->setLocalTransform(Transform(Vec3(-2, 0, 1), Mat3(Euler(-M::PI/2, 0.0, 0.0)), 0.5));
 	
 	// sarge
 	sarge = new MeshNode();
-	sarge->init( "meshes/sphere/sphere16.mesh" );
-	//sarge->setLocalTransform( Vec3( 0, -2.8, 1.0 ), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 1.1 );
-	sarge->setLocalTransform( Transform( Vec3( 0, 2.0, 2.0 ), Mat3::getIdentity(), 0.4 ) );
+	sarge->init("meshes/sphere/sphere16.mesh");
+	//sarge->setLocalTransform(Vec3(0, -2.8, 1.0), Mat3(Euler(-M::PI/2, 0.0, 0.0)), 1.1);
+	sarge->setLocalTransform(Transform(Vec3(0, 2.0, 2.0), Mat3::getIdentity(), 0.4));
 	
 	// floor
 	floor__ = new MeshNode();
-	floor__->init( "maps/temple/Cube.019.mesh" );
-	floor__->setLocalTransform( Transform( Vec3(0.0, -0.19, 0.0), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 0.8 ) );
+	floor__->init("maps/temple/Cube.019.mesh");
+	floor__->setLocalTransform(Transform(Vec3(0.0, -0.19, 0.0), Mat3(Euler(-M::PI/2, 0.0, 0.0)), 0.8));
 
 	// imp	
 	imp = new SkelModelNode();
-	imp->init( "models/imp/imp.smdl" );
-	imp->setLocalTransform( Transform( Vec3( 0.0, 2.11, 0.0 ), Mat3( Euler(-M::PI/2, 0.0, 0.0) ), 0.7 ) );
-	imp->meshNodes[0]->meshSkelCtrl->skelNode->skelAnimCtrl->skelAnim = Rsrc::skelAnims.load( "models/imp/walk.imp.anim" );
+	imp->init("models/imp/imp.smdl");
+	imp->setLocalTransform(Transform(Vec3(0.0, 2.11, 0.0), Mat3(Euler(-M::PI/2, 0.0, 0.0)), 0.7));
+	imp->meshNodes[0]->meshSkelCtrl->skelNode->skelAnimCtrl->skelAnim = Rsrc::skelAnims.load("models/imp/walk.imp.anim");
 	imp->meshNodes[0]->meshSkelCtrl->skelNode->skelAnimCtrl->step = 0.8;
 
 	// particle emitter
 	partEmitter = new ParticleEmitter;
-	partEmitter->init( NULL );
-	partEmitter->getLocalTransform().setOrigin( Vec3( 3.0, 0.0, 0.0 ) );
+	partEmitter->init(NULL);
+	partEmitter->getLocalTransform().setOrigin(Vec3(3.0, 0.0, 0.0));
 
 	// crate
 	/*crate = new MeshNode;
-	crate->init( "models/crate0/crate0.mesh" );
+	crate->init("models/crate0/crate0.mesh");
 	crate->scaleLspace = 1.0;*/
 
 
 	//
 	//floor_ = new floor_t;
-	//floor_->material = Rsrc::materials.load( "materials/default.mtl" );
+	//floor_->material = Rsrc::materials.load("materials/default.mtl");
 
 	const char* skybox_fnames [] = { "textures/env/hellsky4_forward.tga", "textures/env/hellsky4_back.tga", "textures/env/hellsky4_left.tga",
 																	 "textures/env/hellsky4_right.tga", "textures/env/hellsky4_up.tga", "textures/env/hellsky4_down.tga" };
-	app->getScene()->skybox.load( skybox_fnames );
+	app->getScene()->skybox.load(skybox_fnames);
 
 
 	initPhysics();
 
-	INFO( "Engine initialization ends (" << App::getTicks()-ticks << ")" );
+	INFO("Engine initialization ends (" << App::getTicks()-ticks << ")");
 }
 
 
 //======================================================================================================================
 // main                                                                                                                =
 //======================================================================================================================
-int main( int argc, char* argv[] )
+int main(int argc, char* argv[])
 {
-	new App( argc, argv );
+	new App(argc, argv);
 
 	init();
 
-	INFO( "Entering main loop" );
+	INFO("Entering main loop");
 	int ticks = App::getTicks();
 	do
 	{
@@ -314,100 +313,100 @@ int main( int argc, char* argv[] )
 		// move the camera
 		static SceneNode* mover = app->getActiveCam();
 
-		if( I::keys[ SDL_SCANCODE_1 ] ) mover = app->getActiveCam();
-		if( I::keys[ SDL_SCANCODE_2 ] ) mover = point_lights[0];
-		if( I::keys[ SDL_SCANCODE_3 ] ) mover = spot_lights[0];
-		if( I::keys[ SDL_SCANCODE_4 ] ) mover = point_lights[1];
-		if( I::keys[ SDL_SCANCODE_5 ] ) mover = spot_lights[1];
-		if( I::keys[ SDL_SCANCODE_6 ] ) mover = partEmitter;
-		if( I::keys[ SDL_SCANCODE_M ] == 1 ) I::warpMouse = !I::warpMouse;
-
-		if( I::keys[ SDL_SCANCODE_A ] ) mover->moveLocalX( -dist );
-		if( I::keys[ SDL_SCANCODE_D ] ) mover->moveLocalX( dist );
-		if( I::keys[ SDL_SCANCODE_LSHIFT ] ) mover->moveLocalY( dist );
-		if( I::keys[ SDL_SCANCODE_SPACE ] ) mover->moveLocalY( -dist );
-		if( I::keys[ SDL_SCANCODE_W ] ) mover->moveLocalZ( -dist );
-		if( I::keys[ SDL_SCANCODE_S ] ) mover->moveLocalZ( dist );
-		if( !I::warpMouse )
+		if(I::keys[SDL_SCANCODE_1]) mover = app->getActiveCam();
+		if(I::keys[SDL_SCANCODE_2]) mover = point_lights[0];
+		if(I::keys[SDL_SCANCODE_3]) mover = spot_lights[0];
+		if(I::keys[SDL_SCANCODE_4]) mover = point_lights[1];
+		if(I::keys[SDL_SCANCODE_5]) mover = spot_lights[1];
+		if(I::keys[SDL_SCANCODE_6]) mover = partEmitter;
+		if(I::keys[SDL_SCANCODE_M] == 1) I::warpMouse = !I::warpMouse;
+
+		if(I::keys[SDL_SCANCODE_A]) mover->moveLocalX(-dist);
+		if(I::keys[SDL_SCANCODE_D]) mover->moveLocalX(dist);
+		if(I::keys[SDL_SCANCODE_LSHIFT]) mover->moveLocalY(dist);
+		if(I::keys[SDL_SCANCODE_SPACE]) mover->moveLocalY(-dist);
+		if(I::keys[SDL_SCANCODE_W]) mover->moveLocalZ(-dist);
+		if(I::keys[SDL_SCANCODE_S]) mover->moveLocalZ(dist);
+		if(!I::warpMouse)
 		{
-			if( I::keys[ SDL_SCANCODE_UP ] ) mover->rotateLocalX( ang );
-			if( I::keys[ SDL_SCANCODE_DOWN ] ) mover->rotateLocalX( -ang );
-			if( I::keys[ SDL_SCANCODE_LEFT ] ) mover->rotateLocalY( ang );
-			if( I::keys[ SDL_SCANCODE_RIGHT ] ) mover->rotateLocalY( -ang );
+			if(I::keys[SDL_SCANCODE_UP]) mover->rotateLocalX(ang);
+			if(I::keys[SDL_SCANCODE_DOWN]) mover->rotateLocalX(-ang);
+			if(I::keys[SDL_SCANCODE_LEFT]) mover->rotateLocalY(ang);
+			if(I::keys[SDL_SCANCODE_RIGHT]) mover->rotateLocalY(-ang);
 		}
 		else
 		{
 			float accel = 44.0;
-			mover->rotateLocalX( ang * I::mouseVelocity.y * accel );
-			mover->rotateLocalY( -ang * I::mouseVelocity.x * accel );
+			mover->rotateLocalX(ang * I::mouseVelocity.y * accel);
+			mover->rotateLocalY(-ang * I::mouseVelocity.x * accel);
 		}
-		if( I::keys[ SDL_SCANCODE_Q ] ) mover->rotateLocalZ( ang );
-		if( I::keys[ SDL_SCANCODE_E ] ) mover->rotateLocalZ( -ang );
-		if( I::keys[ SDL_SCANCODE_PAGEUP ] ) mover->getLocalTransform().getScale() += scale ;
-		if( I::keys[ SDL_SCANCODE_PAGEDOWN ] ) mover->getLocalTransform().getScale() -= scale ;
+		if(I::keys[SDL_SCANCODE_Q]) mover->rotateLocalZ(ang);
+		if(I::keys[SDL_SCANCODE_E]) mover->rotateLocalZ(-ang);
+		if(I::keys[SDL_SCANCODE_PAGEUP]) mover->getLocalTransform().getScale() += scale ;
+		if(I::keys[SDL_SCANCODE_PAGEDOWN]) mover->getLocalTransform().getScale() -= scale ;
 
-		if( I::keys[ SDL_SCANCODE_K ] ) app->getActiveCam()->lookAtPoint( point_lights[0]->getWorldTransform().getOrigin() );
+		if(I::keys[SDL_SCANCODE_K]) app->getActiveCam()->lookAtPoint(point_lights[0]->getWorldTransform().getOrigin());
 
 
-		if( I::keys[ SDL_SCANCODE_O ] == 1 )
+		if(I::keys[SDL_SCANCODE_O] == 1)
 		{
-			btRigidBody* body = static_cast<btRigidBody*>( boxes[0] );
-			//body->getMotionState()->setWorldTransform( toBt( Mat4( Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0 ) ) );
-			body->setWorldTransform( toBt( Mat4( Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0 ) ) );
+			btRigidBody* body = static_cast<btRigidBody*>(boxes[0]);
+			//body->getMotionState()->setWorldTransform(toBt(Mat4(Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0)));
+			body->setWorldTransform(toBt(Mat4(Vec3(0.0, 10.0, 0.0), Mat3::getIdentity(), 1.0)));
 			//body->clearForces();
-			body->forceActivationState( ACTIVE_TAG );
+			body->forceActivationState(ACTIVE_TAG);
 		}
 
 		mover->getLocalTransform().getRotation().reorthogonalize();
 
-		//static_cast<btRigidBody*>(dynamicsWorld->getCollisionObjectArray()[1])->getMotionState()->setWorldTransform( toBt(point_lights[0]->transformationWspace) );
-		//dynamicsWorld->getCollisionObjectArray()[3]->setWorldTransform( toBt(point_lights[0]->transformationWspace) );
+		//static_cast<btRigidBody*>(dynamicsWorld->getCollisionObjectArray()[1])->getMotionState()->setWorldTransform(toBt(point_lights[0]->transformationWspace));
+		//dynamicsWorld->getCollisionObjectArray()[3]->setWorldTransform(toBt(point_lights[0]->transformationWspace));
 
 		app->getScene()->updateAllControllers();
 		app->getScene()->updateAllWorldStuff();
 
 		//partEmitter->update();
 
-		app->getScene()->getPhyWorld()->getDynamicsWorld()->stepSimulation( app->timerTick );
+		app->getScene()->getPhyWorld()->getDynamicsWorld()->stepSimulation(app->timerTick);
 		app->getScene()->getPhyWorld()->getDynamicsWorld()->debugDrawWorld();
 
-		app->getMainRenderer()->render( *app->getActiveCam() );
+		app->getMainRenderer()->render(*app->getActiveCam());
 
 		//map.octree.root->bounding_box.render();
 
 		// print some debug stuff
-		Ui::setColor( Vec4(1.0, 1.0, 1.0, 1.0) );
-		Ui::setPos( -0.98, 0.95 );
-		Ui::setFontWidth( 0.03 );
-		Ui::printf( "frame:%d fps:%dms\n", app->getMainRenderer()->getFramesNum(), (App::getTicks()-ticks_) );
-		//Ui::print( "Movement keys: arrows,w,a,s,d,q,e,shift,space\nSelect objects: keys 1 to 5\n" );
-		/*Ui::printf( "Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
-								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z) );*/
+		Ui::setColor(Vec4(1.0, 1.0, 1.0, 1.0));
+		Ui::setPos(-0.98, 0.95);
+		Ui::setFontWidth(0.03);
+		Ui::printf("frame:%d fps:%dms\n", app->getMainRenderer()->getFramesNum(), (App::getTicks()-ticks_));
+		//Ui::print("Movement keys: arrows,w,a,s,d,q,e,shift,space\nSelect objects: keys 1 to 5\n");
+		/*Ui::printf("Mover: Pos(%.2f %.2f %.2f) Angs(%.2f %.2f %.2f)", mover->translationWspace.x, mover->translationWspace.y, mover->translationWspace.z,
+								 toDegrees(Euler(mover->rotationWspace).x), toDegrees(Euler(mover->rotationWspace).y), toDegrees(Euler(mover->rotationWspace).z));*/
 
-		if( I::keys[SDL_SCANCODE_ESCAPE] ) break;
-		if( I::keys[SDL_SCANCODE_F11] ) app->togleFullScreen();
-		if( I::keys[SDL_SCANCODE_F12] == 1 )  app->getMainRenderer()->takeScreenshot( "gfx/screenshot.jpg" );
+		if(I::keys[SDL_SCANCODE_ESCAPE]) break;
+		if(I::keys[SDL_SCANCODE_F11]) app->togleFullScreen();
+		if(I::keys[SDL_SCANCODE_F12] == 1)  app->getMainRenderer()->takeScreenshot("gfx/screenshot.jpg");
 
 
 		/*char str[128];
-		sprintf( str, "capt/%06d.jpg", R::framesNum );
+		sprintf(str, "capt/%06d.jpg", R::framesNum);
 		R::takeScreenshot(str);*/
 
 		// std stuff follow
 		app->swapBuffers();
 		Renderer::printLastError();
-		if( 1 )
+		if(1)
 		{
-			//if( R::framesNum == 10 ) R::takeScreenshot("gfx/screenshot.tga");
+			//if(R::framesNum == 10) R::takeScreenshot("gfx/screenshot.tga");
 			app->waitForNextFrame();
 		}
 		else
-			if( app->getMainRenderer()->getFramesNum() == 5000 ) break;
-	}while( true );
-	INFO( "Exiting main loop (" << App::getTicks()-ticks << ")" );
+			if(app->getMainRenderer()->getFramesNum() == 5000) break;
+	}while(true);
+	INFO("Exiting main loop (" << App::getTicks()-ticks << ")");
 
 
-	INFO( "Exiting..." );
-	app->quitApp( EXIT_SUCCESS );
+	INFO("Exiting...");
+	app->quitApp(EXIT_SUCCESS);
 	return 0;
 }

+ 4 - 4
src/Math/Axisang.h

@@ -17,10 +17,10 @@ class Axisang
 		Vec3 axis;
 		// constructors & distructors
 		explicit Axisang();
-		         Axisang( const Axisang& b );
-		explicit Axisang( float rad, const Vec3& axis_ );
-		explicit Axisang( const Quat& q );
-		explicit Axisang( const Mat3& m3 );
+		         Axisang(const Axisang& b);
+		explicit Axisang(float rad, const Vec3& axis_);
+		explicit Axisang(const Quat& q);
+		explicit Axisang(const Mat3& m3);
 };
 
 

+ 34 - 34
src/Math/Axisang.inl.h

@@ -9,84 +9,84 @@ inline Axisang::Axisang()
 {}
 
 // constructor [Axisang]
-inline Axisang::Axisang( const Axisang& b )
+inline Axisang::Axisang(const Axisang& b)
 	: ang(b.ang), axis(b.axis)
 {}
 
 // constructor [float, axis]
-inline Axisang::Axisang( float rad, const Vec3& axis_ )
+inline Axisang::Axisang(float rad, const Vec3& axis_)
 	: ang(rad), axis(axis_)
 {}
 
 // constructor [quat]
-inline Axisang::Axisang( const Quat& q )
+inline Axisang::Axisang(const Quat& q)
 {
-	ang = 2.0*acos( q.w );
-	float length = M::sqrt( 1.0 - q.w*q.w );
-	if( isZero(length) )
+	ang = 2.0*acos(q.w);
+	float length = M::sqrt(1.0 - q.w*q.w);
+	if(isZero(length))
 		axis = Vec3(0.0);
 	else
 	{
 		length = 1.0/length;
-		axis = Vec3( q.x*length, q.y*length, q.z*length );
+		axis = Vec3(q.x*length, q.y*length, q.z*length);
 	}
 }
 
 // constructor [mat3]
-inline Axisang::Axisang( const Mat3& m3 )
+inline Axisang::Axisang(const Mat3& m3)
 {
-	if( (fabs(m3(0,1)-m3(1,0))< EPSILON)  && (fabs(m3(0,2)-m3(2,0))< EPSILON)  && (fabs(m3(1,2)-m3(2,1))< EPSILON) )
+	if((fabs(m3(0, 1)-m3(1, 0))< EPSILON)  && (fabs(m3(0, 2)-m3(2, 0))< EPSILON)  && (fabs(m3(1, 2)-m3(2, 1))< EPSILON))
 	{
 
-		if( (fabs(m3(0,1)+m3(1,0)) < 0.1 ) && (fabs(m3(0,2)+m3(2,0)) < 0.1) && (fabs(m3(1,2)+m3(2,1)) < 0.1) && (fabs(m3(0,0)+m3(1,1)+m3(2,2))-3) < 0.1 )
+		if((fabs(m3(0, 1)+m3(1, 0)) < 0.1) && (fabs(m3(0, 2)+m3(2, 0)) < 0.1) && (fabs(m3(1, 2)+m3(2, 1)) < 0.1) && (fabs(m3(0, 0)+m3(1, 1)+m3(2, 2))-3) < 0.1)
 		{
-			axis = Vec3( 1.0, 0.0, 0.0 );
+			axis = Vec3(1.0, 0.0, 0.0);
 			ang = 0.0;
 			return;
 		}
 
 		ang = PI;
-		axis.x = (m3(0,0)+1)/2;
-		if( axis.x > 0.0 )
+		axis.x = (m3(0, 0)+1)/2;
+		if(axis.x > 0.0)
 			axis.x = M::sqrt(axis.x);
 		else
 			axis.x = 0;
-		axis.y = (m3(1,1)+1)/2;
-		if( axis.y > 0 )
+		axis.y = (m3(1, 1)+1)/2;
+		if(axis.y > 0)
 			axis.y = M::sqrt(axis.y);
 		else
 			axis.y = 0;
-		axis.z = (m3(2,2)+1)/2;
-		if( axis.z > 0 )
+		axis.z = (m3(2, 2)+1)/2;
+		if(axis.z > 0)
 			axis.z = M::sqrt(axis.z);
 		else
 			axis.z = 0.0;
 
-		bool xZero = ( fabs(axis.x)<EPSILON );
-		bool yZero = ( fabs(axis.y)<EPSILON );
-		bool zZero = ( fabs(axis.z)<EPSILON );
-		bool xyPositive = ( m3(0,1) > 0 );
-		bool xzPositive = ( m3(0,2) > 0 );
-		bool yzPositive = ( m3(1,2) > 0 );
-		if( xZero && !yZero && !zZero ){
-			if( !yzPositive ) axis.y = -axis.y;
-		}else if( yZero && !zZero ){
-			if( !xzPositive ) axis.z = -axis.z;
+		bool xZero = (fabs(axis.x)<EPSILON);
+		bool yZero = (fabs(axis.y)<EPSILON);
+		bool zZero = (fabs(axis.z)<EPSILON);
+		bool xyPositive = (m3(0, 1) > 0);
+		bool xzPositive = (m3(0, 2) > 0);
+		bool yzPositive = (m3(1, 2) > 0);
+		if(xZero && !yZero && !zZero){
+			if(!yzPositive) axis.y = -axis.y;
+		}else if(yZero && !zZero){
+			if(!xzPositive) axis.z = -axis.z;
 		}else if (zZero){
-			if( !xyPositive ) axis.x = -axis.x;
+			if(!xyPositive) axis.x = -axis.x;
 		}
 
 		return;
 	}
 
-	float s = M::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(1,0) - m3(0,1))*(m3(1,0) - m3(0,1)));
+	float s = M::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(1, 0) - m3(0, 1))*(m3(1, 0) - m3(0, 1)));
 
-	if( fabs(s) < 0.001 ) s = 1;
+	if(fabs(s) < 0.001) s = 1;
 
-	ang = acos( ( m3(0,0) + m3(1,1) + m3(2,2) - 1)/2 );
-	axis.x= (m3(2,1) - m3(1,2))/s;
-	axis.y= (m3(0,2) - m3(2,0))/s;
-	axis.z= (m3(1,0) - m3(0,1))/s;
+	ang = acos((m3(0, 0) + m3(1, 1) + m3(2, 2) - 1)/2);
+	axis.x= (m3(2, 1) - m3(1, 2))/s;
+	axis.y= (m3(0, 2) - m3(2, 0))/s;
+	axis.z= (m3(1, 0) - m3(0, 1))/s;
 }
 
 

+ 6 - 6
src/Math/Euler.h

@@ -15,8 +15,8 @@ class Euler
 		// data members
 		float x, y, z;
 		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
+		float& operator [](uint i);
+		float  operator [](uint i) const;
 		float& bank();
 		float  bank() const;
 		float& heading();
@@ -25,10 +25,10 @@ class Euler
 		float  attitude() const;
 		// constructors & distructors
 		explicit Euler();
-		explicit Euler( float x, float y, float z  );
-		         Euler( const Euler& b );
-		explicit Euler( const Quat& q );
-		explicit Euler( const Mat3& m3 );
+		explicit Euler(float x, float y, float z);
+		         Euler(const Euler& b);
+		explicit Euler(const Quat& q);
+		explicit Euler(const Mat3& m3);
 		// other
 		void print() const;
 };

+ 25 - 25
src/Math/Euler.inl.h

@@ -5,12 +5,12 @@ namespace M {
 
 
 // accessors
-inline float& Euler::operator []( uint i )
+inline float& Euler::operator [](uint i)
 {
 	return (&x)[i];
 }
 
-inline float Euler::operator []( uint i) const
+inline float Euler::operator [](uint i) const
 {
 	return (&x)[i];
 }
@@ -51,29 +51,29 @@ inline Euler::Euler()
 {}
 
 // constructor [float, float, float]
-inline Euler::Euler( float x_, float y_, float z_ )
+inline Euler::Euler(float x_, float y_, float z_)
 	: x(x_), y(y_), z(z_)
 {}
 
 // constructor [euler]
-inline Euler::Euler( const Euler& b )
+inline Euler::Euler(const Euler& b)
 	: x(b.x), y(b.y), z(b.z)
 {}
 
 // constructor [quat]
-inline Euler::Euler( const Quat& q )
+inline Euler::Euler(const Quat& q)
 {
 	float test = q.x*q.y + q.z*q.w;
-	if( test > 0.499 )
+	if(test > 0.499)
 	{
-		heading() = 2.0 * atan2( q.x, q.w );
+		heading() = 2.0 * atan2(q.x, q.w);
 		attitude() = PI/2.0;
 		bank() = 0.0;
 		return;
 	}
-	if( test < -0.499 )
+	if(test < -0.499)
 	{
-		heading() = -2.0 * atan2( q.x, q.w );
+		heading() = -2.0 * atan2(q.x, q.w);
 		attitude() = -PI/2.0;
 		bank() = 0.0;
 		return;
@@ -82,41 +82,41 @@ inline Euler::Euler( const Quat& q )
 	float sqx = q.x*q.x;
 	float sqy = q.y*q.y;
 	float sqz = q.z*q.z;
-	heading() = atan2( 2.0*q.y*q.w-2.0*q.x*q.z, 1.0-2.0*sqy-2.0*sqz );
-	attitude() = asin( 2.0f*test );
-	bank() = atan2( 2.0*q.x*q.w-2.0*q.y*q.z, 1.0-2.0*sqx-2.0*sqz );
+	heading() = atan2(2.0*q.y*q.w-2.0*q.x*q.z, 1.0-2.0*sqy-2.0*sqz);
+	attitude() = asin(2.0f*test);
+	bank() = atan2(2.0*q.x*q.w-2.0*q.y*q.z, 1.0-2.0*sqx-2.0*sqz);
 }
 
 // constructor [mat3]
-inline Euler::Euler( const Mat3& m3 )
+inline Euler::Euler(const Mat3& m3)
 {
 	float cx, sx;
 	float cy, sy;
 	float cz, sz;
 
-	sy = m3(0,2);
-	cy = M::sqrt( 1.0 - sy*sy );
+	sy = m3(0, 2);
+	cy = M::sqrt(1.0 - sy*sy);
 	// normal case
-	if ( !isZero( cy ) )
+	if (!isZero(cy))
 	{
 		float factor = 1.0/cy;
-		sx = -m3(1,2) * factor;
-		cx = m3(2,2) * factor;
-		sz = -m3(0,1) * factor;
-		cz = m3(0,0) * factor;
+		sx = -m3(1, 2) * factor;
+		cx = m3(2, 2) * factor;
+		sz = -m3(0, 1) * factor;
+		cz = m3(0, 0) * factor;
 	}
 	// x and z axes aligned
 	else
 	{
 		sz = 0.0;
 		cz = 1.0;
-		sx = m3(2,1);
-		cx = m3(1,1);
+		sx = m3(2, 1);
+		cx = m3(1, 1);
 	}
 
-	z = atan2f( sz, cz );
-	y = atan2f( sy, cy );
-	x = atan2f( sx, cx );
+	z = atan2f(sz, cz);
+	y = atan2f(sy, cy);
+	x = atan2f(sx, cx);
 }
 
 

+ 51 - 51
src/Math/Mat3.h

@@ -21,63 +21,63 @@ class Mat3
 
 	public:
 		// accessors
-		float& operator ()( const uint i, const uint j );
-		const float& operator ()( const uint i, const uint j ) const;
-		float& operator []( const uint i);
-		const float& operator []( const uint i) const;
+		float& operator ()(const uint i, const uint j);
+		const float& operator ()(const uint i, const uint j) const;
+		float& operator [](const uint i);
+		const float& operator [](const uint i) const;
 		// constructors & distructors
 		explicit Mat3() {};
-		explicit Mat3( float f );
-		explicit Mat3( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 );
-		explicit Mat3( float arr [] );
-		         Mat3( const Mat3& b );
-		explicit Mat3( const Quat& q ); ///< @ref Quat to @ref Mat3. 12 muls, 12 adds
-		explicit Mat3( const Euler& eu );
-		explicit Mat3( const Axisang& axisang );
+		explicit Mat3(float f);
+		explicit Mat3(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22);
+		explicit Mat3(float arr []);
+		         Mat3(const Mat3& b);
+		explicit Mat3(const Quat& q); ///< @ref Quat to @ref Mat3. 12 muls, 12 adds
+		explicit Mat3(const Euler& eu);
+		explicit Mat3(const Axisang& axisang);
 		// ops with mat3
-		Mat3  operator + ( const Mat3& b ) const;
-		Mat3& operator +=( const Mat3& b );
-		Mat3  operator - ( const Mat3& b ) const;
-		Mat3& operator -=( const Mat3& b );
-		Mat3  operator * ( const Mat3& b ) const; ///< 27 muls, 18 adds
-		Mat3& operator *=( const Mat3& b );
-		Mat3  operator / ( const Mat3& b ) const;
-		Mat3& operator /=( const Mat3& b );
+		Mat3  operator + (const Mat3& b) const;
+		Mat3& operator +=(const Mat3& b);
+		Mat3  operator - (const Mat3& b) const;
+		Mat3& operator -=(const Mat3& b);
+		Mat3  operator * (const Mat3& b) const; ///< 27 muls, 18 adds
+		Mat3& operator *=(const Mat3& b);
+		Mat3  operator / (const Mat3& b) const;
+		Mat3& operator /=(const Mat3& b);
 		// ops with float
-		Mat3  operator + ( float f ) const;
-		Mat3& operator +=( float f );
-		Mat3  operator - ( float f ) const;
-		Mat3& operator -=( float f );
-		Mat3  operator * ( float f ) const;
-		Mat3& operator *=( float f );
-		Mat3  operator / ( float f ) const;
-		Mat3& operator /=( float f );
+		Mat3  operator + (float f) const;
+		Mat3& operator +=(float f);
+		Mat3  operator - (float f) const;
+		Mat3& operator -=(float f);
+		Mat3  operator * (float f) const;
+		Mat3& operator *=(float f);
+		Mat3  operator / (float f) const;
+		Mat3& operator /=(float f);
 		// ops with others
-		Vec3  operator * ( const Vec3& b ) const;  ///< 9 muls, 6 adds
+		Vec3  operator * (const Vec3& b) const;  ///< 9 muls, 6 adds
 		// comparision
-		bool operator ==( const Mat3& b ) const;
-		bool operator !=( const Mat3& b ) const;
+		bool operator ==(const Mat3& b) const;
+		bool operator !=(const Mat3& b) const;
 		// other
-		void  setRows( const Vec3& a, const Vec3& b, const Vec3& c );
-		void  setRow( const uint i, const Vec3& v );
-		void  getRows( Vec3& a, Vec3& b, Vec3& c ) const;
-		Vec3  getRow( const uint i ) const;
-		void  setColumns( const Vec3& a, const Vec3& b, const Vec3& c );
-		void  setColumn( const uint i, const Vec3& v );
-		void  getColumns( Vec3& a, Vec3& b, Vec3& c ) const;
-		Vec3  getColumn( const uint i ) const;
+		void  setRows(const Vec3& a, const Vec3& b, const Vec3& c);
+		void  setRow(const uint i, const Vec3& v);
+		void  getRows(Vec3& a, Vec3& b, Vec3& c) const;
+		Vec3  getRow(const uint i) const;
+		void  setColumns(const Vec3& a, const Vec3& b, const Vec3& c);
+		void  setColumn(const uint i, const Vec3& v);
+		void  getColumns(Vec3& a, Vec3& b, Vec3& c) const;
+		Vec3  getColumn(const uint i) const;
 		Vec3  getXAxis() const;
 		Vec3  getYAxis() const;
 		Vec3  getZAxis() const;
-		void  setXAxis( const Vec3& v3 );
-		void  setYAxis( const Vec3& v3 );
-		void  setZAxis( const Vec3& v3 );
-		void  setRotationX( float rad );
-		void  setRotationY( float rad );
-		void  setRotationZ( float rad );
-		void  rotateXAxis( float rad ); ///< It rotates "this" in the axis defined by the rotation AND not the world axis
-		void  rotateYAxis( float rad );
-		void  rotateZAxis( float rad );
+		void  setXAxis(const Vec3& v3);
+		void  setYAxis(const Vec3& v3);
+		void  setZAxis(const Vec3& v3);
+		void  setRotationX(float rad);
+		void  setRotationY(float rad);
+		void  setRotationZ(float rad);
+		void  rotateXAxis(float rad); ///< It rotates "this" in the axis defined by the rotation AND not the world axis
+		void  rotateYAxis(float rad);
+		void  rotateZAxis(float rad);
 		void  transpose();
 		Mat3  getTransposed() const;
 		void  reorthogonalize();
@@ -92,10 +92,10 @@ class Mat3
 
 
 // other operators
-extern Mat3 operator +( float f, const Mat3& m3 );
-extern Mat3 operator -( float f, const Mat3& m3 );
-extern Mat3 operator *( float f, const Mat3& m3 );
-extern Mat3 operator /( float f, const Mat3& m3 );
+extern Mat3 operator +(float f, const Mat3& m3);
+extern Mat3 operator -(float f, const Mat3& m3);
+extern Mat3 operator *(float f, const Mat3& m3);
+extern Mat3 operator /(float f, const Mat3& m3);
 
 
 } // end namespace

+ 275 - 275
src/Math/Mat3.inl.h

@@ -7,59 +7,59 @@
 namespace M {
 
 // accessors
-inline float& Mat3::operator ()( const uint i, const uint j )
+inline float& Mat3::operator ()(const uint i, const uint j)
 {
 	return arr2[i][j];
 }
 
-inline const float& Mat3::operator ()( const uint i, const uint j ) const
+inline const float& Mat3::operator ()(const uint i, const uint j) const
 {
 	return arr2[i][j]; 
 }
 
-inline float& Mat3::operator []( const uint i)
+inline float& Mat3::operator [](const uint i)
 {
 	return arr1[i];
 }
 
-inline const float& Mat3::operator []( const uint i) const
+inline const float& Mat3::operator [](const uint i) const
 {
 	return arr1[i];
 }
 
 // constructor [float[]]
-inline Mat3::Mat3( float arr [] )
+inline Mat3::Mat3(float arr [])
 {
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 		ME[i] = arr[i];
 }
 
 // constructor [float...........float]
-inline Mat3::Mat3( float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22 )
+inline Mat3::Mat3(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
 {
-	ME(0,0) = m00;
-	ME(0,1) = m01;
-	ME(0,2) = m02;
-	ME(1,0) = m10;
-	ME(1,1) = m11;
-	ME(1,2) = m12;
-	ME(2,0) = m20;
-	ME(2,1) = m21;
-	ME(2,2) = m22;
+	ME(0, 0) = m00;
+	ME(0, 1) = m01;
+	ME(0, 2) = m02;
+	ME(1, 0) = m10;
+	ME(1, 1) = m11;
+	ME(1, 2) = m12;
+	ME(2, 0) = m20;
+	ME(2, 1) = m21;
+	ME(2, 2) = m22;
 }
 
 // constructor [mat3]
-inline Mat3::Mat3( const Mat3& b )
+inline Mat3::Mat3(const Mat3& b)
 {
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 		ME[i] = b[i];
 }
 
 // constructor [quat]
-inline Mat3::Mat3( const Quat& q )
+inline Mat3::Mat3(const Quat& q)
 {
 	const float tolerance = 0.002;
-	DEBUG_ERR( fabs(1.0 - q.getLength()) > tolerance ); // Not normalized quat
+	DEBUG_ERR(fabs(1.0 - q.getLength()) > tolerance); // Not normalized quat
 
 	float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
@@ -76,108 +76,108 @@ inline Mat3::Mat3( const Quat& q )
 	yz = q.y*zs;
 	zz = q.z*zs;
 
-	ME(0,0) = 1.0 - (yy + zz);
-	ME(0,1) = xy - wz;
-	ME(0,2) = xz + wy;
+	ME(0, 0) = 1.0 - (yy + zz);
+	ME(0, 1) = xy - wz;
+	ME(0, 2) = xz + wy;
 
-	ME(1,0) = xy + wz;
-	ME(1,1) = 1.0 - (xx + zz);
-	ME(1,2) = yz - wx;
+	ME(1, 0) = xy + wz;
+	ME(1, 1) = 1.0 - (xx + zz);
+	ME(1, 2) = yz - wx;
 
-	ME(2,0) = xz - wy;
-	ME(2,1) = yz + wx;
-	ME(2,2) = 1.0 - (xx + yy);
+	ME(2, 0) = xz - wy;
+	ME(2, 1) = yz + wx;
+	ME(2, 2) = 1.0 - (xx + yy);
 }
 
 // constructor [euler]
-inline Mat3::Mat3( const Euler& e )
+inline Mat3::Mat3(const Euler& e)
 {
 	float ch, sh, ca, sa, cb, sb;
-  sinCos( e.heading(), sh, ch );
-  sinCos( e.attitude(), sa, ca );
-  sinCos( e.bank(), sb, cb );
+  sinCos(e.heading(), sh, ch);
+  sinCos(e.attitude(), sa, ca);
+  sinCos(e.bank(), sb, cb);
 
-  ME(0,0) = ch * ca;
-  ME(0,1) = sh*sb - ch*sa*cb;
-  ME(0,2) = ch*sa*sb + sh*cb;
-  ME(1,0) = sa;
-  ME(1,1) = ca*cb;
-  ME(1,2) = -ca*sb;
-  ME(2,0) = -sh*ca;
-  ME(2,1) = sh*sa*cb + ch*sb;
-  ME(2,2) = -sh*sa*sb + ch*cb;
+  ME(0, 0) = ch * ca;
+  ME(0, 1) = sh*sb - ch*sa*cb;
+  ME(0, 2) = ch*sa*sb + sh*cb;
+  ME(1, 0) = sa;
+  ME(1, 1) = ca*cb;
+  ME(1, 2) = -ca*sb;
+  ME(2, 0) = -sh*ca;
+  ME(2, 1) = sh*sa*cb + ch*sb;
+  ME(2, 2) = -sh*sa*sb + ch*cb;
 }
 
 // constructor [axisang]
-inline Mat3::Mat3( const Axisang& axisang )
+inline Mat3::Mat3(const Axisang& axisang)
 {
-	DEBUG_ERR( !isZero( 1.0-axisang.axis.getLength() ) ); // Not normalized axis
+	DEBUG_ERR(!isZero(1.0-axisang.axis.getLength())); // Not normalized axis
 
 	float c, s;
-	sinCos( axisang.ang, s, c );
+	sinCos(axisang.ang, s, c);
 	float t = 1.0 - c;
 
 	const Vec3& axis = axisang.axis;
-	ME(0,0) = c + axis.x*axis.x*t;
-	ME(1,1) = c + axis.y*axis.y*t;
-	ME(2,2) = c + axis.z*axis.z*t;
+	ME(0, 0) = c + axis.x*axis.x*t;
+	ME(1, 1) = c + axis.y*axis.y*t;
+	ME(2, 2) = c + axis.z*axis.z*t;
 
 	float tmp1 = axis.x*axis.y*t;
 	float tmp2 = axis.z*s;
-	ME(1,0) = tmp1 + tmp2;
-	ME(0,1) = tmp1 - tmp2;
+	ME(1, 0) = tmp1 + tmp2;
+	ME(0, 1) = tmp1 - tmp2;
 	tmp1 = axis.x*axis.z*t;
 	tmp2 = axis.y*s;
-	ME(2,0) = tmp1 - tmp2;
-	ME(0,2) = tmp1 + tmp2;    tmp1 = axis.y*axis.z*t;
+	ME(2, 0) = tmp1 - tmp2;
+	ME(0, 2) = tmp1 + tmp2;    tmp1 = axis.y*axis.z*t;
 	tmp2 = axis.x*s;
-	ME(2,1) = tmp1 + tmp2;
-	ME(1,2) = tmp1 - tmp2;
+	ME(2, 1) = tmp1 + tmp2;
+	ME(1, 2) = tmp1 - tmp2;
 }
 
 // constructor [float]
-inline Mat3::Mat3( float f )
+inline Mat3::Mat3(float f)
 {
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 			ME[i] = f;
 }
 
 // 3x3 + 3x3
-inline Mat3 Mat3::operator +( const Mat3& b ) const
+inline Mat3 Mat3::operator +(const Mat3& b) const
 {
 	Mat3 c;
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 		c[i] = ME[i] + b[i];
 	return c;
 }
 
 // 3x3 += 3x3
-inline Mat3& Mat3::operator +=( const Mat3& b )
+inline Mat3& Mat3::operator +=(const Mat3& b)
 {
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 		ME[i] += b[i];
 	return ME;
 }
 
 // 3x3 - 3x3
-inline Mat3 Mat3::operator -( const Mat3& b ) const
+inline Mat3 Mat3::operator -(const Mat3& b) const
 {
 	Mat3 c;
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 		c[i] = ME[i] - b[i];
 	return c;
 }
 
 // 3x3 -= 3x3
-inline Mat3& Mat3::operator -=( const Mat3& b )
+inline Mat3& Mat3::operator -=(const Mat3& b)
 {
-	for( int i=0; i<9; i++ )
+	for(int i=0; i<9; i++)
 		ME[i] -= b[i];
 	return ME;
 }
 
 // 3x3 * 3x3
-inline Mat3 Mat3::operator *( const Mat3& b ) const
+inline Mat3 Mat3::operator *(const Mat3& b) const
 {
 	Mat3 c;
 	c(0, 0) = ME(0, 0)*b(0, 0) + ME(0, 1)*b(1, 0) + ME(0, 2)*b(2, 0);
@@ -193,115 +193,115 @@ inline Mat3 Mat3::operator *( const Mat3& b ) const
 }
 
 // 3x3 *= 3x3
-inline Mat3& Mat3::operator *=( const Mat3& b )
+inline Mat3& Mat3::operator *=(const Mat3& b)
 {
 	ME = ME * b;
 	return ME;
 }
 
 // 3x3 + float
-inline Mat3 Mat3::operator +( float f ) const
+inline Mat3 Mat3::operator +(float f) const
 {
 	Mat3 c;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		c[i] = ME[i] + f;
 	return c;
 }
 
 // float + 3x3
-inline Mat3 operator +( float f, const Mat3& m3 )
+inline Mat3 operator +(float f, const Mat3& m3)
 {
 	return m3+f;
 }
 
 // 3x3 += float
-inline Mat3& Mat3::operator +=( float f )
+inline Mat3& Mat3::operator +=(float f)
 {
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		ME[i] += f;
 	return ME;
 }
 
 // 3x3 - float
-inline Mat3 Mat3::operator -( float f ) const
+inline Mat3 Mat3::operator -(float f) const
 {
 	Mat3 c;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		c[i] = ME[i] - f;
 	return c;
 }
 
 // float - 3x3
-inline Mat3 operator -( float f, const Mat3& m3 )
+inline Mat3 operator -(float f, const Mat3& m3)
 {
 	Mat3 out;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		out[i] = f - m3[i];
 	return out;
 }
 
 // 3x3 -= float
-inline Mat3& Mat3::operator -=( float f )
+inline Mat3& Mat3::operator -=(float f)
 {
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		ME[i] -= f;
 	return ME;
 }
 
 // 3x3 * float
-inline Mat3 Mat3::operator *( float f ) const
+inline Mat3 Mat3::operator *(float f) const
 {
 	Mat3 c;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		c[i] = ME[i] * f;
 	return c;
 }
 
 // float * 3x3
-inline Mat3 operator *( float f, const Mat3& m3 )
+inline Mat3 operator *(float f, const Mat3& m3)
 {
 	Mat3 out;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		out[i] = f * m3[i];
 	return out;
 }
 
 // 3x3 *= float
-inline Mat3& Mat3::operator *=( float f )
+inline Mat3& Mat3::operator *=(float f)
 {
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		ME[i] *= f;
 	return ME;
 }
 
 // 3x3 / float
-inline Mat3 Mat3::operator /( float f ) const
+inline Mat3 Mat3::operator /(float f) const
 {
 	Mat3 c;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		c[i] = ME[i] / f;
 	return c;
 }
 
 // float / 3x3
-inline Mat3 operator /( float f, const Mat3& m3 )
+inline Mat3 operator /(float f, const Mat3& m3)
 {
 	Mat3 out;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		out[i] = f / m3[i];
 	return out;
 }
 
 // 3x3 / float (self)
-inline Mat3& Mat3::operator /=( float f )
+inline Mat3& Mat3::operator /=(float f)
 {
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		ME[i] /= f;
 	return ME;
 }
 
 // 3x3 * vec3 (cross products with rows)
-inline Vec3 Mat3::operator *( const Vec3& b ) const
+inline Vec3 Mat3::operator *(const Vec3& b) const
 {
 	return Vec3(
 		ME(0, 0)*b.x + ME(0, 1)*b.y + ME(0, 2)*b.z,
@@ -311,93 +311,93 @@ inline Vec3 Mat3::operator *( const Vec3& 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++ )
-		if( !isZero( ME[i]-b[i] ) ) return false;
+	for(int i=0; i<9; i++)
+		if(!isZero(ME[i]-b[i])) return false;
 	return true;
 }
 
 // !=
-inline bool Mat3::operator !=( const Mat3& b ) const
+inline bool Mat3::operator !=(const Mat3& b) const
 {
-	for( int i=0; i<9; i++ )
-		if( !isZero( ME[i]-b[i] ) ) return true;
+	for(int i=0; i<9; i++)
+		if(!isZero(ME[i]-b[i])) return true;
 	return false;
 }
 
 // setRows
-inline void Mat3::setRows( const Vec3& a, const Vec3& b, const Vec3& c )
+inline void Mat3::setRows(const Vec3& a, const Vec3& b, const Vec3& c)
 {
-	ME(0,0) = a.x;
-	ME(0,1) = a.y;
-	ME(0,2) = a.z;
-	ME(1,0) = b.x;
-	ME(1,1) = b.y;
-	ME(1,2) = b.z;
-	ME(2,0) = c.x;
-	ME(2,1) = c.y;
-	ME(2,2) = c.z;
+	ME(0, 0) = a.x;
+	ME(0, 1) = a.y;
+	ME(0, 2) = a.z;
+	ME(1, 0) = b.x;
+	ME(1, 1) = b.y;
+	ME(1, 2) = b.z;
+	ME(2, 0) = c.x;
+	ME(2, 1) = c.y;
+	ME(2, 2) = c.z;
 }
 
 // setColumns
-inline void Mat3::setColumns( const Vec3& a, const Vec3& b, const Vec3& c )
+inline void Mat3::setColumns(const Vec3& a, const Vec3& b, const Vec3& c)
 {
-	ME(0,0) = a.x;
-	ME(1,0) = a.y;
-	ME(2,0) = a.z;
-	ME(0,1) = b.x;
-	ME(1,1) = b.y;
-	ME(2,1) = b.z;
-	ME(0,2) = c.x;
-	ME(1,2) = c.y;
-	ME(2,2) = c.z;
+	ME(0, 0) = a.x;
+	ME(1, 0) = a.y;
+	ME(2, 0) = a.z;
+	ME(0, 1) = b.x;
+	ME(1, 1) = b.y;
+	ME(2, 1) = b.z;
+	ME(0, 2) = c.x;
+	ME(1, 2) = c.y;
+	ME(2, 2) = c.z;
 }
 
 // getRows
-inline void Mat3::getRows( Vec3& a, Vec3& b, Vec3& c ) const
+inline void Mat3::getRows(Vec3& a, Vec3& b, Vec3& c) const
 {
-	a.x = ME(0,0);
-	a.y = ME(0,1);
-	a.z = ME(0,2);
-	b.x = ME(1,0);
-	b.y = ME(1,1);
-	b.z = ME(1,2);
-	c.x = ME(2,0);
-	c.y = ME(2,1);
-	c.z = ME(2,2);
+	a.x = ME(0, 0);
+	a.y = ME(0, 1);
+	a.z = ME(0, 2);
+	b.x = ME(1, 0);
+	b.y = ME(1, 1);
+	b.z = ME(1, 2);
+	c.x = ME(2, 0);
+	c.y = ME(2, 1);
+	c.z = ME(2, 2);
 }
 
 // getColumns
-inline void Mat3::getColumns( Vec3& a, Vec3& b, Vec3& c ) const
+inline void Mat3::getColumns(Vec3& a, Vec3& b, Vec3& c) const
 {
-	a.x = ME(0,0);
-	a.y = ME(1,0);
-	a.z = ME(2,0);
-	b.x = ME(0,1);
-	b.y = ME(1,1);
-	b.z = ME(2,1);
-	c.x = ME(0,2);
-	c.y = ME(1,2);
-	c.z = ME(2,2);
+	a.x = ME(0, 0);
+	a.y = ME(1, 0);
+	a.z = ME(2, 0);
+	b.x = ME(0, 1);
+	b.y = ME(1, 1);
+	b.z = ME(2, 1);
+	c.x = ME(0, 2);
+	c.y = ME(1, 2);
+	c.z = ME(2, 2);
 }
 
 // setRow
-inline void Mat3::setRow( const uint i, const Vec3& v )
+inline void Mat3::setRow(const uint i, const Vec3& v)
 {
-	ME(i,0)=v.x;
-	ME(i,1)=v.y;
-	ME(i,2)=v.z;
+	ME(i, 0)=v.x;
+	ME(i, 1)=v.y;
+	ME(i, 2)=v.z;
 }
 
 // getRow
-inline Vec3 Mat3::getRow( const uint i ) const
+inline Vec3 Mat3::getRow(const uint i) const
 {
-	return Vec3( ME(i,0), ME(i,1), ME(i,2) );
+	return Vec3(ME(i, 0), ME(i, 1), ME(i, 2));
 }
 
 // setColumn
-inline void Mat3::setColumn( const uint i, const Vec3& v )
+inline void Mat3::setColumn(const uint i, const Vec3& v)
 {
 	ME(0,i) = v.x;
 	ME(1,i) = v.y;
@@ -405,96 +405,96 @@ inline void Mat3::setColumn( const uint i, const Vec3& v )
 }
 
 // getColumn
-inline Vec3 Mat3::getColumn( const uint i ) const
+inline Vec3 Mat3::getColumn(const uint i) const
 {
-	return Vec3( ME(0,i), ME(1,i), ME(2,i) );
+	return Vec3(ME(0,i), ME(1,i), ME(2,i));
 }
 
 // getXAxis
 inline Vec3 Mat3::getXAxis() const
 {
-	return getColumn( 0 );
+	return getColumn(0);
 }
 
 // getYAxis
 inline Vec3 Mat3::getYAxis() const
 {
-	return getColumn( 1 );
+	return getColumn(1);
 }
 
 // getZAxis
 inline Vec3 Mat3::getZAxis() const
 {
-	return getColumn( 2 );
+	return getColumn(2);
 }
 
 // setXAxis
-inline void Mat3::setXAxis( const Vec3& v3 )
+inline void Mat3::setXAxis(const Vec3& v3)
 {
-	setColumn( 0, v3 );
+	setColumn(0, v3);
 }
 
 // setYAxis
-inline void Mat3::setYAxis( const Vec3& v3 )
+inline void Mat3::setYAxis(const Vec3& v3)
 {
-	setColumn( 1, v3 );
+	setColumn(1, v3);
 }
 
 // setZAxis
-inline void Mat3::setZAxis( const Vec3& v3 )
+inline void Mat3::setZAxis(const Vec3& v3)
 {
-	setColumn( 2, v3 );
+	setColumn(2, v3);
 }
 
 // setRotationX
-inline void Mat3::setRotationX( float rad )
+inline void Mat3::setRotationX(float rad)
 {
 	float sintheta, costheta;
-	sinCos( rad, sintheta, costheta );
+	sinCos(rad, sintheta, costheta);
 
-	ME(0,0) = 1.0;
-	ME(0,1) = 0.0;
-	ME(0,2) = 0.0;
-	ME(1,0) = 0.0;
-	ME(1,1) = costheta;
-	ME(1,2) = -sintheta;
-	ME(2,0) = 0.0;
-	ME(2,1) = sintheta;
-	ME(2,2) = costheta;
+	ME(0, 0) = 1.0;
+	ME(0, 1) = 0.0;
+	ME(0, 2) = 0.0;
+	ME(1, 0) = 0.0;
+	ME(1, 1) = costheta;
+	ME(1, 2) = -sintheta;
+	ME(2, 0) = 0.0;
+	ME(2, 1) = sintheta;
+	ME(2, 2) = costheta;
 }
 
 // setRotationY
-inline void Mat3::setRotationY( float rad )
+inline void Mat3::setRotationY(float rad)
 {
 	float sintheta, costheta;
-	sinCos( rad, sintheta, costheta );
+	sinCos(rad, sintheta, costheta);
 
-	ME(0,0) = costheta;
-	ME(0,1) = 0.0;
-	ME(0,2) = sintheta;
-	ME(1,0) = 0.0;
-	ME(1,1) = 1.0;
-	ME(1,2) = 0.0;
-	ME(2,0) = -sintheta;
-	ME(2,1) = 0.0;
-	ME(2,2) = costheta;
+	ME(0, 0) = costheta;
+	ME(0, 1) = 0.0;
+	ME(0, 2) = sintheta;
+	ME(1, 0) = 0.0;
+	ME(1, 1) = 1.0;
+	ME(1, 2) = 0.0;
+	ME(2, 0) = -sintheta;
+	ME(2, 1) = 0.0;
+	ME(2, 2) = costheta;
 }
 
 // loadRotationZ
-inline void Mat3::setRotationZ( float rad )
+inline void Mat3::setRotationZ(float rad)
 {
 	float sintheta, costheta;
-	sinCos( rad, sintheta, costheta );
+	sinCos(rad, sintheta, costheta);
 
-	ME(0,0) = costheta;
-	ME(0,1) = -sintheta;
-	ME(0,2) = 0.0;
-	ME(1,0) = sintheta;
-	ME(1,1) = costheta;
-	ME(1,2) = 0.0;
-	ME(2,0) = 0.0;
-	ME(2,1) = 0.0;
-	ME(2,2) = 1.0;
+	ME(0, 0) = costheta;
+	ME(0, 1) = -sintheta;
+	ME(0, 2) = 0.0;
+	ME(1, 0) = sintheta;
+	ME(1, 1) = costheta;
+	ME(1, 2) = 0.0;
+	ME(2, 0) = 0.0;
+	ME(2, 1) = 0.0;
+	ME(2, 2) = 1.0;
 }
 
 // rotateXAxis
@@ -502,121 +502,121 @@ inline void Mat3::setRotationZ( float rad )
 If we analize the mat3 we can extract the 3 unit vectors rotated by the mat3. The 3 rotated vectors are in mat's colomns.
 This means that: mat3.colomn[0] == i*mat3. rotateXAxis() rotates rad angle not from i vector (aka x axis) but
 from the vector from colomn 0*/
-inline void Mat3::rotateXAxis( float rad )
+inline void Mat3::rotateXAxis(float rad)
 {
 	float sina, cosa;
-	sinCos( rad, sina, cosa );
+	sinCos(rad, sina, cosa);
 
 	/*Vec3 xAxis, yAxis, zAxis;
-	getColumns( xAxis, yAxis, zAxis );*/
+	getColumns(xAxis, yAxis, zAxis);*/
 
 	// zAxis = zAxis*cosa - yAxis*sina;
-	ME(0,2) = ME(0,2)*cosa - ME(0,1)*sina;
-	ME(1,2) = ME(1,2)*cosa - ME(1,1)*sina;
-	ME(2,2) = ME(2,2)*cosa - ME(2,1)*sina;
+	ME(0, 2) = ME(0, 2)*cosa - ME(0, 1)*sina;
+	ME(1, 2) = ME(1, 2)*cosa - ME(1, 1)*sina;
+	ME(2, 2) = ME(2, 2)*cosa - ME(2, 1)*sina;
 
 	// zAxis.normalize();
-	float len = invSqrt( ME(0,2)*ME(0,2) + ME(1,2)*ME(1,2) + ME(2,2)*ME(2,2) );
-	ME(0,2) *= len;
-	ME(1,2) *= len;
-	ME(2,2) *= len;
+	float len = invSqrt(ME(0, 2)*ME(0, 2) + ME(1, 2)*ME(1, 2) + ME(2, 2)*ME(2, 2));
+	ME(0, 2) *= len;
+	ME(1, 2) *= len;
+	ME(2, 2) *= len;
 
 	// yAxis = zAxis * xAxis;
-	ME(0,1) = ME(1,2)*ME(2,0) - ME(2,2)*ME(1,0);
-	ME(1,1) = ME(2,2)*ME(0,0) - ME(0,2)*ME(2,0);
-	ME(2,1) = ME(0,2)*ME(1,0) - ME(1,2)*ME(0,0);
+	ME(0, 1) = ME(1, 2)*ME(2, 0) - ME(2, 2)*ME(1, 0);
+	ME(1, 1) = ME(2, 2)*ME(0, 0) - ME(0, 2)*ME(2, 0);
+	ME(2, 1) = ME(0, 2)*ME(1, 0) - ME(1, 2)*ME(0, 0);
 
 	// yAxis.normalize();
-	/*len = invSqrt( ME(0,1)*ME(0,1) + ME(1,1)*ME(1,1) + ME(2,1)*ME(2,1) );
-	ME(0,1) *= len;
-	ME(1,1) *= len;
-	ME(2,1) *= len;*/
+	/*len = invSqrt(ME(0, 1)*ME(0, 1) + ME(1, 1)*ME(1, 1) + ME(2, 1)*ME(2, 1));
+	ME(0, 1) *= len;
+	ME(1, 1) *= len;
+	ME(2, 1) *= len;*/
 
-	// setColumns( xAxis, yAxis, zAxis );
+	// setColumns(xAxis, yAxis, zAxis);
 
 }
 
 // rotateYAxis
-inline void Mat3::rotateYAxis( float rad )
+inline void Mat3::rotateYAxis(float rad)
 {
 	float sina, cosa;
-	sinCos( rad, sina, cosa );
+	sinCos(rad, sina, cosa);
 
 	/*Vec3 xAxis, yAxis, zAxis;
-	getColumns( xAxis, yAxis, zAxis );*/
+	getColumns(xAxis, yAxis, zAxis);*/
 
 	// zAxis = zAxis*cosa + xAxis*sina;
-	ME(0,2) = ME(0,2)*cosa + ME(0,0)*sina;
-	ME(1,2) = ME(1,2)*cosa + ME(1,0)*sina;
-	ME(2,2) = ME(2,2)*cosa + ME(2,0)*sina;
+	ME(0, 2) = ME(0, 2)*cosa + ME(0, 0)*sina;
+	ME(1, 2) = ME(1, 2)*cosa + ME(1, 0)*sina;
+	ME(2, 2) = ME(2, 2)*cosa + ME(2, 0)*sina;
 
 	// zAxis.normalize();
-	float len = invSqrt( ME(0,2)*ME(0,2) + ME(1,2)*ME(1,2) + ME(2,2)*ME(2,2) );
-	ME(0,2) *= len;
-	ME(1,2) *= len;
-	ME(2,2) *= len;
+	float len = invSqrt(ME(0, 2)*ME(0, 2) + ME(1, 2)*ME(1, 2) + ME(2, 2)*ME(2, 2));
+	ME(0, 2) *= len;
+	ME(1, 2) *= len;
+	ME(2, 2) *= len;
 
 	// xAxis = (zAxis*yAxis) * -1.0f;
-	ME(0,0) = ME(2,2)*ME(1,1) - ME(1,2)*ME(2,1);
-	ME(1,0) = ME(0,2)*ME(2,1) - ME(2,2)*ME(0,1);
-	ME(2,0) = ME(1,2)*ME(0,1) - ME(0,2)*ME(1,1);
+	ME(0, 0) = ME(2, 2)*ME(1, 1) - ME(1, 2)*ME(2, 1);
+	ME(1, 0) = ME(0, 2)*ME(2, 1) - ME(2, 2)*ME(0, 1);
+	ME(2, 0) = ME(1, 2)*ME(0, 1) - ME(0, 2)*ME(1, 1);
 
 	// xAxis.normalize();
-	/*len = invSqrt( ME(0,0)*ME(0,0) + ME(1,0)*ME(1,0) + ME(2,0)*ME(2,0) );
-	ME(0,0) *= len;
-	ME(1,0) *= len;
-	ME(2,0) *= len;*/
+	/*len = invSqrt(ME(0, 0)*ME(0, 0) + ME(1, 0)*ME(1, 0) + ME(2, 0)*ME(2, 0));
+	ME(0, 0) *= len;
+	ME(1, 0) *= len;
+	ME(2, 0) *= len;*/
 
-	// setColumns( xAxis, yAxis, zAxis );
+	// setColumns(xAxis, yAxis, zAxis);
 }
 
 
 // rotateZAxis
-inline void Mat3::rotateZAxis( float rad )
+inline void Mat3::rotateZAxis(float rad)
 {
 	float sina, cosa;
-	sinCos( rad, sina, cosa );
+	sinCos(rad, sina, cosa);
 
 	/*Vec3 xAxis, yAxis, zAxis;
-	getColumns( xAxis, yAxis, zAxis );*/
+	getColumns(xAxis, yAxis, zAxis);*/
 
 	// xAxis = xAxis*cosa + yAxis*sina;
-	ME(0,0) = ME(0,0)*cosa + ME(0,1)*sina;
-	ME(1,0) = ME(1,0)*cosa + ME(1,1)*sina;
-	ME(2,0) = ME(2,0)*cosa + ME(2,1)*sina;
+	ME(0, 0) = ME(0, 0)*cosa + ME(0, 1)*sina;
+	ME(1, 0) = ME(1, 0)*cosa + ME(1, 1)*sina;
+	ME(2, 0) = ME(2, 0)*cosa + ME(2, 1)*sina;
 
 	// xAxis.normalize();
-	float len = invSqrt( ME(0,0)*ME(0,0) + ME(1,0)*ME(1,0) + ME(2,0)*ME(2,0) );
-	ME(0,0) *= len;
-	ME(1,0) *= len;
-	ME(2,0) *= len;
+	float len = invSqrt(ME(0, 0)*ME(0, 0) + ME(1, 0)*ME(1, 0) + ME(2, 0)*ME(2, 0));
+	ME(0, 0) *= len;
+	ME(1, 0) *= len;
+	ME(2, 0) *= len;
 
 	// yAxis = zAxis*xAxis;
-	ME(0,1) = ME(1,2)*ME(2,0) - ME(2,2)*ME(1,0);
-	ME(1,1) = ME(2,2)*ME(0,0) - ME(0,2)*ME(2,0);
-	ME(2,1) = ME(0,2)*ME(1,0) - ME(1,2)*ME(0,0);
+	ME(0, 1) = ME(1, 2)*ME(2, 0) - ME(2, 2)*ME(1, 0);
+	ME(1, 1) = ME(2, 2)*ME(0, 0) - ME(0, 2)*ME(2, 0);
+	ME(2, 1) = ME(0, 2)*ME(1, 0) - ME(1, 2)*ME(0, 0);
 
 	// yAxis.normalize();
-	/*len = invSqrt( ME(0,1)*ME(0,1) + ME(1,1)*ME(1,1) + ME(2,1)*ME(2,1) );
-	ME(0,1) *= len;
-	ME(1,1) *= len;
-	ME(2,1) *= len;*/
+	/*len = invSqrt(ME(0, 1)*ME(0, 1) + ME(1, 1)*ME(1, 1) + ME(2, 1)*ME(2, 1));
+	ME(0, 1) *= len;
+	ME(1, 1) *= len;
+	ME(2, 1) *= len;*/
 
-	//setColumns( xAxis, yAxis, zAxis );
+	//setColumns(xAxis, yAxis, zAxis);
 }
 
 // transpose
 inline void Mat3::transpose()
 {
-	float temp = ME(0,1);
-	ME(0,1) = ME(1,0);
-	ME(1,0) = temp;
-	temp = ME(0,2);
-	ME(0,2) = ME(2,0);
-	ME(2,0) = temp;
-	temp = ME(1,2);
-	ME(1,2) = ME(2,1);
-	ME(2,1) = temp;
+	float temp = ME(0, 1);
+	ME(0, 1) = ME(1, 0);
+	ME(1, 0) = temp;
+	temp = ME(0, 2);
+	ME(0, 2) = ME(2, 0);
+	ME(2, 0) = temp;
+	temp = ME(1, 2);
+	ME(1, 2) = ME(2, 1);
+	ME(2, 1) = temp;
 }
 
 // transposed
@@ -649,24 +649,24 @@ inline void Mat3::reorthogonalize()
 
 	// method 2: Gram-Schmidt method with a twist for zAxis
 	Vec3 xAxis, yAxis, zAxis;
-	getColumns( xAxis, yAxis, zAxis );
+	getColumns(xAxis, yAxis, zAxis);
 
 	xAxis.normalize();
 
-	yAxis = yAxis - ( xAxis * xAxis.dot(yAxis) );
+	yAxis = yAxis - (xAxis * xAxis.dot(yAxis));
 	yAxis.normalize();
 
 	zAxis = xAxis.cross(yAxis);
 
-	setColumns( xAxis, yAxis, zAxis );
+	setColumns(xAxis, yAxis, zAxis);
 }
 
 // print
 inline void Mat3::print() const
 {
-	for( int i=0; i<3; i++ )
+	for(int i=0; i<3; i++)
 	{
-		for( int j=0; j<3; j++ )
+		for(int j=0; j<3; j++)
 			cout << fixed << ME(i, j) << " ";
 		cout << endl;
 	}
@@ -679,38 +679,38 @@ inline float Mat3::getDet() const
 	/* accurate method:
 	return ME(0, 0)*ME(1, 1)*ME(2, 2) + ME(0, 1)*ME(1, 2)*ME(2, 0) + ME(0, 2)*ME(1, 0)*ME(2, 1)
 	- ME(0, 0)*ME(1, 2)*ME(2, 1) - ME(0, 1)*ME(1, 0)*ME(2, 2) - ME(0, 2)*ME(1, 1)*ME(2, 0);*/
-	return ME(0, 0)*( ME(1, 1)*ME(2, 2) - ME(1, 2)*ME(2, 1) ) -
-	ME(0, 1)*( ME(1, 0)*ME(2, 2) - ME(1, 2)*ME(2, 0) ) +
-	ME(0, 2)*( ME(0, 1)*ME(2, 1) - ME(1, 1)*ME(2, 0) );
+	return ME(0, 0)*(ME(1, 1)*ME(2, 2) - ME(1, 2)*ME(2, 1)) -
+	ME(0, 1)*(ME(1, 0)*ME(2, 2) - ME(1, 2)*ME(2, 0)) +
+	ME(0, 2)*(ME(0, 1)*ME(2, 1) - ME(1, 1)*ME(2, 0));
 }
 
 // getInverse
-// using Gramer's method ( Inv(A) = ( 1/getDet(A) ) * Adj(A)  )
+// using Gramer's method (Inv(A) = (1/getDet(A)) * Adj(A))
 inline Mat3 Mat3::getInverse() const
 {
 	Mat3 result;
 
 	// compute determinant
-	float cofactor0 = ME(1,1)*ME(2,2) - ME(1,2)*ME(2,1);
-	float cofactor3 = ME(0,2)*ME(2,1) - ME(0,1)*ME(2,2);
-	float cofactor6 = ME(0,1)*ME(1,2) - ME(0,2)*ME(1,1);
-	float det = ME(0,0)*cofactor0 + ME(1,0)*cofactor3 + ME(2,0)*cofactor6;
+	float cofactor0 = ME(1, 1)*ME(2, 2) - ME(1, 2)*ME(2, 1);
+	float cofactor3 = ME(0, 2)*ME(2, 1) - ME(0, 1)*ME(2, 2);
+	float cofactor6 = ME(0, 1)*ME(1, 2) - ME(0, 2)*ME(1, 1);
+	float det = ME(0, 0)*cofactor0 + ME(1, 0)*cofactor3 + ME(2, 0)*cofactor6;
 
-	DEBUG_ERR( isZero( det ) ); // Cannot invert det == 0
+	DEBUG_ERR(isZero(det)); // Cannot invert det == 0
 
 	// create adjoint matrix and multiply by 1/det to get inverse
 	float invDet = 1.0f/det;
-	result(0,0) = invDet*cofactor0;
-	result(0,1) = invDet*cofactor3;
-	result(0,2) = invDet*cofactor6;
+	result(0, 0) = invDet*cofactor0;
+	result(0, 1) = invDet*cofactor3;
+	result(0, 2) = invDet*cofactor6;
 
-	result(1,0) = invDet*(ME(1,2)*ME(2,0) - ME(1,0)*ME(2,2));
-	result(1,1) = invDet*(ME(0,0)*ME(2,2) - ME(0,2)*ME(2,0));
-	result(1,2) = invDet*(ME(0,2)*ME(1,0) - ME(0,0)*ME(1,2));
+	result(1, 0) = invDet*(ME(1, 2)*ME(2, 0) - ME(1, 0)*ME(2, 2));
+	result(1, 1) = invDet*(ME(0, 0)*ME(2, 2) - ME(0, 2)*ME(2, 0));
+	result(1, 2) = invDet*(ME(0, 2)*ME(1, 0) - ME(0, 0)*ME(1, 2));
 
-	result(2,0) = invDet*(ME(1,0)*ME(2,1) - ME(1,1)*ME(2,0));
-	result(2,1) = invDet*(ME(0,1)*ME(2,0) - ME(0,0)*ME(2,1));
-	result(2,2) = invDet*(ME(0,0)*ME(1,1) - ME(0,1)*ME(1,0));
+	result(2, 0) = invDet*(ME(1, 0)*ME(2, 1) - ME(1, 1)*ME(2, 0));
+	result(2, 1) = invDet*(ME(0, 1)*ME(2, 0) - ME(0, 0)*ME(2, 1));
+	result(2, 2) = invDet*(ME(0, 0)*ME(1, 1) - ME(0, 1)*ME(1, 0));
 
 	return result;
 }
@@ -731,14 +731,14 @@ inline void Mat3::invert()
 // getZero
 inline const Mat3& Mat3::getZero()
 {
-	static Mat3 zero( 0.0 );
+	static Mat3 zero(0.0);
 	return zero;
 }
 
 // getIdentity
 inline const Mat3& Mat3::getIdentity()
 {
-	static Mat3 ident( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
+	static Mat3 ident(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
 	return ident;
 }
 

+ 47 - 46
src/Math/Mat4.h

@@ -20,54 +20,55 @@ class Mat4
 
 	public:
 		// access to the data
-		float& operator ()( const uint i, const uint j );
-		const float& operator ()( const uint i, const uint j ) const;
-		float& operator []( const uint i);
-		const float& operator []( const uint i) const;
+		float& operator ()(const uint i, const uint j);
+		const float& operator ()(const uint i, const uint j) const;
+		float& operator [](const uint i);
+		const float& operator [](const uint i) const;
 		// constructors & distructors
 		explicit Mat4() {}
-		explicit Mat4( float f );
-		explicit Mat4( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33 );
-		explicit Mat4( const float arr [] );
-		         Mat4( const Mat4& b );
-		explicit Mat4( const Mat3& m3 );
-		explicit Mat4( const Vec3& v );
-		explicit Mat4( const Vec4& v );
-		explicit Mat4( const Vec3& transl, const Mat3& rot );
-		explicit Mat4( const Vec3& transl, const Mat3& rot, float scale );
-		explicit Mat4( const Transform& t );
+		explicit Mat4(float f);
+		explicit Mat4(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20,
+		               float m21, float m22, float m23, float m30, float m31, float m32, float m33);
+		explicit Mat4(const float arr []);
+		         Mat4(const Mat4& b);
+		explicit Mat4(const Mat3& m3);
+		explicit Mat4(const Vec3& v);
+		explicit Mat4(const Vec4& v);
+		explicit Mat4(const Vec3& transl, const Mat3& rot);
+		explicit Mat4(const Vec3& transl, const Mat3& rot, float scale);
+		explicit Mat4(const Transform& t);
 		// ops with same type
-		Mat4  operator + ( const Mat4& b ) const;
-		Mat4& operator +=( const Mat4& b );
-		Mat4  operator - ( const Mat4& b ) const;
-		Mat4& operator -=( const Mat4& b );
-		Mat4  operator * ( const Mat4& b ) const; ///< 64 muls, 48 adds
-		Mat4& operator *=( const Mat4& b );
-		Mat4  operator / ( const Mat4& b ) const;
-		Mat4& operator /=( const Mat4& b );
+		Mat4  operator + (const Mat4& b) const;
+		Mat4& operator +=(const Mat4& b);
+		Mat4  operator - (const Mat4& b) const;
+		Mat4& operator -=(const Mat4& b);
+		Mat4  operator * (const Mat4& b) const; ///< 64 muls, 48 adds
+		Mat4& operator *=(const Mat4& b);
+		Mat4  operator / (const Mat4& b) const;
+		Mat4& operator /=(const Mat4& b);
 		// ops with float
-		Mat4  operator + ( float f ) const;
-		Mat4& operator +=( float f );
-		Mat4  operator - ( float f ) const;
-		Mat4& operator -=( float f );
-		Mat4  operator * ( float f ) const;
-		Mat4& operator *=( float f );
-		Mat4  operator / ( float f ) const;
-		Mat4& operator /=( float f );
+		Mat4  operator + (float f) const;
+		Mat4& operator +=(float f);
+		Mat4  operator - (float f) const;
+		Mat4& operator -=(float f);
+		Mat4  operator * (float f) const;
+		Mat4& operator *=(float f);
+		Mat4  operator / (float f) const;
+		Mat4& operator /=(float f);
 		// ops with other types
-		Vec4  operator * ( const Vec4& v4 ) const; ///< 16 muls, 12 adds
+		Vec4  operator * (const Vec4& v4) const; ///< 16 muls, 12 adds
 		// comparision
-		bool operator ==( const Mat4& b ) const;
-		bool operator !=( const Mat4& b ) const;
+		bool operator ==(const Mat4& b) const;
+		bool operator !=(const Mat4& b) const;
 		// other
-		void  setRows( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d );
-		void  setRow( uint i, const Vec4& v );
-		void  setColumns( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d );
-		void  setColumn( uint i, const Vec4& v );
-		void  setRotationPart( const Mat3& m3 );
-		void  setTranslationPart( const Vec4& v4 );
+		void  setRows(const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d);
+		void  setRow(uint i, const Vec4& v);
+		void  setColumns(const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d);
+		void  setColumn(uint i, const Vec4& v);
+		void  setRotationPart(const Mat3& m3);
+		void  setTranslationPart(const Vec4& v4);
 		Mat3  getRotationPart() const;
-		void  setTranslationPart( const Vec3& v3 );
+		void  setTranslationPart(const Vec3& v3);
 		Vec3  getTranslationPart() const;
 		void  transpose();
 		Mat4  getTransposed() const;
@@ -76,19 +77,19 @@ class Mat4
 		void  invert();
 		Mat4  getInverse() const;
 		Mat4  getInverseTransformation() const;
-		Mat4  lerp( const Mat4& b, float t ) const;
+		Mat4  lerp(const Mat4& b, float t) const;
 		void  setIdentity();
-		static Mat4 combineTransformations( const Mat4& m0, const Mat4& m1 ); ///< 12 muls, 27 adds. Something like m4 = m0 * m1 but without touching the 4rth row and allot faster
+		static Mat4 combineTransformations(const Mat4& m0, const Mat4& m1); ///< 12 muls, 27 adds. Something like m4 = m0 * m1 but without touching the 4rth row and allot faster
 		static const Mat4& getIdentity();
 		static const Mat4& getZero();
 };
 
 
 // other operators
-extern Mat4 operator +( float f, const Mat4& m4 );
-extern Mat4 operator -( float f, const Mat4& m4 );
-extern Mat4 operator *( float f, const Mat4& m4 );
-extern Mat4 operator /( float f, const Mat4& m4 );
+extern Mat4 operator +(float f, const Mat4& m4);
+extern Mat4 operator -(float f, const Mat4& m4);
+extern Mat4 operator *(float f, const Mat4& m4);
+extern Mat4 operator /(float f, const Mat4& m4);
 
 
 } // end namespace

+ 276 - 277
src/Math/Mat4.inl.h

@@ -7,79 +7,80 @@
 namespace M {
 
 // accessors
-inline float& Mat4::operator ()( const uint i, const uint j )
+inline float& Mat4::operator ()(const uint i, const uint j)
 {
 	return arr2[i][j];
 }
 
-inline const float& Mat4::operator ()( const uint i, const uint j ) const
+inline const float& Mat4::operator ()(const uint i, const uint j) const
 {
 	return arr2[i][j];
 }
 
-inline float& Mat4::operator []( const uint i) 
+inline float& Mat4::operator [](const uint i) 
 { 
 	return arr1[i]; 
 }
 
-inline const float& Mat4::operator []( const uint i) const 
+inline const float& Mat4::operator [](const uint i) const 
 { 
 	return arr1[i]; 
 }
 
 // constructor [mat4]
-inline Mat4::Mat4( const Mat4& b )
+inline Mat4::Mat4(const Mat4& b)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] = b[i];
 }
 
 // constructor [float[]]
-inline Mat4::Mat4( const float arr_ [] )
+inline Mat4::Mat4(const float arr_ [])
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] = arr_[i];
 }
 
 // constructor [float..........]
-inline Mat4::Mat4( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33 )
-{
-	ME(0,0) = m00;
-	ME(0,1) = m01;
-	ME(0,2) = m02;
-	ME(0,3) = m03;
-	ME(1,0) = m10;
-	ME(1,1) = m11;
-	ME(1,2) = m12;
-	ME(1,3) = m13;
-	ME(2,0) = m20;
-	ME(2,1) = m21;
-	ME(2,2) = m22;
-	ME(2,3) = m23;
-	ME(3,0) = m30;
-	ME(3,1) = m31;
-	ME(3,2) = m32;
-	ME(3,3) = m33;
+inline Mat4::Mat4(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20,
+                  float m21, float m22, float m23, float m30, float m31, float m32, float m33)
+{
+	ME(0, 0) = m00;
+	ME(0, 1) = m01;
+	ME(0, 2) = m02;
+	ME(0, 3) = m03;
+	ME(1, 0) = m10;
+	ME(1, 1) = m11;
+	ME(1, 2) = m12;
+	ME(1, 3) = m13;
+	ME(2, 0) = m20;
+	ME(2, 1) = m21;
+	ME(2, 2) = m22;
+	ME(2, 3) = m23;
+	ME(3, 0) = m30;
+	ME(3, 1) = m31;
+	ME(3, 2) = m32;
+	ME(3, 3) = m33;
 }
 
 // constructor [mat3]
-inline Mat4::Mat4( const Mat3& m3 )
-{
-	ME(0,0) = m3(0,0);
-	ME(0,1) = m3(0,1);
-	ME(0,2) = m3(0,2);
-	ME(1,0) = m3(1,0);
-	ME(1,1) = m3(1,1);
-	ME(1,2) = m3(1,2);
-	ME(2,0) = m3(2,0);
-	ME(2,1) = m3(2,1);
-	ME(2,2) = m3(2,2);
+inline Mat4::Mat4(const Mat3& m3)
+{
+	ME(0, 0) = m3(0, 0);
+	ME(0, 1) = m3(0, 1);
+	ME(0, 2) = m3(0, 2);
+	ME(1, 0) = m3(1, 0);
+	ME(1, 1) = m3(1, 1);
+	ME(1, 2) = m3(1, 2);
+	ME(2, 0) = m3(2, 0);
+	ME(2, 1) = m3(2, 1);
+	ME(2, 2) = m3(2, 2);
 	ME(3, 0) = ME(3, 1) = ME(3, 2) = ME(0, 3) = ME(1, 3) = ME(2, 3) = 0.0;
 	ME(3, 3) = 1.0;
 }
 
 // constructor [vec3]
-inline Mat4::Mat4( const Vec3& v )
+inline Mat4::Mat4(const Vec3& v)
 {
 	ME(0, 0) = 1.0;
 	ME(0, 1) = 0.0;
@@ -100,7 +101,7 @@ inline Mat4::Mat4( const Vec3& v )
 }
 
 // constructor [vec4]
-inline Mat4::Mat4( const Vec4& v )
+inline Mat4::Mat4(const Vec4& v)
 {
 	ME(0, 0) = 1.0;
 	ME(0, 1) = 0.0;
@@ -121,286 +122,284 @@ inline Mat4::Mat4( const Vec4& v )
 }
 
 // constructor [vec3, mat3]
-inline Mat4::Mat4( const Vec3& transl, const Mat3& rot )
+inline Mat4::Mat4(const Vec3& transl, const Mat3& rot)
 {
 	setRotationPart(rot);
 	setTranslationPart(transl);
-	ME(3,0) = ME(3,1) = ME(3,2) = 0.0;
-	ME(3,3) = 1.0;
+	ME(3, 0) = ME(3, 1) = ME(3, 2) = 0.0;
+	ME(3, 3) = 1.0;
 }
 
 // constructor [vec3, mat3, float]
-inline Mat4::Mat4( const Vec3& translate, const Mat3& rotate, float scale )
+inline Mat4::Mat4(const Vec3& translate, const Mat3& rotate, float scale)
 {
-	if( !isZero( scale-1.0 ) )
-		setRotationPart( rotate*scale );
+	if(!isZero(scale-1.0))
+		setRotationPart(rotate*scale);
 	else
-		setRotationPart( rotate );
+		setRotationPart(rotate);
 
-	setTranslationPart( translate );
+	setTranslationPart(translate);
 
-	ME(3,0) = ME(3,1) = ME(3,2) = 0.0;
-	ME(3,3) = 1.0;
+	ME(3, 0) = ME(3, 1) = ME(3, 2) = 0.0;
+	ME(3, 3) = 1.0;
 }
 
 // constructor [float]
-inline Mat4::Mat4( float f )
+inline Mat4::Mat4(float f)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] = f;
 }
 
 // constructor [Transform]
-inline Mat4::Mat4( const Transform& t )
+inline Mat4::Mat4(const Transform& t)
 {
-	ME = Mat4( t.getOrigin(), t.getRotation(), t.getScale() );
+	ME = Mat4(t.getOrigin(), t.getRotation(), t.getScale());
 }
 
 // 4x4 + 4x4
-inline Mat4 Mat4::operator +( const Mat4& b ) const
+inline Mat4 Mat4::operator +(const Mat4& b) const
 {
 	Mat4 c;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		c[i] = ME[i] + b[i];
 	return c;
 }
 
 // 4x4 + 4x4 (self)
-inline Mat4& Mat4::operator +=( const Mat4& b )
+inline Mat4& Mat4::operator +=(const Mat4& b)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] += b[i];
 	return ME;
 }
 
 // 4x4 - 4x4
-inline Mat4 Mat4::operator -( const Mat4& b ) const
+inline Mat4 Mat4::operator -(const Mat4& b) const
 {
 	Mat4 c;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		c[i] = ME[i] - b[i];
 	return c;
 }
 
 // 4x4 - 4x4 (self)
-inline Mat4& Mat4::operator -=( const Mat4& b )
+inline Mat4& Mat4::operator -=(const Mat4& b)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] -= b[i];
 	return ME;
 }
 
 // 4x4 * 4x4
-inline Mat4 Mat4::operator *( const Mat4& b ) const
+inline Mat4 Mat4::operator *(const Mat4& b) const
 {
 	Mat4 c;
-	c(0,0) = ME(0,0)*b(0,0) + ME(0,1)*b(1,0) + ME(0,2)*b(2,0) + ME(0,3)*b(3,0);
-	c(0,1) = ME(0,0)*b(0,1) + ME(0,1)*b(1,1) + ME(0,2)*b(2,1) + ME(0,3)*b(3,1);
-	c(0,2) = ME(0,0)*b(0,2) + ME(0,1)*b(1,2) + ME(0,2)*b(2,2) + ME(0,3)*b(3,2);
-	c(0,3) = ME(0,0)*b(0,3) + ME(0,1)*b(1,3) + ME(0,2)*b(2,3) + ME(0,3)*b(3,3);
-	c(1,0) = ME(1,0)*b(0,0) + ME(1,1)*b(1,0) + ME(1,2)*b(2,0) + ME(1,3)*b(3,0);
-	c(1,1) = ME(1,0)*b(0,1) + ME(1,1)*b(1,1) + ME(1,2)*b(2,1) + ME(1,3)*b(3,1);
-	c(1,2) = ME(1,0)*b(0,2) + ME(1,1)*b(1,2) + ME(1,2)*b(2,2) + ME(1,3)*b(3,2);
-	c(1,3) = ME(1,0)*b(0,3) + ME(1,1)*b(1,3) + ME(1,2)*b(2,3) + ME(1,3)*b(3,3);
-	c(2,0) = ME(2,0)*b(0,0) + ME(2,1)*b(1,0) + ME(2,2)*b(2,0) + ME(2,3)*b(3,0);
-	c(2,1) = ME(2,0)*b(0,1) + ME(2,1)*b(1,1) + ME(2,2)*b(2,1) + ME(2,3)*b(3,1);
-	c(2,2) = ME(2,0)*b(0,2) + ME(2,1)*b(1,2) + ME(2,2)*b(2,2) + ME(2,3)*b(3,2);
-	c(2,3) = ME(2,0)*b(0,3) + ME(2,1)*b(1,3) + ME(2,2)*b(2,3) + ME(2,3)*b(3,3);
-	c(3,0) = ME(3,0)*b(0,0) + ME(3,1)*b(1,0) + ME(3,2)*b(2,0) + ME(3,3)*b(3,0);
-	c(3,1) = ME(3,0)*b(0,1) + ME(3,1)*b(1,1) + ME(3,2)*b(2,1) + ME(3,3)*b(3,1);
-	c(3,2) = ME(3,0)*b(0,2) + ME(3,1)*b(1,2) + ME(3,2)*b(2,2) + ME(3,3)*b(3,2);
-	c(3,3) = ME(3,0)*b(0,3) + ME(3,1)*b(1,3) + ME(3,2)*b(2,3) + ME(3,3)*b(3,3);
+	c(0, 0) = ME(0, 0)*b(0, 0) + ME(0, 1)*b(1, 0) + ME(0, 2)*b(2, 0) + ME(0, 3)*b(3, 0);
+	c(0, 1) = ME(0, 0)*b(0, 1) + ME(0, 1)*b(1, 1) + ME(0, 2)*b(2, 1) + ME(0, 3)*b(3, 1);
+	c(0, 2) = ME(0, 0)*b(0, 2) + ME(0, 1)*b(1, 2) + ME(0, 2)*b(2, 2) + ME(0, 3)*b(3, 2);
+	c(0, 3) = ME(0, 0)*b(0, 3) + ME(0, 1)*b(1, 3) + ME(0, 2)*b(2, 3) + ME(0, 3)*b(3, 3);
+	c(1, 0) = ME(1, 0)*b(0, 0) + ME(1, 1)*b(1, 0) + ME(1, 2)*b(2, 0) + ME(1, 3)*b(3, 0);
+	c(1, 1) = ME(1, 0)*b(0, 1) + ME(1, 1)*b(1, 1) + ME(1, 2)*b(2, 1) + ME(1, 3)*b(3, 1);
+	c(1, 2) = ME(1, 0)*b(0, 2) + ME(1, 1)*b(1, 2) + ME(1, 2)*b(2, 2) + ME(1, 3)*b(3, 2);
+	c(1, 3) = ME(1, 0)*b(0, 3) + ME(1, 1)*b(1, 3) + ME(1, 2)*b(2, 3) + ME(1, 3)*b(3, 3);
+	c(2, 0) = ME(2, 0)*b(0, 0) + ME(2, 1)*b(1, 0) + ME(2, 2)*b(2, 0) + ME(2, 3)*b(3, 0);
+	c(2, 1) = ME(2, 0)*b(0, 1) + ME(2, 1)*b(1, 1) + ME(2, 2)*b(2, 1) + ME(2, 3)*b(3, 1);
+	c(2, 2) = ME(2, 0)*b(0, 2) + ME(2, 1)*b(1, 2) + ME(2, 2)*b(2, 2) + ME(2, 3)*b(3, 2);
+	c(2, 3) = ME(2, 0)*b(0, 3) + ME(2, 1)*b(1, 3) + ME(2, 2)*b(2, 3) + ME(2, 3)*b(3, 3);
+	c(3, 0) = ME(3, 0)*b(0, 0) + ME(3, 1)*b(1, 0) + ME(3, 2)*b(2, 0) + ME(3, 3)*b(3, 0);
+	c(3, 1) = ME(3, 0)*b(0, 1) + ME(3, 1)*b(1, 1) + ME(3, 2)*b(2, 1) + ME(3, 3)*b(3, 1);
+	c(3, 2) = ME(3, 0)*b(0, 2) + ME(3, 1)*b(1, 2) + ME(3, 2)*b(2, 2) + ME(3, 3)*b(3, 2);
+	c(3, 3) = ME(3, 0)*b(0, 3) + ME(3, 1)*b(1, 3) + ME(3, 2)*b(2, 3) + ME(3, 3)*b(3, 3);
 	return c;
 }
 
 // 4x4 * 4x4 (self)
-inline Mat4& Mat4::operator *=( const Mat4& b )
+inline Mat4& Mat4::operator *=(const Mat4& b)
 {
 	ME = ME * b;
 	return ME;
 }
 
 // ==
-inline bool Mat4::operator ==( const Mat4& b ) const
+inline bool Mat4::operator ==(const Mat4& b) const
 {
-	for( int i=0; i<16; i++ )
-		if( !isZero( ME[i]-b[i] ) ) return false;
+	for(int i=0; i<16; i++)
+		if(!isZero(ME[i]-b[i])) return false;
 	return true;
 }
 
 // !=
-inline bool Mat4::operator !=( const Mat4& b ) const
+inline bool Mat4::operator !=(const Mat4& b) const
 {
-	for( int i=0; i<16; i++ )
-		if( !isZero( ME[i]-b[i] ) ) return true;
+	for(int i=0; i<16; i++)
+		if(!isZero(ME[i]-b[i])) return true;
 	return false;
 }
 
 // 4x4 * vec4
-inline Vec4 Mat4::operator *( const Vec4& b ) const
+inline Vec4 Mat4::operator *(const Vec4& b) const
 {
-	return Vec4(
-		ME(0,0)*b.x + ME(0,1)*b.y + ME(0,2)*b.z + ME(0,3)*b.w,
-		ME(1,0)*b.x + ME(1,1)*b.y + ME(1,2)*b.z + ME(1,3)*b.w,
-		ME(2,0)*b.x + ME(2,1)*b.y + ME(2,2)*b.z + ME(2,3)*b.w,
-		ME(3,0)*b.x + ME(3,1)*b.y + ME(3,2)*b.z + ME(3,3)*b.w
-	);
+	return Vec4(ME(0, 0)*b.x + ME(0, 1)*b.y + ME(0, 2)*b.z + ME(0, 3)*b.w,
+	            ME(1, 0)*b.x + ME(1, 1)*b.y + ME(1, 2)*b.z + ME(1, 3)*b.w,
+	            ME(2, 0)*b.x + ME(2, 1)*b.y + ME(2, 2)*b.z + ME(2, 3)*b.w,
+	            ME(3, 0)*b.x + ME(3, 1)*b.y + ME(3, 2)*b.z + ME(3, 3)*b.w);
 }
 
 // 4x4 + float
-inline Mat4 Mat4::operator +( float f ) const
+inline Mat4 Mat4::operator +(float f) const
 {
 	Mat4 c;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		c[i] = ME[i] + f;
 	return c;
 }
 
 // float + 4x4
-inline Mat4 operator +( float f, const Mat4& m4 )
+inline Mat4 operator +(float f, const Mat4& m4)
 {
 	return m4+f;
 }
 
 // 4x4 + float (self)
-inline Mat4& Mat4::operator +=( float f )
+inline Mat4& Mat4::operator +=(float f)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] += f;
 	return ME;
 }
 
 // 4x4 - float
-inline Mat4 Mat4::operator -( float f ) const
+inline Mat4 Mat4::operator -(float f) const
 {
 	Mat4 c;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		c[i] = ME[i] - f;
 	return c;
 }
 
 // float - 4x4
-inline Mat4 operator -( float f, const Mat4& m4 )
+inline Mat4 operator -(float f, const Mat4& m4)
 {
 	Mat4 out;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		out[i] = f- m4[i];
 	return out;
 }
 
 // 4x4 - float (self)
-inline Mat4& Mat4::operator -=( float f )
+inline Mat4& Mat4::operator -=(float f)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] -= f;
 	return ME;
 }
 
 // 4x4 * float
-inline Mat4 Mat4::operator *( float f ) const
+inline Mat4 Mat4::operator *(float f) const
 {
 	Mat4 c;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		c[i] = ME[i] * f;
 	return c;
 }
 
 // float * 4x4
-inline Mat4 operator *( float f, const Mat4& m4 )
+inline Mat4 operator *(float f, const Mat4& m4)
 {
 	return m4*f;
 }
 
 // 4x4 *= float
-inline Mat4& Mat4::operator *=( float f )
+inline Mat4& Mat4::operator *=(float f)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] *= f;
 	return ME;
 }
 
 // 4x4 / float
-inline Mat4 Mat4::operator /( float f ) const
+inline Mat4 Mat4::operator /(float f) const
 {
 	Mat4 c;
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		c[i] = ME[i] / f;
 	return c;
 }
 
 // float / 4x4
-inline Mat4 operator /( float f, const Mat4& m4 )
+inline Mat4 operator /(float f, const Mat4& m4)
 {
 	Mat4 out;
-	for( uint i=0; i<9; i++ )
+	for(uint i=0; i<9; i++)
 		out[i] = f / m4[i];
 	return out;
 }
 
 // 4x4 /= float
-inline Mat4& Mat4::operator /=( float f )
+inline Mat4& Mat4::operator /=(float f)
 {
-	for( int i=0; i<16; i++ )
+	for(int i=0; i<16; i++)
 		ME[i] /= f;
 	return ME;
 }
 
 // setRows
-inline void Mat4::setRows( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d )
-{
-	ME(0,0) = a.x;
-	ME(0,1) = a.y;
-	ME(0,2) = a.z;
-	ME(0,3) = a.w;
-	ME(1,0) = b.x;
-	ME(1,1) = b.y;
-	ME(1,2) = b.z;
-	ME(1,3) = b.w;
-	ME(2,0) = c.x;
-	ME(2,1) = c.y;
-	ME(2,2) = c.z;
-	ME(2,3) = c.w;
-	ME(3,0) = d.x;
-	ME(3,1) = d.y;
-	ME(3,2) = d.z;
-	ME(3,3) = d.w;
+inline void Mat4::setRows(const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d)
+{
+	ME(0, 0) = a.x;
+	ME(0, 1) = a.y;
+	ME(0, 2) = a.z;
+	ME(0, 3) = a.w;
+	ME(1, 0) = b.x;
+	ME(1, 1) = b.y;
+	ME(1, 2) = b.z;
+	ME(1, 3) = b.w;
+	ME(2, 0) = c.x;
+	ME(2, 1) = c.y;
+	ME(2, 2) = c.z;
+	ME(2, 3) = c.w;
+	ME(3, 0) = d.x;
+	ME(3, 1) = d.y;
+	ME(3, 2) = d.z;
+	ME(3, 3) = d.w;
 }
 
 // setRow
-inline void Mat4::setRow( uint i, const Vec4& v )
+inline void Mat4::setRow(uint i, const Vec4& v)
 {
-	DEBUG_ERR( i > 3 );
-	ME(i,0) = v.x;
-	ME(i,1) = v.y;
-	ME(i,2) = v.z;
-	ME(i,3) = v.w;
+	DEBUG_ERR(i > 3);
+	ME(i, 0) = v.x;
+	ME(i, 1) = v.y;
+	ME(i, 2) = v.z;
+	ME(i, 3) = v.w;
 }
 
 // setColumns
-inline void Mat4::setColumns( const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d )
-{
-	ME(0,0) = a.x;
-	ME(1,0) = a.y;
-	ME(2,0) = a.z;
-	ME(3,0) = a.w;
-	ME(0,1) = b.x;
-	ME(1,1) = b.y;
-	ME(2,1) = b.z;
-	ME(3,1) = b.w;
-	ME(0,2) = c.x;
-	ME(1,2) = c.y;
-	ME(2,2) = c.z;
-	ME(3,2) = c.w;
-	ME(0,3) = d.x;
-	ME(1,3) = d.y;
-	ME(2,3) = d.z;
-	ME(3,3) = d.w;
+inline void Mat4::setColumns(const Vec4& a, const Vec4& b, const Vec4& c, const Vec4& d)
+{
+	ME(0, 0) = a.x;
+	ME(1, 0) = a.y;
+	ME(2, 0) = a.z;
+	ME(3, 0) = a.w;
+	ME(0, 1) = b.x;
+	ME(1, 1) = b.y;
+	ME(2, 1) = b.z;
+	ME(3, 1) = b.w;
+	ME(0, 2) = c.x;
+	ME(1, 2) = c.y;
+	ME(2, 2) = c.z;
+	ME(3, 2) = c.w;
+	ME(0, 3) = d.x;
+	ME(1, 3) = d.y;
+	ME(2, 3) = d.z;
+	ME(3, 3) = d.w;
 }
 
 // setColumn
-inline void Mat4::setColumn( uint i, const Vec4& v )
+inline void Mat4::setColumn(uint i, const Vec4& v)
 {
-	DEBUG_ERR( i > 3 );
+	DEBUG_ERR(i > 3);
 	ME(0,i) = v.x;
 	ME(1,i) = v.y;
 	ME(2,i) = v.z;
@@ -410,24 +409,24 @@ inline void Mat4::setColumn( uint i, const Vec4& v )
 // transpose
 inline void Mat4::transpose()
 {
-	float tmp = ME(0,1);
-	ME(0,1) = ME(1,0);
-	ME(1,0) = tmp;
-	tmp = ME(0,2);
-	ME(0,2) = ME(2,0);
-	ME(2,0) = tmp;
-	tmp = ME(0,3);
-	ME(0,3) = ME(3,0);
-	ME(3,0) = tmp;
-	tmp = ME(1,2);
-	ME(1,2) = ME(2,1);
-	ME(2,1) = tmp;
-	tmp = ME(1,3);
-	ME(1,3) = ME(3,1);
-	ME(3,1) = tmp;
-	tmp = ME(2,3);
-	ME(2,3) = ME(3,2);
-	ME(3,2) = tmp;
+	float tmp = ME(0, 1);
+	ME(0, 1) = ME(1, 0);
+	ME(1, 0) = tmp;
+	tmp = ME(0, 2);
+	ME(0, 2) = ME(2, 0);
+	ME(2, 0) = tmp;
+	tmp = ME(0, 3);
+	ME(0, 3) = ME(3, 0);
+	ME(3, 0) = tmp;
+	tmp = ME(1, 2);
+	ME(1, 2) = ME(2, 1);
+	ME(2, 1) = tmp;
+	tmp = ME(1, 3);
+	ME(1, 3) = ME(3, 1);
+	ME(3, 1) = tmp;
+	tmp = ME(2, 3);
+	ME(2, 3) = ME(3, 2);
+	ME(3, 2) = tmp;
 }
 
 // getTransposed
@@ -455,37 +454,37 @@ inline Mat4 Mat4::getTransposed() const
 }
 
 // setRotationPart
-inline void Mat4::setRotationPart( const Mat3& m3 )
+inline void Mat4::setRotationPart(const Mat3& m3)
 {
-	ME(0,0) = m3(0,0);
-	ME(0,1) = m3(0,1);
-	ME(0,2) = m3(0,2);
-	ME(1,0) = m3(1,0);
-	ME(1,1) = m3(1,1);
-	ME(1,2) = m3(1,2);
-	ME(2,0) = m3(2,0);
-	ME(2,1) = m3(2,1);
-	ME(2,2) = m3(2,2);
+	ME(0, 0) = m3(0, 0);
+	ME(0, 1) = m3(0, 1);
+	ME(0, 2) = m3(0, 2);
+	ME(1, 0) = m3(1, 0);
+	ME(1, 1) = m3(1, 1);
+	ME(1, 2) = m3(1, 2);
+	ME(2, 0) = m3(2, 0);
+	ME(2, 1) = m3(2, 1);
+	ME(2, 2) = m3(2, 2);
 }
 
 // getRotationPart
 inline Mat3 Mat4::getRotationPart() const
 {
 	Mat3 m3;
-	m3(0,0) = ME(0,0);
-	m3(0,1) = ME(0,1);
-	m3(0,2) = ME(0,2);
-	m3(1,0) = ME(1,0);
-	m3(1,1) = ME(1,1);
-	m3(1,2) = ME(1,2);
-	m3(2,0) = ME(2,0);
-	m3(2,1) = ME(2,1);
-	m3(2,2) = ME(2,2);
+	m3(0, 0) = ME(0, 0);
+	m3(0, 1) = ME(0, 1);
+	m3(0, 2) = ME(0, 2);
+	m3(1, 0) = ME(1, 0);
+	m3(1, 1) = ME(1, 1);
+	m3(1, 2) = ME(1, 2);
+	m3(2, 0) = ME(2, 0);
+	m3(2, 1) = ME(2, 1);
+	m3(2, 2) = ME(2, 2);
 	return m3;
 }
 
 // setTranslationPart
-inline void Mat4::setTranslationPart( const Vec4& v )
+inline void Mat4::setTranslationPart(const Vec4& v)
 {
 	ME(0, 3) = v.x;
 	ME(1, 3) = v.y;
@@ -494,7 +493,7 @@ inline void Mat4::setTranslationPart( const Vec4& v )
 }
 
 // setTranslationPart
-inline void Mat4::setTranslationPart( const Vec3& v )
+inline void Mat4::setTranslationPart(const Vec3& v)
 {
 	ME(0, 3) = v.x;
 	ME(1, 3) = v.y;
@@ -504,20 +503,20 @@ inline void Mat4::setTranslationPart( const Vec3& v )
 // getTranslationPart
 inline Vec3 Mat4::getTranslationPart() const
 {
-	return Vec3( ME(0, 3), ME(1, 3), ME(2, 3) );
+	return Vec3(ME(0, 3), ME(1, 3), ME(2, 3));
 }
 
 // getIdentity
 inline const Mat4& Mat4::getIdentity()
 {
-	static Mat4 ident( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 );
+	static Mat4 ident(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
 	return ident;
 }
 
 // getZero
 inline const Mat4& Mat4::getZero()
 {
-	static Mat4 zero( 0.0 );
+	static Mat4 zero(0.0);
 	return zero;
 }
 
@@ -525,11 +524,11 @@ inline const Mat4& Mat4::getZero()
 inline void Mat4::print() const
 {
 	cout << fixed;
-	for( int i=0; i<4; i++ )
+	for(int i=0; i<4; i++)
 	{
-		for( int j=0; j<4; j++ )
+		for(int j=0; j<4; j++)
 		{
-			if( ME(i, j) < 0.0 )
+			if(ME(i, j) < 0.0)
 				cout << ME(i, j) << " ";
 			else
 				cout << " " << ME(i, j) << " ";
@@ -573,70 +572,70 @@ inline Mat4 Mat4::getInverse() const
 	Mat4 m4;
 
 
-	tmp[0] = in(2,2) * in(3,3);
-	tmp[1] = in(3,2) * in(2,3);
-	tmp[2] = in(1,2) * in(3,3);
-	tmp[3] = in(3,2) * in(1,3);
-	tmp[4] = in(1,2) * in(2,3);
-	tmp[5] = in(2,2) * in(1,3);
-	tmp[6] = in(0,2) * in(3,3);
-	tmp[7] = in(3,2) * in(0,3);
-	tmp[8] = in(0,2) * in(2,3);
-	tmp[9] = in(2,2) * in(0,3);
-	tmp[10] = in(0,2) * in(1,3);
-	tmp[11] = in(1,2) * in(0,3);
-
-	m4(0,0) =  tmp[0]*in(1,1) + tmp[3]*in(2,1) + tmp[4]*in(3,1);
-	m4(0,0) -= tmp[1]*in(1,1) + tmp[2]*in(2,1) + tmp[5]*in(3,1);
-	m4(0,1) =  tmp[1]*in(0,1) + tmp[6]*in(2,1) + tmp[9]*in(3,1);
-	m4(0,1) -= tmp[0]*in(0,1) + tmp[7]*in(2,1) + tmp[8]*in(3,1);
-	m4(0,2) =  tmp[2]*in(0,1) + tmp[7]*in(1,1) + tmp[10]*in(3,1);
-	m4(0,2) -= tmp[3]*in(0,1) + tmp[6]*in(1,1) + tmp[11]*in(3,1);
-	m4(0,3) =  tmp[5]*in(0,1) + tmp[8]*in(1,1) + tmp[11]*in(2,1);
-	m4(0,3) -= tmp[4]*in(0,1) + tmp[9]*in(1,1) + tmp[10]*in(2,1);
-	m4(1,0) =  tmp[1]*in(1,0) + tmp[2]*in(2,0) + tmp[5]*in(3,0);
-	m4(1,0) -= tmp[0]*in(1,0) + tmp[3]*in(2,0) + tmp[4]*in(3,0);
-	m4(1,1) =  tmp[0]*in(0,0) + tmp[7]*in(2,0) + tmp[8]*in(3,0);
-	m4(1,1) -= tmp[1]*in(0,0) + tmp[6]*in(2,0) + tmp[9]*in(3,0);
-	m4(1,2) =  tmp[3]*in(0,0) + tmp[6]*in(1,0) + tmp[11]*in(3,0);
-	m4(1,2) -= tmp[2]*in(0,0) + tmp[7]*in(1,0) + tmp[10]*in(3,0);
-	m4(1,3) =  tmp[4]*in(0,0) + tmp[9]*in(1,0) + tmp[10]*in(2,0);
-	m4(1,3) -= tmp[5]*in(0,0) + tmp[8]*in(1,0) + tmp[11]*in(2,0);
-
-
-	tmp[0] = in(2,0)*in(3,1);
-	tmp[1] = in(3,0)*in(2,1);
-	tmp[2] = in(1,0)*in(3,1);
-	tmp[3] = in(3,0)*in(1,1);
-	tmp[4] = in(1,0)*in(2,1);
-	tmp[5] = in(2,0)*in(1,1);
-	tmp[6] = in(0,0)*in(3,1);
-	tmp[7] = in(3,0)*in(0,1);
-	tmp[8] = in(0,0)*in(2,1);
-	tmp[9] = in(2,0)*in(0,1);
-	tmp[10] = in(0,0)*in(1,1);
-	tmp[11] = in(1,0)*in(0,1);
-
-	m4(2,0) = tmp[0]*in(1,3) + tmp[3]*in(2,3) + tmp[4]*in(3,3);
-	m4(2,0)-= tmp[1]*in(1,3) + tmp[2]*in(2,3) + tmp[5]*in(3,3);
-	m4(2,1) = tmp[1]*in(0,3) + tmp[6]*in(2,3) + tmp[9]*in(3,3);
-	m4(2,1)-= tmp[0]*in(0,3) + tmp[7]*in(2,3) + tmp[8]*in(3,3);
-	m4(2,2) = tmp[2]*in(0,3) + tmp[7]*in(1,3) + tmp[10]*in(3,3);
-	m4(2,2)-= tmp[3]*in(0,3) + tmp[6]*in(1,3) + tmp[11]*in(3,3);
-	m4(2,3) = tmp[5]*in(0,3) + tmp[8]*in(1,3) + tmp[11]*in(2,3);
-	m4(2,3)-= tmp[4]*in(0,3) + tmp[9]*in(1,3) + tmp[10]*in(2,3);
-	m4(3,0) = tmp[2]*in(2,2) + tmp[5]*in(3,2) + tmp[1]*in(1,2);
-	m4(3,0)-= tmp[4]*in(3,2) + tmp[0]*in(1,2) + tmp[3]*in(2,2);
-	m4(3,1) = tmp[8]*in(3,2) + tmp[0]*in(0,2) + tmp[7]*in(2,2);
-	m4(3,1)-= tmp[6]*in(2,2) + tmp[9]*in(3,2) + tmp[1]*in(0,2);
-	m4(3,2) = tmp[6]*in(1,2) + tmp[11]*in(3,2) + tmp[3]*in(0,2);
-	m4(3,2)-= tmp[10]*in(3,2) + tmp[2]*in(0,2) + tmp[7]*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);
-
-	det = ME(0,0)*m4(0,0)+ME(1,0)*m4(0,1)+ME(2,0)*m4(0,2)+ME(3,0)*m4(0,3);
-
-	DEBUG_ERR( isZero( det ) ); // Cannot invert, det == 0
+	tmp[0] = in(2, 2) * in(3, 3);
+	tmp[1] = in(3, 2) * in(2, 3);
+	tmp[2] = in(1, 2) * in(3, 3);
+	tmp[3] = in(3, 2) * in(1, 3);
+	tmp[4] = in(1, 2) * in(2, 3);
+	tmp[5] = in(2, 2) * in(1, 3);
+	tmp[6] = in(0, 2) * in(3, 3);
+	tmp[7] = in(3, 2) * in(0, 3);
+	tmp[8] = in(0, 2) * in(2, 3);
+	tmp[9] = in(2, 2) * in(0, 3);
+	tmp[10] = in(0, 2) * in(1, 3);
+	tmp[11] = in(1, 2) * in(0, 3);
+
+	m4(0, 0) =  tmp[0]*in(1, 1) + tmp[3]*in(2, 1) + tmp[4]*in(3, 1);
+	m4(0, 0) -= tmp[1]*in(1, 1) + tmp[2]*in(2, 1) + tmp[5]*in(3, 1);
+	m4(0, 1) =  tmp[1]*in(0, 1) + tmp[6]*in(2, 1) + tmp[9]*in(3, 1);
+	m4(0, 1) -= tmp[0]*in(0, 1) + tmp[7]*in(2, 1) + tmp[8]*in(3, 1);
+	m4(0, 2) =  tmp[2]*in(0, 1) + tmp[7]*in(1, 1) + tmp[10]*in(3, 1);
+	m4(0, 2) -= tmp[3]*in(0, 1) + tmp[6]*in(1, 1) + tmp[11]*in(3, 1);
+	m4(0, 3) =  tmp[5]*in(0, 1) + tmp[8]*in(1, 1) + tmp[11]*in(2, 1);
+	m4(0, 3) -= tmp[4]*in(0, 1) + tmp[9]*in(1, 1) + tmp[10]*in(2, 1);
+	m4(1, 0) =  tmp[1]*in(1, 0) + tmp[2]*in(2, 0) + tmp[5]*in(3, 0);
+	m4(1, 0) -= tmp[0]*in(1, 0) + tmp[3]*in(2, 0) + tmp[4]*in(3, 0);
+	m4(1, 1) =  tmp[0]*in(0, 0) + tmp[7]*in(2, 0) + tmp[8]*in(3, 0);
+	m4(1, 1) -= tmp[1]*in(0, 0) + tmp[6]*in(2, 0) + tmp[9]*in(3, 0);
+	m4(1, 2) =  tmp[3]*in(0, 0) + tmp[6]*in(1, 0) + tmp[11]*in(3, 0);
+	m4(1, 2) -= tmp[2]*in(0, 0) + tmp[7]*in(1, 0) + tmp[10]*in(3, 0);
+	m4(1, 3) =  tmp[4]*in(0, 0) + tmp[9]*in(1, 0) + tmp[10]*in(2, 0);
+	m4(1, 3) -= tmp[5]*in(0, 0) + tmp[8]*in(1, 0) + tmp[11]*in(2, 0);
+
+
+	tmp[0] = in(2, 0)*in(3, 1);
+	tmp[1] = in(3, 0)*in(2, 1);
+	tmp[2] = in(1, 0)*in(3, 1);
+	tmp[3] = in(3, 0)*in(1, 1);
+	tmp[4] = in(1, 0)*in(2, 1);
+	tmp[5] = in(2, 0)*in(1, 1);
+	tmp[6] = in(0, 0)*in(3, 1);
+	tmp[7] = in(3, 0)*in(0, 1);
+	tmp[8] = in(0, 0)*in(2, 1);
+	tmp[9] = in(2, 0)*in(0, 1);
+	tmp[10] = in(0, 0)*in(1, 1);
+	tmp[11] = in(1, 0)*in(0, 1);
+
+	m4(2, 0) = tmp[0]*in(1, 3) + tmp[3]*in(2, 3) + tmp[4]*in(3, 3);
+	m4(2, 0)-= tmp[1]*in(1, 3) + tmp[2]*in(2, 3) + tmp[5]*in(3, 3);
+	m4(2, 1) = tmp[1]*in(0, 3) + tmp[6]*in(2, 3) + tmp[9]*in(3, 3);
+	m4(2, 1)-= tmp[0]*in(0, 3) + tmp[7]*in(2, 3) + tmp[8]*in(3, 3);
+	m4(2, 2) = tmp[2]*in(0, 3) + tmp[7]*in(1, 3) + tmp[10]*in(3, 3);
+	m4(2, 2)-= tmp[3]*in(0, 3) + tmp[6]*in(1, 3) + tmp[11]*in(3, 3);
+	m4(2, 3) = tmp[5]*in(0, 3) + tmp[8]*in(1, 3) + tmp[11]*in(2, 3);
+	m4(2, 3)-= tmp[4]*in(0, 3) + tmp[9]*in(1, 3) + tmp[10]*in(2, 3);
+	m4(3, 0) = tmp[2]*in(2, 2) + tmp[5]*in(3, 2) + tmp[1]*in(1, 2);
+	m4(3, 0)-= tmp[4]*in(3, 2) + tmp[0]*in(1, 2) + tmp[3]*in(2, 2);
+	m4(3, 1) = tmp[8]*in(3, 2) + tmp[0]*in(0, 2) + tmp[7]*in(2, 2);
+	m4(3, 1)-= tmp[6]*in(2, 2) + tmp[9]*in(3, 2) + tmp[1]*in(0, 2);
+	m4(3, 2) = tmp[6]*in(1, 2) + tmp[11]*in(3, 2) + tmp[3]*in(0, 2);
+	m4(3, 2)-= tmp[10]*in(3, 2) + tmp[2]*in(0, 2) + tmp[7]*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);
+
+	det = ME(0, 0)*m4(0, 0)+ME(1, 0)*m4(0, 1)+ME(2, 0)*m4(0, 2)+ME(3, 0)*m4(0, 3);
+
+	DEBUG_ERR(isZero(det)); // Cannot invert, det == 0
 	det = 1/det;
 	m4 *= det;
 	return m4;
@@ -648,12 +647,12 @@ inline Mat4 Mat4::getInverseTransformation() const
 {
 	Mat3 invertedRot = (getRotationPart()).getTransposed();
 	Vec3 invertedTsl = getTranslationPart();
-	invertedTsl = -( invertedRot * invertedTsl );
-	return Mat4( invertedTsl, invertedRot );
+	invertedTsl = -(invertedRot * invertedTsl);
+	return Mat4(invertedTsl, invertedRot);
 }
 
 // lerp
-inline Mat4 Mat4::lerp( const Mat4& b, float t ) const
+inline Mat4 Mat4::lerp(const Mat4& b, float t) const
 {
 	return (ME*(1.0-t))+(b*t);
 }
@@ -665,17 +664,17 @@ inline void Mat4::setIdentity()
 }
 
 // combineTransformations
-inline Mat4 Mat4::combineTransformations( const Mat4& m0, const Mat4& m1 )
+inline Mat4 Mat4::combineTransformations(const Mat4& m0, const Mat4& m1)
 {
 	/*
 	 * The clean code is:
 	 * Mat3 rot = m0.getRotationPart() * m1.getRotationPart();  // combine the rotations
-	 * Vec3 tra = (m1.getTranslationPart()).Transformed( m0.getTranslationPart(), m0.getRotationPart(), 1.0 );
-	 * return Mat4( tra, rot );
+	 * Vec3 tra = (m1.getTranslationPart()).Transformed(m0.getTranslationPart(), m0.getRotationPart(), 1.0);
+	 * return Mat4(tra, rot);
 	 * and the optimized:
 	 */
-	DEBUG_ERR( !isZero( m0(3,0)+m0(3,1)+m0(3,2)+m0(3,3)-1.0 ) ||
-	           !isZero( m1(3,0)+m1(3,1)+m1(3,2)+m1(3,3)-1.0 ) ); // one of the 2 mat4 doesnt represent transformation
+	DEBUG_ERR(!isZero(m0(3, 0)+m0(3, 1)+m0(3, 2)+m0(3, 3)-1.0) ||
+	           !isZero(m1(3, 0)+m1(3, 1)+m1(3, 2)+m1(3, 3)-1.0)); // one of the 2 mat4 doesnt represent transformation
 
 	Mat4 m4;
 
@@ -693,8 +692,8 @@ inline Mat4 Mat4::combineTransformations( const Mat4& m0, const Mat4& m1 )
 	m4(1, 3) = m0(1, 0)*m1(0, 3) + m0(1, 1)*m1(1, 3) + m0(1, 2)*m1(2, 3) + m0(1, 3);
 	m4(2, 3) = m0(2, 0)*m1(0, 3) + m0(2, 1)*m1(1, 3) + m0(2, 2)*m1(2, 3) + m0(2, 3);
 
-	m4(3,0) = m4(3,1) = m4(3,2) = 0.0;
-	m4(3,3) = 1.0;
+	m4(3, 0) = m4(3, 1) = m4(3, 2) = 0.0;
+	m4(3, 3) = 1.0;
 
 	return m4;
 }

+ 12 - 12
src/Math/MathFuncs.h

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

+ 49 - 26
src/Math/MathFuncs.inl.h

@@ -8,25 +8,25 @@ namespace M {
 inline void mathSanityChecks()
 {
 	const int fs = sizeof(float); // float size
-	if( sizeof(Vec2)!=fs*2 || sizeof(Vec3)!=fs*3 || sizeof(Vec4)!=fs*4 || sizeof(Quat)!=fs*4 ||
-	    sizeof(Euler)!=fs*3 || sizeof(Mat3)!=fs*9 || sizeof(Mat4)!=fs*16 )
+	if(sizeof(Vec2)!=fs*2 || sizeof(Vec3)!=fs*3 || sizeof(Vec4)!=fs*4 || sizeof(Quat)!=fs*4 ||
+	   sizeof(Euler)!=fs*3 || sizeof(Mat3)!=fs*9 || sizeof(Mat4)!=fs*16)
 	{
-		FATAL( "Your compiler does class alignment" );
+		FATAL("Your compiler does class alignment");
 	}
 }
 
 
 // 1/sqrt(f)
-inline float invSqrt( float f )
+inline float invSqrt(float f)
 {
-	#if defined( PLATFORM_WIN )
+	#if defined(PLATFORM_WIN)
 		float fhalf = 0.5*f;
 		int i = *(int*)&f;
 		i = 0x5F3759DF - (i>>1);
 		f = *(float*)&i;
 		f *= 1.5 - fhalf*f*f;
 		return f;
-	#elif defined( PLATFORM_LINUX )
+	#elif defined(PLATFORM_LINUX)
 		float fhalf = 0.5*f;
 		asm
 		(
@@ -51,17 +51,17 @@ inline float invSqrt( float f )
 /**
  * Used in sinCos
  */
-inline static float polynomialSinQuadrant( float a )
+inline static float polynomialSinQuadrant(float a)
 {
-	return a * ( 1.0 + a * a * (-0.16666 + a * a * (0.0083143 - a * a * 0.00018542)));
+	return a * (1.0 + a * a * (-0.16666 + a * a * (0.0083143 - a * a * 0.00018542)));
 }
 
 
 // Sine and Cosine
-inline void sinCos( float a, float& sina, float& cosa )
+inline void sinCos(float a, float& sina, float& cosa)
 {
 	bool negative = false;
-	if( a < 0.0 )
+	if(a < 0.0)
 	{
 		a = -a;
 		negative = true;
@@ -77,7 +77,7 @@ inline void sinCos( float a, float& sina, float& cosa )
 
 	float floatAMinusHalfPi = (floatA - k_rational_half_pi) - kRemainderHalfPi;
 
-	switch( intA & 3 )
+	switch(intA & 3)
 	{
 		case 0: // 0 - Pi/2
 			sina = polynomialSinQuadrant(floatA);
@@ -97,40 +97,63 @@ inline void sinCos( float a, float& sina, float& cosa )
 			break;
 	};
 
-	if( negative )
+	if(negative)
 		sina = -sina;
 
-	/*DEBUG_ERR( !isZero( M::sin(a) - sina ) );
-	DEBUG_ERR( !isZero( M::cos(a) - cosa ) );*/
+	/*DEBUG_ERR(!isZero(M::sin(a) - sina));
+	DEBUG_ERR(!isZero(M::cos(a) - cosa));*/
 }
 
 
 //======================================================================================================================
 // Small funcs                                                                                                         =
 //======================================================================================================================
-inline float sqrt( float f ) { return 1/invSqrt(f); }
-inline float toRad( float degrees ) { return degrees*(PI/180.0); }
-inline float toDegrees( float rad ) { return rad*(180.0/PI); }
-inline float sin( float rad ) { return ::sin(rad); }
-inline float cos( float rad ) { return ::cos(rad); }
-inline bool  isZero( float f ) { return ( fabs(f) < EPSILON ); }
+inline float sqrt(float f)
+{
+	return 1/invSqrt(f);
+}
+
+inline float toRad(float degrees)
+{
+	return degrees*(PI/180.0);
+}
+
+inline float toDegrees(float rad)
+{
+	return rad*(180.0/PI);
+}
+
+inline float sin(float rad)
+{
+	return ::sin(rad);
+}
+
+inline float cos(float rad)
+{
+	return ::cos(rad);
+}
+
+inline bool  isZero(float f)
+{
+	return (fabs(f) < EPSILON);
+}
 
 
 //  combineTransformations
 //  mat4(t0,r0,s0)*mat4(t1,r1,s1) == mat4(tf,rf,sf)
-inline void combineTransformations( const Vec3& t0, const Mat3& r0, float s0,
-                                    const Vec3& t1, const Mat3& r1, float s1,
-                                    Vec3& tf, Mat3& rf, float& sf )
+inline void combineTransformations(const Vec3& t0, const Mat3& r0, float s0,
+                                   const Vec3& t1, const Mat3& r1, float s1,
+                                   Vec3& tf, Mat3& rf, float& sf)
 {
-	tf = t1.getTransformed( t0, r0, s0 );
+	tf = t1.getTransformed(t0, r0, s0);
 	rf = r0 * r1;
 	sf = s0 * s1;
 }
 
 //  combineTransformations as the above but without scale
-inline void combineTransformations( const Vec3& t0, const Mat3& r0, const Vec3& t1, const Mat3& r1, Vec3& tf, Mat3& rf)
+inline void combineTransformations(const Vec3& t0, const Mat3& r0, const Vec3& t1, const Mat3& r1, Vec3& tf, Mat3& rf)
 {
-	tf = t1.getTransformed( t0, r0 );
+	tf = t1.getTransformed(t0, r0);
 	rf = r0 * r1;
 }
 

+ 18 - 18
src/Math/Quat.h

@@ -16,23 +16,23 @@ class Quat
 		float x, y, z, w;
 		// constructors & destructors
 		explicit Quat();
-		explicit Quat( float f );
-		explicit Quat( float x, float y, float z, float w );
-		explicit Quat( const Vec2& v2, float z, float w );
-		explicit Quat( const Vec3& v3, float w );
-		explicit Quat( const Vec4& v4 );
-		         Quat( const Quat& b );
-		explicit Quat( const Mat3& m3 );
-		explicit Quat( const Euler& eu );
-		explicit Quat( const Axisang& axisang );
+		explicit Quat(float f);
+		explicit Quat(float x, float y, float z, float w);
+		explicit Quat(const Vec2& v2, float z, float w);
+		explicit Quat(const Vec3& v3, float w);
+		explicit Quat(const Vec4& v4);
+		         Quat(const Quat& b);
+		explicit Quat(const Mat3& m3);
+		explicit Quat(const Euler& eu);
+		explicit Quat(const Axisang& axisang);
 		// ops with same
-		Quat  operator * ( const Quat& b ) const; ///< 16 muls, 12 adds
-		Quat& operator *=( const Quat& b );
+		Quat  operator * (const Quat& b) const; ///< 16 muls, 12 adds
+		Quat& operator *=(const Quat& b);
 		// comparision
-		bool operator ==( const Quat& b ) const;
-		bool operator !=( const Quat& b ) const;
+		bool operator ==(const Quat& b) const;
+		bool operator !=(const Quat& b) const;
 		// other
-		void  setFrom2Vec3( const Vec3& v0, const Vec3& v1 ); ///< calculates a quat from v0 to v1
+		void  setFrom2Vec3(const Vec3& v0, const Vec3& v1); ///< calculates a quat from v0 to v1
 		float getLength() const;
 		Quat  getInverted() const;
 		void  invert();
@@ -41,10 +41,10 @@ class Quat
 		void  normalize();
 		Quat  getNormalized() const;
 		void  print() const;
-		float dot( const Quat& b ) const;
-		Quat  slerp( const Quat& q1, float t ) const; ///< returns slerp( this, q1, t )
-		Quat  getRotated( const Quat& b ) const; ///< The same as Quat * Quat
-		void  rotate( const Quat& b ); ///< @see getRotated
+		float dot(const Quat& b) const;
+		Quat  slerp(const Quat& q1, float t) const; ///< returns slerp(this, q1, t)
+		Quat  getRotated(const Quat& b) const; ///< The same as Quat * Quat
+		void  rotate(const Quat& b); ///< @see getRotated
 		void  setIdentity();
 		static const Quat& getIdentity();
 };

+ 65 - 65
src/Math/Quat.inl.h

@@ -12,87 +12,87 @@ inline Quat::Quat()
 {}
 
 // constructor [float]
-inline Quat::Quat( float f )
+inline Quat::Quat(float f)
 	: x(f), y(f), z(f), w(f)
 {}
 
 // constructor [float, float, float, float]
-inline Quat::Quat( float x_, float y_, float z_, float w_ )
+inline Quat::Quat(float x_, float y_, float z_, float w_)
 	: x(x_), y(y_), z(z_), w(w_)
 {}
 
 // constructor [vec2, float, float]
-inline Quat::Quat( const Vec2& v2, float z_, float w_ )
+inline Quat::Quat(const Vec2& v2, float z_, float w_)
 	: x(v2.x), y(v2.y), z(z_), w(w_)
 {}
 
 // constructor [vec3, float]
-inline Quat::Quat( const Vec3& v3, float w_ )
+inline Quat::Quat(const Vec3& v3, float w_)
 	: x(v3.x), y(v3.y), z(v3.z), w(w_)
 {}
 
 // constructor [vec4]
-inline Quat::Quat( const Vec4& v4 )
+inline Quat::Quat(const Vec4& v4)
 	: x(v4.x), y(v4.y), z(v4.z), w(v4.w)
 {}
 
 // constructor [quat]
-inline Quat::Quat( const Quat& b )
+inline Quat::Quat(const Quat& b)
 	: x(b.x), y(b.y), z(b.z), w(b.w)
 {}
 
 // constructor [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;
-	if( trace > EPSILON )
+	if(trace > EPSILON)
 	{
 		float s = 0.5 * invSqrt(trace);
 		w = 0.25 / s;
-		x = ( m3(2, 1) - m3(1, 2) ) * s;
-		y = ( m3(0, 2) - m3(2, 0) ) * s;
-		z = ( m3(1, 0) - m3(0, 1) ) * s;
+		x = (m3(2, 1) - m3(1, 2)) * s;
+		y = (m3(0, 2) - m3(2, 0)) * s;
+		z = (m3(1, 0) - m3(0, 1)) * s;
 	}
 	else
 	{
-		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 * invSqrt( 1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2) );
-			w = (m3(1, 2) - m3(2, 1) ) * s;
+			float s = 0.5 * invSqrt(1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2));
+			w = (m3(1, 2) - m3(2, 1)) * s;
 			x = 0.25 / s;
-			y = (m3(0, 1) + m3(1, 0) ) * s;
-			z = (m3(0, 2) + m3(2, 0) ) * s;
+			y = (m3(0, 1) + m3(1, 0)) * s;
+			z = (m3(0, 2) + m3(2, 0)) * s;
 		}
-		else if( m3(1, 1) > m3(2, 2) )
+		else if(m3(1, 1) > m3(2, 2))
 		{
-			float s = 0.5 * invSqrt( 1.0 + m3(1, 1) - m3(0, 0) - m3(2, 2) );
-			w = (m3(0, 2) - m3(2, 0) ) * s;
-			x = (m3(0, 1) + m3(1, 0) ) * s;
+			float s = 0.5 * invSqrt(1.0 + m3(1, 1) - m3(0, 0) - m3(2, 2));
+			w = (m3(0, 2) - m3(2, 0)) * s;
+			x = (m3(0, 1) + m3(1, 0)) * s;
 			y = 0.25 / s;
-			z = (m3(1, 2) + m3(2, 1) ) * s;
+			z = (m3(1, 2) + m3(2, 1)) * s;
 		}
 		else
 		{
-			float s = 0.5 * invSqrt( 1.0 + m3(2, 2) - m3(0, 0) - m3(1, 1) );
-			w = (m3(0, 1) - m3(1, 0) ) * s;
-			x = (m3(0, 2) + m3(2, 0) ) * s;
-			y = (m3(1, 2) + m3(2, 1) ) * s;
+			float s = 0.5 * invSqrt(1.0 + m3(2, 2) - m3(0, 0) - m3(1, 1));
+			w = (m3(0, 1) - m3(1, 0)) * s;
+			x = (m3(0, 2) + m3(2, 0)) * s;
+			y = (m3(1, 2) + m3(2, 1)) * s;
 			z = 0.25 / s;
 		}
 	}
 }
 
 // constructor [euler]
-inline Quat::Quat( const Euler& eu )
+inline Quat::Quat(const Euler& eu)
 {
 	float cx, sx;
-	sinCos( eu.heading()*0.5, sx, cx );
+	sinCos(eu.heading()*0.5, sx, cx);
 
 	float cy, sy;
-	sinCos( eu.attitude()*0.5, sy, cy );
+	sinCos(eu.attitude()*0.5, sy, cy);
 
 	float cz, sz;
-	sinCos( eu.bank()*0.5, sz, cz );
+	sinCos(eu.bank()*0.5, sz, cz);
 
 	float cxcy = cx*cy;
 	float sxsy = sx*sy;
@@ -103,10 +103,10 @@ inline Quat::Quat( const Euler& eu )
 }
 
 // constructor [euler]
-inline Quat::Quat( const Axisang& axisang )
+inline Quat::Quat(const Axisang& axisang)
 {
 	float lengthsq = axisang.axis.getLengthSquared();
-	if( isZero( lengthsq ) )
+	if(isZero(lengthsq))
 	{
 		ME = getIdentity();
 		return;
@@ -115,7 +115,7 @@ inline Quat::Quat( const Axisang& axisang )
 	float rad = axisang.ang * 0.5;
 
 	float sintheta, costheta;
-	sinCos( rad, sintheta, costheta );
+	sinCos(rad, sintheta, costheta);
 
 	float scalefactor = sintheta * invSqrt(lengthsq);
 
@@ -126,7 +126,7 @@ inline Quat::Quat( const Axisang& axisang )
 }
 
 // *
-inline Quat Quat::operator *( const Quat& b ) const
+inline Quat Quat::operator *(const Quat& b) const
 {
 	return Quat(
 		 x * b.w + y * b.z - z * b.y + w * b.x,
@@ -137,22 +137,22 @@ inline Quat Quat::operator *( const Quat& b ) const
 }
 
 // *=
-inline Quat& Quat::operator *=( const Quat& b )
+inline Quat& Quat::operator *=(const Quat& b)
 {
 	ME = ME * b;
 	return ME;
 }
 
 // ==
-inline bool Quat::operator ==( const Quat& b ) const
+inline bool Quat::operator ==(const Quat& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? true : false;
+	return (isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w)) ? true : false;
 }
 
 // !=
-inline bool Quat::operator !=( const Quat& b ) const
+inline bool Quat::operator !=(const Quat& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? false : true;
+	return (isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w)) ? false : true;
 }
 
 // conjugate
@@ -166,13 +166,13 @@ inline void Quat::conjugate()
 // getConjugated
 inline Quat Quat::getConjugated() const
 {
-	return Quat( -x, -y, -z, w );
+	return Quat(-x, -y, -z, w);
 }
 
 // Normalized
 inline Quat Quat::getNormalized() const
 {
-	return Quat( Vec4(ME).getNormalized() );
+	return Quat(Vec4(ME).getNormalized());
 }
 
 // normalize
@@ -184,7 +184,7 @@ inline void Quat::normalize()
 // getLength
 inline float Quat::getLength() const
 {
-	return M::sqrt( w*w + x*x + y*y + z*z );
+	return M::sqrt(w*w + x*x + y*y + z*z);
 }
 
 
@@ -193,10 +193,10 @@ inline Quat Quat::getInverted() const
 {
 	float norm = w*w + x*x + y*y + z*z;
 
-	DEBUG_ERR( isZero(norm) ); // Norm is zero
+	DEBUG_ERR(isZero(norm)); // Norm is zero
 
 	float normi = 1.0 / norm;
-	return Quat( -normi*x, -normi*y, -normi*z, normi*w );
+	return Quat(-normi*x, -normi*y, -normi*z, normi*w);
 }
 
 // invert
@@ -212,63 +212,63 @@ inline void Quat::print() const
 }
 
 // CalcFromVecVec
-inline void Quat::setFrom2Vec3( const Vec3& from, const Vec3& to )
+inline void Quat::setFrom2Vec3(const Vec3& from, const Vec3& to)
 {
-	Vec3 axis( from.cross(to) );
-	ME = Quat( axis.x, axis.y, axis.z, from.dot(to) );
+	Vec3 axis(from.cross(to));
+	ME = Quat(axis.x, axis.y, axis.z, from.dot(to));
 	normalize();
 	w += 1.0;
 
-	if( w <= EPSILON )
+	if(w <= EPSILON)
 	{
-		if( from.z*from.z > from.x*from.x )
-			ME = Quat( 0.0, from.z, -from.y, 0.0 );
+		if(from.z*from.z > from.x*from.x)
+			ME = Quat(0.0, from.z, -from.y, 0.0);
 		else
-			ME = Quat( from.y, -from.x, 0.0, 0.0 );
+			ME = Quat(from.y, -from.x, 0.0, 0.0);
 	}
 	normalize();
 }
 
 // getRotated
-inline Quat Quat::getRotated( const Quat& b ) const
+inline Quat Quat::getRotated(const Quat& b) const
 {
 	return ME * b;
 }
 
 // rotate
-inline void Quat::rotate( const Quat& b )
+inline void Quat::rotate(const Quat& b)
 {
-	ME = getRotated( b );
+	ME = getRotated(b);
 }
 
 // dot
-inline float Quat::dot( const Quat& b ) const
+inline float Quat::dot(const Quat& b) const
 {
 	return w*b.w + x*b.x + y*b.y + z*b.z;
 }
 
 // SLERP
-inline Quat Quat::slerp( const Quat& q1_, float t ) const
+inline Quat Quat::slerp(const Quat& q1_, float t) const
 {
 	const Quat& q0 = ME;
-	Quat q1( q1_ );
+	Quat q1(q1_);
 	float cosHalfTheta = q0.w*q1.w + q0.x*q1.x + q0.y*q1.y + q0.z*q1.z;
-	if( cosHalfTheta < 0.0 )
+	if(cosHalfTheta < 0.0)
 	{
-		q1 = Quat( -Vec4(q1) ); // quat changes
+		q1 = Quat(-Vec4(q1)); // quat changes
 		cosHalfTheta = -cosHalfTheta;
 	}
-	if( fabs(cosHalfTheta) >= 1.0f )
+	if(fabs(cosHalfTheta) >= 1.0f)
 	{
-		return Quat( q0 );
+		return Quat(q0);
 	}
 
-	float halfTheta = acos( cosHalfTheta );
+	float halfTheta = acos(cosHalfTheta);
 	float sinHalfTheta = M::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;
@@ -277,7 +277,7 @@ inline Quat Quat::slerp( const Quat& q1_, float t ) const
 	tmp1 = Vec4(q1)*ratio_b;
 	sum = tmp + tmp1;
 	sum.normalize();
-	return Quat( sum );
+	return Quat(sum);
 }
 
 // setIdentity
@@ -290,7 +290,7 @@ inline void Quat::setIdentity()
 // getIdentity
 inline const Quat::Quat& getIdentity()
 {
-	static Quat ident( 0.0, 0.0, 0.0, 1.0 );
+	static Quat ident(0.0, 0.0, 0.0, 1.0);
 	return ident;
 }
 

+ 7 - 7
src/Math/Transform.h

@@ -11,20 +11,20 @@ namespace M {
 /// For transformations
 class Transform
 {
-	PROPERTY_RW( Mat3, rotation, setRotation, getRotation ) ///< @ref PROPERTY_RW : The rotation
-	PROPERTY_RW( Vec3, origin, setOrigin, getOrigin ) ///< @ref PROPERTY_RW : The translation
-	PROPERTY_RW( float, scale, setScale, getScale ) ///< @ref PROPERTY_RW : The uniform scaling
+	PROPERTY_RW(Mat3, rotation, setRotation, getRotation) ///< @ref PROPERTY_RW : The rotation
+	PROPERTY_RW(Vec3, origin, setOrigin, getOrigin) ///< @ref PROPERTY_RW : The translation
+	PROPERTY_RW(float, scale, setScale, getScale) ///< @ref PROPERTY_RW : The uniform scaling
 
 	public:
 		// constructors
 		explicit Transform();
-		         Transform( const Transform& b );
-		explicit Transform( const Mat4& m4 );
-		explicit Transform( const Vec3& origin, const Mat3& rotation_, float scale_ );
+		         Transform(const Transform& b);
+		explicit Transform(const Mat4& m4);
+		explicit Transform(const Vec3& origin, const Mat3& rotation_, float scale_);
 		// funcs
 		void setIdentity();
 		static const Transform& getIdentity();
-		static Transform combineTransformations( const Transform& a, const Transform& b ); ///< @see M::combineTransformations
+		static Transform combineTransformations(const Transform& a, const Transform& b); ///< @see M::combineTransformations
 };
 
 

+ 6 - 6
src/Math/Transform.inl.h

@@ -12,12 +12,12 @@ inline Transform::Transform()
 {}
 
 // constructor [Transform]
-inline Transform::Transform( const Transform& b ):
+inline Transform::Transform(const Transform& b):
 	rotation(b.rotation), origin(b.origin)
 {}
 
 // constructor [Mat4]
-inline Transform::Transform( const Mat4& m4 )
+inline Transform::Transform(const Mat4& m4)
 {
 	rotation = m4.getRotationPart();
 	origin = m4.getTranslationPart();
@@ -25,7 +25,7 @@ inline Transform::Transform( const Mat4& m4 )
 }
 
 // constructor [Vec3, Quat, float]
-inline Transform::Transform( const Vec3& origin, const Mat3& rotation_, float scale_ ):
+inline Transform::Transform(const Vec3& origin, const Mat3& rotation_, float scale_):
 	rotation(rotation_), origin(origin), scale(scale_)
 {}
 
@@ -38,15 +38,15 @@ inline void Transform::setIdentity()
 // getIdentity
 inline const Transform& Transform::getIdentity()
 {
-	static Transform ident( Vec3(0.0), Mat3::getIdentity(), 1.0 );
+	static Transform ident(Vec3(0.0), Mat3::getIdentity(), 1.0);
 	return ident;
 }
 
 // combineTransformations
-inline Transform Transform::combineTransformations( const Transform& a, const Transform& b )
+inline Transform Transform::combineTransformations(const Transform& a, const Transform& b)
 {
 	Transform out;
-	M::combineTransformations( a.origin, a.rotation, a.scale, b.origin, b.rotation, b.scale, out.origin, out.rotation, out.scale );
+	M::combineTransformations(a.origin, a.rotation, a.scale, b.origin, b.rotation, b.scale, out.origin, out.rotation, out.scale);
 	return out;
 }
 

+ 30 - 30
src/Math/Vec2.h

@@ -17,37 +17,37 @@ class Vec2
 		static const Vec2 zero;
 		static const Vec2 one;
 		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
+		float& operator [](uint i);
+		float  operator [](uint i) const;
 		// constructors & distructors
 		explicit Vec2();
-		explicit Vec2( float f );
-		explicit Vec2( float x, float y );
-		         Vec2( const Vec2& b );
-		explicit Vec2( const Vec3& v3 );
-		explicit Vec2( const Vec4& v4 );
+		explicit Vec2(float f);
+		explicit Vec2(float x, float y);
+		         Vec2(const Vec2& b);
+		explicit Vec2(const Vec3& v3);
+		explicit Vec2(const Vec4& v4);
 		// ops with same type
-		Vec2  operator + ( const Vec2& b ) const;
-		Vec2& operator +=( const Vec2& b );
-		Vec2  operator - ( const Vec2& b ) const;
-		Vec2& operator -=( const Vec2& b );
-		Vec2  operator * ( const Vec2& b ) const;
-		Vec2& operator *=( const Vec2& b );
-		Vec2  operator / ( const Vec2& b ) const;
-		Vec2& operator /=( const Vec2& b );
+		Vec2  operator + (const Vec2& b) const;
+		Vec2& operator +=(const Vec2& b);
+		Vec2  operator - (const Vec2& b) const;
+		Vec2& operator -=(const Vec2& b);
+		Vec2  operator * (const Vec2& b) const;
+		Vec2& operator *=(const Vec2& b);
+		Vec2  operator / (const Vec2& b) const;
+		Vec2& operator /=(const Vec2& b);
 		Vec2  operator - () const;
 		// ops with float
-		Vec2  operator + ( float f ) const;
-		Vec2& operator +=( float f );
-		Vec2  operator - ( float f ) const;
-		Vec2& operator -=( float f );
-		Vec2  operator * ( float f ) const;
-		Vec2& operator *=( float f );
-		Vec2  operator / ( float f ) const;
-		Vec2& operator /=( float f );
+		Vec2  operator + (float f) const;
+		Vec2& operator +=(float f);
+		Vec2  operator - (float f) const;
+		Vec2& operator -=(float f);
+		Vec2  operator * (float f) const;
+		Vec2& operator *=(float f);
+		Vec2  operator / (float f) const;
+		Vec2& operator /=(float f);
 		// comparision
-		bool operator ==( const Vec2& b ) const;
-		bool operator !=( const Vec2& b ) const;
+		bool operator ==(const Vec2& b) const;
+		bool operator !=(const Vec2& b) const;
 		// other
 		static Vec2 getZero();
 		static Vec2 getOne();
@@ -55,16 +55,16 @@ class Vec2
 		void   setZero();
 		void   normalize();
 		Vec2   getNormalized() const;
-		float  dot( const Vec2& b ) const;
+		float  dot(const Vec2& b) const;
 		void   print() const;
 };
 
 
 // other operators
-extern Vec2 operator +( float f, const Vec2& v2 );
-extern Vec2 operator -( float f, const Vec2& v2 );
-extern Vec2 operator *( float f, const Vec2& v2 );
-extern Vec2 operator /( float f, const Vec2& v2 );
+extern Vec2 operator +(float f, const Vec2& v2);
+extern Vec2 operator -(float f, const Vec2& v2);
+extern Vec2 operator *(float f, const Vec2& v2);
+extern Vec2 operator /(float f, const Vec2& v2);
 
 
 } // end namespace

+ 43 - 43
src/Math/Vec2.inl.h

@@ -6,12 +6,12 @@
 namespace M {
 
 // accessors
-inline float& Vec2::operator []( uint i )
+inline float& Vec2::operator [](uint i)
 {
 	return (&x)[i];
 }
 
-inline float Vec2::operator []( uint i ) const
+inline float Vec2::operator [](uint i) const
 {
 	return (&x)[i];
 }
@@ -22,34 +22,34 @@ inline Vec2::Vec2()
 {}
 
 // constructor [float, float]
-inline Vec2::Vec2( float x_, float y_ )
+inline Vec2::Vec2(float x_, float y_)
 	: x(x_), y(y_)
 {}
 
 // constructor [float]
-inline Vec2::Vec2( float f ): x(f), y(f)
+inline Vec2::Vec2(float f): x(f), y(f)
 {}
 
 // constructor [vec2]
-inline Vec2::Vec2( const Vec2& b ): x(b.x), y(b.y)
+inline Vec2::Vec2(const Vec2& b): x(b.x), y(b.y)
 {}
 
 // constructor [vec3]
-inline Vec2::Vec2( const Vec3& v3 ): x(v3.x), y(v3.y)
+inline Vec2::Vec2(const Vec3& v3): x(v3.x), y(v3.y)
 {}
 
 // constructor [vec4]
-inline Vec2::Vec2( const Vec4& v4 ): x(v4.x), y(v4.y)
+inline Vec2::Vec2(const Vec4& v4): x(v4.x), y(v4.y)
 {}
 
 // +
-inline Vec2 Vec2::operator +( const Vec2& b ) const
+inline Vec2 Vec2::operator +(const Vec2& b) const
 {
-	return Vec2( x+b.x, y+b.y );
+	return Vec2(x+b.x, y+b.y);
 }
 
 // +=
-inline Vec2& Vec2::operator +=( const Vec2& b )
+inline Vec2& Vec2::operator +=(const Vec2& b)
 {
 	x += b.x;
 	y += b.y;
@@ -57,13 +57,13 @@ inline Vec2& Vec2::operator +=( const Vec2& b )
 }
 
 // -
-inline Vec2 Vec2::operator -( const Vec2& b ) const
+inline Vec2 Vec2::operator -(const Vec2& b) const
 {
-	return Vec2( x-b.x, y-b.y );
+	return Vec2(x-b.x, y-b.y);
 }
 
 // -=
-inline Vec2& Vec2::operator -=( const Vec2& b )
+inline Vec2& Vec2::operator -=(const Vec2& b)
 {
 	x -= b.x;
 	y -= b.y;
@@ -71,13 +71,13 @@ inline Vec2& Vec2::operator -=( const Vec2& b )
 }
 
 // *
-inline Vec2 Vec2::operator *( const Vec2& b ) const
+inline Vec2 Vec2::operator *(const Vec2& b) const
 {
-	return Vec2( x*b.x, y*b.y );
+	return Vec2(x*b.x, y*b.y);
 }
 
 // *=
-inline Vec2& Vec2::operator *=( const Vec2& b )
+inline Vec2& Vec2::operator *=(const Vec2& b)
 {
 	x *= b.x;
 	y *= b.y;
@@ -85,13 +85,13 @@ inline Vec2& Vec2::operator *=( const Vec2& b )
 }
 
 // /
-inline Vec2 Vec2::operator /( const Vec2& b ) const
+inline Vec2 Vec2::operator /(const Vec2& b) const
 {
-	return Vec2( x/b.x, y/b.y );
+	return Vec2(x/b.x, y/b.y);
 }
 
 // /=
-inline Vec2& Vec2::operator /=( const Vec2& b )
+inline Vec2& Vec2::operator /=(const Vec2& b)
 {
 	x /= b.x;
 	y /= b.y;
@@ -101,92 +101,92 @@ inline Vec2& Vec2::operator /=( const Vec2& b )
 // negative
 inline Vec2 Vec2::operator -() const
 {
-	return Vec2( -x, -y );
+	return Vec2(-x, -y);
 }
 
 // ==
-inline bool Vec2::operator ==( const Vec2& b ) const
+inline bool Vec2::operator ==(const Vec2& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) ) ? true : false;
+	return (isZero(x-b.x) && isZero(y-b.y)) ? true : false;
 }
 
 // !=
-inline bool Vec2::operator !=( const Vec2& b ) const
+inline bool Vec2::operator !=(const Vec2& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) ) ? false : true;
+	return (isZero(x-b.x) && isZero(y-b.y)) ? false : true;
 }
 
 // vec2 + float
-inline Vec2 Vec2::operator +( float f ) const
+inline Vec2 Vec2::operator +(float f) const
 {
 	return ME + Vec2(f);
 }
 
 // float + vec2
-inline Vec2 operator +( float f, const Vec2& v2 )
+inline Vec2 operator +(float f, const Vec2& v2)
 {
 	return v2+f;
 }
 
 // vec2 += float
-inline Vec2& Vec2::operator +=( float f )
+inline Vec2& Vec2::operator +=(float f)
 {
 	ME += Vec2(f);
 	return ME;
 }
 
 // vec2 - float
-inline Vec2 Vec2::operator -( float f ) const
+inline Vec2 Vec2::operator -(float f) const
 {
 	return ME - Vec2(f);
 }
 
 // float - vec2
-inline Vec2 operator -( float f, const Vec2& v2 )
+inline Vec2 operator -(float f, const Vec2& v2)
 {
-	return Vec2( f-v2.x, f-v2.y );
+	return Vec2(f-v2.x, f-v2.y);
 }
 
 // vec2 -= float
-inline Vec2& Vec2::operator -=( float f )
+inline Vec2& Vec2::operator -=(float f)
 {
 	ME -= Vec2(f);
 	return ME;
 }
 
 // vec2 * float
-inline Vec2 Vec2::operator *( float f ) const
+inline Vec2 Vec2::operator *(float f) const
 {
 	return ME * Vec2(f);
 }
 
 // float * vec2
-inline Vec2 operator *( float f, const Vec2& v2 )
+inline Vec2 operator *(float f, const Vec2& v2)
 {
 	return v2*f;
 }
 
 // vec2 *= float
-inline Vec2& Vec2::operator *=( float f )
+inline Vec2& Vec2::operator *=(float f)
 {
 	ME *= Vec2(f);
 	return ME;
 }
 
 // vec2 / float
-inline Vec2 Vec2::operator /( float f ) const
+inline Vec2 Vec2::operator /(float f) const
 {
 	return ME / Vec2(f);
 }
 
 // float / vec2
-inline Vec2 operator /( float f, const Vec2& v2 )
+inline Vec2 operator /(float f, const Vec2& v2)
 {
-	return Vec2( f/v2.x, f/v2.y );
+	return Vec2(f/v2.x, f/v2.y);
 }
 
 // vec2 /= float
-inline Vec2& Vec2::operator /=( float f )
+inline Vec2& Vec2::operator /=(float f)
 {
 	ME /= Vec2(f);
 	return ME;
@@ -195,7 +195,7 @@ inline Vec2& Vec2::operator /=( float f )
 // getLength
 inline float Vec2::getLength() const
 {
-	return M::sqrt( x*x + y*y );
+	return M::sqrt(x*x + y*y);
 }
 
 // set to zero
@@ -207,17 +207,17 @@ inline void Vec2::setZero()
 // normalize
 inline void Vec2::normalize()
 {
-	ME *= invSqrt( x*x + y*y );
+	ME *= invSqrt(x*x + y*y);
 }
 
 // Normalized (return the normalized)
 inline Vec2 Vec2::getNormalized() const
 {
-	return ME * invSqrt( x*x + y*y );
+	return ME * invSqrt(x*x + y*y);
 }
 
 // dot
-inline float Vec2::dot( const Vec2& b ) const
+inline float Vec2::dot(const Vec2& b) const
 {
 	return x*b.x + y*b.y;
 }
@@ -237,7 +237,7 @@ inline Vec2 Vec2::getOne()
 // print
 inline void Vec2::print() const
 {
-	for( int i=0; i<2; i++ )
+	for(int i=0; i<2; i++)
 		cout << fixed << ME[i] << ' ';
 	cout << "\n" << endl;
 }

+ 51 - 51
src/Math/Vec3.h

@@ -15,74 +15,74 @@ class Vec3
 		// data members
 		float x, y, z;
 		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
+		float& operator [](uint i);
+		float  operator [](uint i) const;
 		// constructors & distructors
 		explicit Vec3();
-		explicit Vec3( float f );
-		explicit Vec3( float x, float y, float z );
-		explicit Vec3( const Vec2& v2, float z );
-		         Vec3( const Vec3& b );
-		explicit Vec3( const Vec4& v4 );
-		explicit Vec3( const Quat& q );
+		explicit Vec3(float f);
+		explicit Vec3(float x, float y, float z);
+		explicit Vec3(const Vec2& v2, float z);
+		         Vec3(const Vec3& b);
+		explicit Vec3(const Vec4& v4);
+		explicit Vec3(const Quat& q);
 		// ops with same type
-		Vec3  operator + ( const Vec3& b ) const;
-		Vec3& operator +=( const Vec3& b );
-		Vec3  operator - ( const Vec3& b ) const;
-		Vec3& operator -=( const Vec3& b );
-		Vec3  operator * ( const Vec3& b ) const;
-		Vec3& operator *=( const Vec3& b );
-		Vec3  operator / ( const Vec3& b ) const;
-		Vec3& operator /=( const Vec3& b );
+		Vec3  operator + (const Vec3& b) const;
+		Vec3& operator +=(const Vec3& b);
+		Vec3  operator - (const Vec3& b) const;
+		Vec3& operator -=(const Vec3& b);
+		Vec3  operator * (const Vec3& b) const;
+		Vec3& operator *=(const Vec3& b);
+		Vec3  operator / (const Vec3& b) const;
+		Vec3& operator /=(const Vec3& b);
 		Vec3  operator - () const; // return the negative
 		// ops with float
-		Vec3  operator + ( float f ) const;
-		Vec3& operator +=( float f );
-		Vec3  operator - ( float f ) const;
-		Vec3& operator -=( float f );
-		Vec3  operator * ( float f ) const;
-		Vec3& operator *=( float f );
-		Vec3  operator / ( float f ) const;
-		Vec3& operator /=( float f );
+		Vec3  operator + (float f) const;
+		Vec3& operator +=(float f);
+		Vec3  operator - (float f) const;
+		Vec3& operator -=(float f);
+		Vec3  operator * (float f) const;
+		Vec3& operator *=(float f);
+		Vec3  operator / (float f) const;
+		Vec3& operator /=(float f);
 		// ops with other types
-		Vec3  operator * ( const Mat3& m3 ) const;
+		Vec3  operator * (const Mat3& m3) const;
 		// comparision
-		bool operator ==( const Vec3& b ) const;
-		bool operator !=( const Vec3& b ) const;
+		bool operator ==(const Vec3& b) const;
+		bool operator !=(const Vec3& b) const;
 		// other
-		float dot( const Vec3& b ) const;
-		Vec3  cross( const Vec3& b ) const;
+		float dot(const Vec3& b) const;
+		Vec3  cross(const Vec3& b) const;
 		float getLength() const;
 		float getLengthSquared() const;
-		float getDistanceSquared( const Vec3& b ) const;
+		float getDistanceSquared(const Vec3& b) const;
 		void  normalize();
 		Vec3  getNormalized() const;
-		Vec3  getProjection( const Vec3& toThis ) const;
-		Vec3  getRotated( const Quat& q ) const; ///< Returns q * this * q.Conjucated() aka returns a rotated this. 18 muls, 12 adds
-		void  rotate( const Quat& q );
-		Vec3  lerp( const Vec3& v1, float t ) const; ///< return lerp( this, v1, t )
+		Vec3  getProjection(const Vec3& toThis) const;
+		Vec3  getRotated(const Quat& q) const; ///< Returns q * this * q.Conjucated() aka returns a rotated this. 18 muls, 12 adds
+		void  rotate(const Quat& q);
+		Vec3  lerp(const Vec3& v1, float t) const; ///< return lerp(this, v1, t)
 		void  print() const;
-		// transformations. The faster way is by far the mat4 * vec3 or the Transformed( Vec3, Mat3 )
-		Vec3  getTransformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
-		void  transform( const Vec3& translate, const Mat3& rotate, float scale );
-		Vec3  getTransformed( const Vec3& translate, const Mat3& rotate ) const;
-		void  transform( const Vec3& translate, const Mat3& rotate );
-		Vec3  getTransformed( const Vec3& translate, const Quat& rotate, float scale ) const;
-		void  transform( const Vec3& translate, const Quat& rotate, float scale );
-		Vec3  getTransformed( const Vec3& translate, const Quat& rotate ) const;
-		void  transform( const Vec3& translate, const Quat& rotate );
-		Vec3  getTransformed( const Mat4& transform ) const;  ///< 9 muls, 9 adds
-		void  transform( const Mat4& transform );
-		Vec3  getTransformed( const Transform& transform ) const;
-		void  transform( const Transform& transform );
+		// transformations. The faster way is by far the mat4 * vec3 or the Transformed(Vec3, Mat3)
+		Vec3  getTransformed(const Vec3& translate, const Mat3& rotate, float scale) const;
+		void  transform(const Vec3& translate, const Mat3& rotate, float scale);
+		Vec3  getTransformed(const Vec3& translate, const Mat3& rotate) const;
+		void  transform(const Vec3& translate, const Mat3& rotate);
+		Vec3  getTransformed(const Vec3& translate, const Quat& rotate, float scale) const;
+		void  transform(const Vec3& translate, const Quat& rotate, float scale);
+		Vec3  getTransformed(const Vec3& translate, const Quat& rotate) const;
+		void  transform(const Vec3& translate, const Quat& rotate);
+		Vec3  getTransformed(const Mat4& transform) const;  ///< 9 muls, 9 adds
+		void  transform(const Mat4& transform);
+		Vec3  getTransformed(const Transform& transform) const;
+		void  transform(const Transform& transform);
 };
 
 
 // other operators
-extern Vec3 operator +( float f, const Vec3& v );
-extern Vec3 operator -( float f, const Vec3& v );
-extern Vec3 operator *( float f, const Vec3& v );
-extern Vec3 operator /( float f, const Vec3& v );
+extern Vec3 operator +(float f, const Vec3& v);
+extern Vec3 operator -(float f, const Vec3& v);
+extern Vec3 operator *(float f, const Vec3& v);
+extern Vec3 operator /(float f, const Vec3& v);
 
 
 } // end namespace

+ 73 - 73
src/Math/Vec3.inl.h

@@ -8,12 +8,12 @@ namespace M {
 
 
 // accessors
-inline float& Vec3::operator []( uint i )
+inline float& Vec3::operator [](uint i)
 {
 	return (&x)[i];
 }
 
-inline float Vec3::operator []( uint i ) const
+inline float Vec3::operator [](uint i) const
 {
 	return (&x)[i];
 }
@@ -24,43 +24,43 @@ inline Vec3::Vec3()
 {}
 
 // constructor [float, float, float]
-inline Vec3::Vec3( float x_, float y_, float z_ )
+inline Vec3::Vec3(float x_, float y_, float z_)
 	: x(x_), y(y_), z(z_)
 {}
 
 // constructor [float]
-inline Vec3::Vec3( float f )
+inline Vec3::Vec3(float f)
 	: x(f), y(f), z(f)
 {}
 
 // constructor [vec3]
-inline Vec3::Vec3( const Vec3& b )
+inline Vec3::Vec3(const Vec3& b)
 	: x(b.x), y(b.y), z(b.z)
 {}
 
 // constructor [vec2, float]
-inline Vec3::Vec3( const Vec2& v2, float z_ )
+inline Vec3::Vec3(const Vec2& v2, float z_)
 	: x(v2.x), y(v2.y), z(z_)
 {}
 
 // constructor [vec4]
-inline Vec3::Vec3( const Vec4& v4 )
+inline Vec3::Vec3(const Vec4& v4)
 	: x(v4.x), y(v4.y), z(v4.z)
 {}
 
 // constructor [quat]
-inline Vec3::Vec3( const Quat& q )
+inline Vec3::Vec3(const Quat& q)
 	: x(q.x), y(q.y), z(q.z)
 {}
 
 // +
-inline Vec3 Vec3::operator +( const Vec3& b ) const
+inline Vec3 Vec3::operator +(const Vec3& b) const
 {
-	return Vec3( x+b.x, y+b.y, z+b.z );
+	return Vec3(x+b.x, y+b.y, z+b.z);
 }
 
 // +=
-inline Vec3& Vec3::operator +=( const Vec3& b )
+inline Vec3& Vec3::operator +=(const Vec3& b)
 {
 	x += b.x;
 	y += b.y;
@@ -69,13 +69,13 @@ inline Vec3& Vec3::operator +=( const Vec3& b )
 }
 
 // -
-inline Vec3 Vec3::operator -( const Vec3& b ) const
+inline Vec3 Vec3::operator -(const Vec3& b) const
 {
-	return Vec3( x-b.x, y-b.y, z-b.z );
+	return Vec3(x-b.x, y-b.y, z-b.z);
 }
 
 // -=
-inline Vec3& Vec3::operator -=( const Vec3& b )
+inline Vec3& Vec3::operator -=(const Vec3& b)
 {
 	x -= b.x;
 	y -= b.y;
@@ -84,13 +84,13 @@ inline Vec3& Vec3::operator -=( const Vec3& b )
 }
 
 // *
-inline Vec3 Vec3::operator *( const Vec3& b ) const
+inline Vec3 Vec3::operator *(const Vec3& b) const
 {
-	return Vec3( x*b.x, y*b.y, z*b.z );
+	return Vec3(x*b.x, y*b.y, z*b.z);
 }
 
 // *=
-inline Vec3& Vec3::operator *=( const Vec3& b )
+inline Vec3& Vec3::operator *=(const Vec3& b)
 {
 	x *= b.x;
 	y *= b.y;
@@ -99,13 +99,13 @@ inline Vec3& Vec3::operator *=( const Vec3& b )
 }
 
 // /
-inline Vec3 Vec3::operator /( const Vec3& b ) const
+inline Vec3 Vec3::operator /(const Vec3& b) const
 {
-	return Vec3( x/b.x, y/b.y, z/b.z );
+	return Vec3(x/b.x, y/b.y, z/b.z);
 }
 
 // /=
-inline Vec3& Vec3::operator /=( const Vec3& b )
+inline Vec3& Vec3::operator /=(const Vec3& b)
 {
 	x /= b.x;
 	y /= b.y;
@@ -116,113 +116,113 @@ inline Vec3& Vec3::operator /=( const Vec3& b )
 // negative
 inline Vec3 Vec3::operator -() const
 {
-	return Vec3( -x, -y, -z );
+	return Vec3(-x, -y, -z);
 }
 
 // ==
-inline bool Vec3::operator ==( const Vec3& b ) const
+inline bool Vec3::operator ==(const Vec3& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) ) ? true : false;
+	return (isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z)) ? true : false;
 }
 
 // !=
-inline bool Vec3::operator !=( const Vec3& b ) const
+inline bool Vec3::operator !=(const Vec3& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) ) ? false : true;
+	return (isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z)) ? false : true;
 }
 
 // vec3 + float
-inline Vec3 Vec3::operator +( float f ) const
+inline Vec3 Vec3::operator +(float f) const
 {
 	return ME + Vec3(f);
 }
 
 // float + vec3
-inline Vec3 operator +( float f, const Vec3& v )
+inline Vec3 operator +(float f, const Vec3& v)
 {
 	return v+f;
 }
 
 // vec3 += float
-inline Vec3& Vec3::operator +=( float f )
+inline Vec3& Vec3::operator +=(float f)
 {
 	ME += Vec3(f);
 	return ME;
 }
 
 // vec3 - float
-inline Vec3 Vec3::operator -( float f ) const
+inline Vec3 Vec3::operator -(float f) const
 {
 	return ME - Vec3(f);
 }
 
 // float - vec3
-inline Vec3 operator -( float f, const Vec3& v )
+inline Vec3 operator -(float f, const Vec3& v)
 {
 	return Vec3(f-v.x, f-v.y, f-v.z);
 }
 
 // vec3 -= float
-inline Vec3& Vec3::operator -=( float f )
+inline Vec3& Vec3::operator -=(float f)
 {
 	ME -= Vec3(f);
 	return ME;
 }
 
 // vec3 * float
-inline Vec3 Vec3::operator *( float f ) const
+inline Vec3 Vec3::operator *(float f) const
 {
 	return ME * Vec3(f);
 }
 
 // float * vec3
-inline Vec3 operator *( float f, const Vec3& v )
+inline Vec3 operator *(float f, const Vec3& v)
 {
 	return v*f;
 }
 
 // vec3 *= float
-inline Vec3& Vec3::operator *=( float f )
+inline Vec3& Vec3::operator *=(float f)
 {
 	ME *= Vec3(f);
 	return ME;
 }
 
 // vec3 / float
-inline Vec3 Vec3::operator /( float f ) const
+inline Vec3 Vec3::operator /(float f) const
 {
 	return ME / Vec3(f);
 }
 
 // float / vec3
-inline Vec3 operator /( float f, const Vec3& v )
+inline Vec3 operator /(float f, const Vec3& v)
 {
 	return Vec3(f/v.x, f/v.y, f/v.z);
 }
 
 // vec3 /= float
-inline Vec3& Vec3::operator /=( float f )
+inline Vec3& Vec3::operator /=(float f)
 {
 	ME /= Vec3(f);
 	return ME;
 }
 
 // dot
-inline float Vec3::dot( const Vec3& b ) const
+inline float Vec3::dot(const Vec3& b) const
 {
 	return x*b.x + y*b.y + z*b.z;
 }
 
 // cross prod
-inline Vec3 Vec3::cross( const Vec3& b ) const
+inline Vec3 Vec3::cross(const Vec3& b) const
 {
-	return Vec3( y*b.z-z*b.y, z*b.x-x*b.z, x*b.y-y*b.x );
+	return Vec3(y*b.z-z*b.y, z*b.x-x*b.z, x*b.y-y*b.x);
 }
 
 // getLength
 inline float Vec3::getLength() const
 {
-	return M::sqrt( x*x + y*y + z*z );
+	return M::sqrt(x*x + y*y + z*z);
 }
 
 // getLengthSquared
@@ -232,7 +232,7 @@ inline float Vec3::getLengthSquared() const
 }
 
 // getDistanceSquared
-inline float Vec3::getDistanceSquared( const Vec3& b ) const
+inline float Vec3::getDistanceSquared(const Vec3& b) const
 {
 	return (ME-b).getLengthSquared();
 }
@@ -240,39 +240,39 @@ inline float Vec3::getDistanceSquared( const Vec3& b ) const
 // normalize
 inline void Vec3::normalize()
 {
-	ME *= invSqrt( x*x + y*y + z*z );
+	ME *= invSqrt(x*x + y*y + z*z);
 }
 
 // Normalized (return the normalized)
 inline Vec3 Vec3::getNormalized() const
 {
-	return ME * invSqrt( x*x + y*y + z*z );
+	return ME * invSqrt(x*x + y*y + z*z);
 }
 
 // getProjection
-inline Vec3 Vec3::getProjection( const Vec3& toThis ) const
+inline Vec3 Vec3::getProjection(const Vec3& toThis) const
 {
-	return toThis * ( ME.dot(toThis)/(toThis.dot(toThis)) );
+	return toThis * (ME.dot(toThis)/(toThis.dot(toThis)));
 }
 
 // Rotated
-inline Vec3 Vec3::getRotated( const Quat& q ) const
+inline Vec3 Vec3::getRotated(const Quat& q) const
 {
-	DEBUG_ERR( !isZero(1.0-q.getLength()) ); // Not normalized quat
+	DEBUG_ERR(!isZero(1.0-q.getLength())); // Not normalized quat
 
 	/*float vmult = 2.0f*(q.x*x + q.y*y + q.z*z);
 	float crossmult = 2.0*q.w;
 	float pmult = crossmult*q.w - 1.0;
 
-	return Vec3( pmult*x + vmult*q.x + crossmult*(q.y*z - q.z*y),
+	return Vec3(pmult*x + vmult*q.x + crossmult*(q.y*z - q.z*y),
 							   pmult*y + vmult*q.y + crossmult*(q.z*x - q.x*z),
-	               pmult*z + vmult*q.z + crossmult*(q.x*y - q.y*x) );*/
-	Vec3 qXyz( q );
-	return ME + qXyz.cross( qXyz.cross(ME) + ME*q.w ) * 2.0;
+	               pmult*z + vmult*q.z + crossmult*(q.x*y - q.y*x));*/
+	Vec3 qXyz(q);
+	return ME + qXyz.cross(qXyz.cross(ME) + ME*q.w) * 2.0;
 }
 
 // rotate
-inline void Vec3::rotate( const Quat& q )
+inline void Vec3::rotate(const Quat& q)
 {
 	ME = getRotated(q);
 }
@@ -280,79 +280,79 @@ inline void Vec3::rotate( const Quat& q )
 // print
 inline void Vec3::print() const
 {
-	for( int i=0; i<3; i++ )
+	for(int i=0; i<3; i++)
 		cout << fixed << ME[i] << " ";
 	cout << "\n" << endl;
 }
 
 // lerp
-inline Vec3 Vec3::lerp( const Vec3& v1, float t ) const
+inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
 {
 	return (ME*(1.0f-t))+(v1*t);
 }
 
 // getTransformed [mat3]
-inline Vec3 Vec3::getTransformed( const Vec3& translate, const Mat3& rotate, float scale ) const
+inline Vec3 Vec3::getTransformed(const Vec3& translate, const Mat3& rotate, float scale) const
 {
 	return (rotate * (ME * scale)) + translate;
 }
 
 // transform [mat3]
-inline void Vec3::transform( const Vec3& translate, const Mat3& rotate, float scale )
+inline void Vec3::transform(const Vec3& translate, const Mat3& rotate, float scale)
 {
-	ME = getTransformed( translate, rotate, scale );
+	ME = getTransformed(translate, rotate, scale);
 }
 
 // getTransformed [mat3] no scale
-inline Vec3 Vec3::getTransformed( const Vec3& translate, const Mat3& rotate ) const
+inline Vec3 Vec3::getTransformed(const Vec3& translate, const Mat3& rotate) const
 {
 	return (rotate * ME) + translate;
 }
 
 // transform [mat3] no scale
-inline void Vec3::transform( const Vec3& translate, const Mat3& rotate )
+inline void Vec3::transform(const Vec3& translate, const Mat3& rotate)
 {
-	ME = getTransformed( translate, rotate );
+	ME = getTransformed(translate, rotate);
 }
 
 // getTransformed [quat]
-inline Vec3 Vec3::getTransformed( const Vec3& translate, const Quat& rotate, float scale ) const
+inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate, float scale) const
 {
 	return (ME * scale).getRotated(rotate) + translate;
 }
 
 // transform [quat3] no scale
-inline void Vec3::transform( const Vec3& translate, const Quat& rotate, float scale )
+inline void Vec3::transform(const Vec3& translate, const Quat& rotate, float scale)
 {
-	ME = getTransformed( translate, rotate, scale );
+	ME = getTransformed(translate, rotate, scale);
 }
 
 // getTransformed [mat4]
-inline Vec3 Vec3::getTransformed( const Mat4& transform ) const
+inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 {
 	return Vec3(
-		transform(0,0)*x + transform(0,1)*y + transform(0,2)*z + transform(0,3),
-		transform(1,0)*x + transform(1,1)*y + transform(1,2)*z + transform(1,3),
-		transform(2,0)*x + transform(2,1)*y + transform(2,2)*z + transform(2,3)
+		transform(0, 0)*x + transform(0, 1)*y + transform(0, 2)*z + transform(0, 3),
+		transform(1, 0)*x + transform(1, 1)*y + transform(1, 2)*z + transform(1, 3),
+		transform(2, 0)*x + transform(2, 1)*y + transform(2, 2)*z + transform(2, 3)
 	);
 }
 
 // getTransformed [mat4]
-inline void Vec3::transform( const Mat4& transform )
+inline void Vec3::transform(const Mat4& transform)
 {
-	ME = getTransformed( transform );
+	ME = getTransformed(transform);
 }
 
 // getTransformed [Transform]
-inline Vec3 Vec3::getTransformed( const Transform& transform ) const
+inline Vec3 Vec3::getTransformed(const Transform& transform) const
 {
 	return (transform.getRotation() * (ME * transform.getScale())) + transform.getOrigin();
 }
 
 // getTransformed [Transform]
-inline void Vec3::transform( const Transform& transform )
+inline void Vec3::transform(const Transform& transform)
 {
-	ME = getTransformed( transform );
+	ME = getTransformed(transform);
 }
 
 

+ 32 - 32
src/Math/Vec4.h

@@ -15,54 +15,54 @@ class Vec4
 		// data members
 		float x, y, z, w;
 		// accessors
-		float& operator []( uint i );
-		float  operator []( uint i ) const;
+		float& operator [](uint i);
+		float  operator [](uint i) const;
 		// constructors & distructors
 		explicit Vec4();
-		explicit Vec4( float f );
-		explicit Vec4( float x, float y, float z, float w );
-		explicit Vec4( const Vec2& v2, float z, float w );
-		explicit Vec4( const Vec3& v3, float w );
-		         Vec4( const Vec4& b );
-		explicit Vec4( const Quat& q );
+		explicit Vec4(float f);
+		explicit Vec4(float x, float y, float z, float w);
+		explicit Vec4(const Vec2& v2, float z, float w);
+		explicit Vec4(const Vec3& v3, float w);
+		         Vec4(const Vec4& b);
+		explicit Vec4(const Quat& q);
 		// ops with same
-		Vec4  operator + ( const Vec4& b ) const;
-		Vec4& operator +=( const Vec4& b );
-		Vec4  operator - ( const Vec4& b ) const;
-		Vec4& operator -=( const Vec4& b );
-		Vec4  operator * ( const Vec4& b ) const;
-		Vec4& operator *=( const Vec4& b );
-		Vec4  operator / ( const Vec4& b ) const;
-		Vec4& operator /=( const Vec4& b );
+		Vec4  operator + (const Vec4& b) const;
+		Vec4& operator +=(const Vec4& b);
+		Vec4  operator - (const Vec4& b) const;
+		Vec4& operator -=(const Vec4& b);
+		Vec4  operator * (const Vec4& b) const;
+		Vec4& operator *=(const Vec4& b);
+		Vec4  operator / (const Vec4& b) const;
+		Vec4& operator /=(const Vec4& b);
 		Vec4  operator - () const;
 		// ops with float
-		Vec4  operator + ( float f ) const;
-		Vec4& operator +=( float f );
-		Vec4  operator - ( float f ) const;
-		Vec4& operator -=( float f );
-		Vec4  operator * ( float f ) const;
-		Vec4& operator *=( float f );
-		Vec4  operator / ( float f ) const;
-		Vec4& operator /=( float f );
+		Vec4  operator + (float f) const;
+		Vec4& operator +=(float f);
+		Vec4  operator - (float f) const;
+		Vec4& operator -=(float f);
+		Vec4  operator * (float f) const;
+		Vec4& operator *=(float f);
+		Vec4  operator / (float f) const;
+		Vec4& operator /=(float f);
 		// ops with other
-		Vec4  operator * ( const Mat4& m4 ) const;
+		Vec4  operator * (const Mat4& m4) const;
 		// comparision
-		bool operator ==( const Vec4& b ) const;
-		bool operator !=( const Vec4& b ) const;
+		bool operator ==(const Vec4& b) const;
+		bool operator !=(const Vec4& b) const;
 		// other
 		float getLength() const;
 		Vec4  getNormalized() const;
 		void  normalize();
 		void  print() const;
-		float dot( const Vec4& b ) const;
+		float dot(const Vec4& b) const;
 };
 
 
 // other operators
-extern Vec4 operator +( float f, const Vec4& v4 );
-extern Vec4 operator -( float f, const Vec4& v4 );
-extern Vec4 operator *( float f, const Vec4& v4 );
-extern Vec4 operator /( float f, const Vec4& v4 );
+extern Vec4 operator +(float f, const Vec4& v4);
+extern Vec4 operator -(float f, const Vec4& v4);
+extern Vec4 operator *(float f, const Vec4& v4);
+extern Vec4 operator /(float f, const Vec4& v4);
 
 
 } // end namespace

+ 49 - 49
src/Math/Vec4.inl.h

@@ -8,12 +8,12 @@ namespace M {
 
 
 // accessors
-inline float& Vec4::operator []( uint i )
+inline float& Vec4::operator [](uint i)
 {
 	return (&x)[i];
 }
 
-inline float Vec4::operator []( uint i ) const
+inline float Vec4::operator [](uint i) const
 {
 	return (&x)[i];
 }
@@ -24,43 +24,43 @@ inline Vec4::Vec4()
 {}
 
 // constructor [float]
-inline Vec4::Vec4( float f )
+inline Vec4::Vec4(float f)
 	: x(f), y(f), z(f), w(f)
 {}
 
 // constructor [float, float, float, float]
-inline Vec4::Vec4( float x_, float y_, float z_, float w_ )
+inline Vec4::Vec4(float x_, float y_, float z_, float w_)
 	: x(x_), y(y_), z(z_), w(w_)
 {}
 
 // constructor [vec2, float, float]
-inline Vec4::Vec4( const Vec2& v2, float z_, float w_ )
+inline Vec4::Vec4(const Vec2& v2, float z_, float w_)
 	: x(v2.x), y(v2.y), z(z_), w(w_)
 {}
 
 // constructor [vec3, float]
-inline Vec4::Vec4( const Vec3& v3, float w_ )
+inline Vec4::Vec4(const Vec3& v3, float w_)
 	: x(v3.x), y(v3.y), z(v3.z), w(w_)
 {}
 
 // constructor [vec4]
-inline Vec4::Vec4( const Vec4& b )
+inline Vec4::Vec4(const Vec4& b)
 	: x(b.x), y(b.y), z(b.z), w(b.w)
 {}
 
 // constructor [quat]
-inline Vec4::Vec4( const Quat& q )
+inline Vec4::Vec4(const Quat& q)
 	: x(q.x), y(q.y), z(q.z), w(q.w)
 {}
 
 // +
-inline Vec4 Vec4::operator +( const Vec4& b ) const
+inline Vec4 Vec4::operator +(const Vec4& b) const
 {
-	return Vec4( x+b.x, y+b.y, z+b.z, w+b.w );
+	return Vec4(x+b.x, y+b.y, z+b.z, w+b.w);
 }
 
 // +=
-inline Vec4& Vec4::operator +=( const Vec4& b )
+inline Vec4& Vec4::operator +=(const Vec4& b)
 {
 	x += b.x;
 	y += b.y;
@@ -70,13 +70,13 @@ inline Vec4& Vec4::operator +=( const Vec4& b )
 }
 
 // -
-inline Vec4 Vec4::operator -( const Vec4& b ) const
+inline Vec4 Vec4::operator -(const Vec4& b) const
 {
-	return Vec4( x-b.x, y-b.y, z-b.z, w-b.w );
+	return Vec4(x-b.x, y-b.y, z-b.z, w-b.w);
 }
 
 // -=
-inline Vec4& Vec4::operator -=( const Vec4& b )
+inline Vec4& Vec4::operator -=(const Vec4& b)
 {
 	x -= b.x;
 	y -= b.y;
@@ -86,13 +86,13 @@ inline Vec4& Vec4::operator -=( const Vec4& b )
 }
 
 // *
-inline Vec4 Vec4::operator *( const Vec4& b ) const
+inline Vec4 Vec4::operator *(const Vec4& b) const
 {
-	return Vec4( x*b.x, y*b.y, z*b.z, w*b.w );
+	return Vec4(x*b.x, y*b.y, z*b.z, w*b.w);
 }
 
 // *=
-inline Vec4& Vec4::operator *=( const Vec4& b )
+inline Vec4& Vec4::operator *=(const Vec4& b)
 {
 	x *= b.x;
 	y *= b.y;
@@ -102,13 +102,13 @@ inline Vec4& Vec4::operator *=( const Vec4& b )
 }
 
 // /
-inline Vec4 Vec4::operator /( const Vec4& b ) const
+inline Vec4 Vec4::operator /(const Vec4& b) const
 {
-	return Vec4( x/b.x, y/b.y, z/b.z, w/b.w );
+	return Vec4(x/b.x, y/b.y, z/b.z, w/b.w);
 }
 
 // /=
-inline Vec4& Vec4::operator /=( const Vec4& b )
+inline Vec4& Vec4::operator /=(const Vec4& b)
 {
 	x /= b.x;
 	y /= b.y;
@@ -120,110 +120,110 @@ inline Vec4& Vec4::operator /=( const Vec4& b )
 // negative
 inline Vec4 Vec4::operator -() const
 {
-	return Vec4( -x, -y, -z, -w );
+	return Vec4(-x, -y, -z, -w);
 }
 
 // ==
-inline bool Vec4::operator ==( const Vec4& b ) const
+inline bool Vec4::operator ==(const Vec4& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? true : false;
+	return (isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w)) ? true : false;
 }
 
 // !=
-inline bool Vec4::operator !=( const Vec4& b ) const
+inline bool Vec4::operator !=(const Vec4& b) const
 {
-	return ( isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w) ) ? false : true;
+	return (isZero(x-b.x) && isZero(y-b.y) && isZero(z-b.z) && isZero(w-b.w)) ? false : true;
 }
 
 // vec4 + float
-inline Vec4 Vec4::operator +( float f ) const
+inline Vec4 Vec4::operator +(float f) const
 {
 	return ME + Vec4(f);
 }
 
 // float + vec4
-inline Vec4 operator +( float f, const Vec4& v4 )
+inline Vec4 operator +(float f, const Vec4& v4)
 {
 	return v4+f;
 }
 
 // vec4 += float
-inline Vec4& Vec4::operator +=( float f )
+inline Vec4& Vec4::operator +=(float f)
 {
 	ME += Vec4(f);
 	return ME;
 }
 
 // vec4 - float
-inline Vec4 Vec4::operator -( float f ) const
+inline Vec4 Vec4::operator -(float f) const
 {
 	return ME - Vec4(f);
 }
 
 // float - vec4
-inline Vec4 operator -( float f, const Vec4& v4 )
+inline Vec4 operator -(float f, const Vec4& v4)
 {
-	return Vec4( f-v4.x, f-v4.y, f-v4.z, f-v4.w );
+	return Vec4(f-v4.x, f-v4.y, f-v4.z, f-v4.w);
 }
 
 // vec4 -= float
-inline Vec4& Vec4::operator -=( float f )
+inline Vec4& Vec4::operator -=(float f)
 {
 	ME -= Vec4(f);
 	return ME;
 }
 
 // vec4 * float
-inline Vec4 Vec4::operator *( float f ) const
+inline Vec4 Vec4::operator *(float f) const
 {
 	return ME * Vec4(f);
 }
 
 // float * vec4
-inline Vec4 operator *( float f, const Vec4& v4 )
+inline Vec4 operator *(float f, const Vec4& v4)
 {
 	return v4*f;
 }
 
 // vec4 *= float
-inline Vec4& Vec4::operator *=( float f )
+inline Vec4& Vec4::operator *=(float f)
 {
 	ME *= Vec4(f);
 	return ME;
 }
 
 // vec4 / float
-inline Vec4 Vec4::operator /( float f ) const
+inline Vec4 Vec4::operator /(float f) const
 {
 	return ME / Vec4(f);
 }
 
 // float / vec4
-inline Vec4 operator /( float f, const Vec4& v4 )
+inline Vec4 operator /(float f, const Vec4& v4)
 {
-	return Vec4( f/v4.x, f/v4.y, f/v4.z, f/v4.w );
+	return Vec4(f/v4.x, f/v4.y, f/v4.z, f/v4.w);
 }
 
 // vec4 /= float
-inline Vec4& Vec4::operator /=( float f )
+inline Vec4& Vec4::operator /=(float f)
 {
 	ME /= Vec4(f);
 	return ME;
 }
 
 // vec4 * mat4
-inline Vec4 Vec4::operator *( const Mat4& m4 ) const
+inline Vec4 Vec4::operator *(const Mat4& m4) const
 {
 	return Vec4(
-		x*m4(0,0) + y*m4(1,0) + z*m4(2,0) + w*m4(3,0),
-		x*m4(0,1) + y*m4(1,1) + z*m4(2,1) + w*m4(3,1),
-		x*m4(0,2) + y*m4(1,2) + z*m4(2,2) + w*m4(3,2),
-		x*m4(0,3) + y*m4(1,3) + z*m4(2,3) + w*m4(3,3)
+		x*m4(0, 0) + y*m4(1, 0) + z*m4(2, 0) + w*m4(3, 0),
+		x*m4(0, 1) + y*m4(1, 1) + z*m4(2, 1) + w*m4(3, 1),
+		x*m4(0, 2) + y*m4(1, 2) + z*m4(2, 2) + w*m4(3, 2),
+		x*m4(0, 3) + y*m4(1, 3) + z*m4(2, 3) + w*m4(3, 3)
 	);
 }
 
 // dot
-inline float Vec4::dot( const Vec4& b ) const
+inline float Vec4::dot(const Vec4& b) const
 {
 	return x*b.x + y*b.y + z*b.z + w*b.w;
 }
@@ -231,25 +231,25 @@ inline float Vec4::dot( const Vec4& b ) const
 // getLength
 inline float Vec4::getLength() const
 {
-	return M::sqrt( x*x + y*y + z*z + w*w );
+	return M::sqrt(x*x + y*y + z*z + w*w);
 }
 
 // Normalized
 inline Vec4 Vec4::getNormalized() const
 {
-	return ME * invSqrt( x*x +y*y + z*z + w*w );
+	return ME * invSqrt(x*x +y*y + z*z + w*w);
 }
 
 // normalize
 inline void Vec4::normalize()
 {
-	ME *= invSqrt( x*x +y*y + z*z + w*w );
+	ME *= invSqrt(x*x +y*y + z*z + w*w);
 }
 
 // print
 inline void Vec4::print() const
 {
-	for( int i=0; i<4; i++ )
+	for(int i=0; i<4; i++)
 		cout << fixed << ME[i] << " ";
 	cout << "\n" << endl;
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 214 - 214
src/Misc/collision.cpp


+ 95 - 95
src/Misc/collision.h

@@ -3,7 +3,7 @@
 
 /*
 Info on how seperation tests work.
-We have: bvolume1.SeperationTest( bvolume2, normal, impact_point, depth );
+We have: bvolume1.SeperationTest(bvolume2, normal, impact_point, depth);
 This expresion returns the normal, impact_point and depth of the collision between bvolume1 and bvolume2.
 The normal shows the direction we have to move bvolume2 in order to seperate the 2 volumes. The depth shows the distance we have to
 move bvolume2 for the seperation. The impact_point is a point between inside the collision area.
@@ -41,7 +41,7 @@ class bvolume_t
 
 		type_e type;
 
-		bvolume_t( type_e type_ ): type(type_) {}
+		bvolume_t(type_e type_): type(type_) {}
 
 		virtual void Render() = 0;
 
@@ -49,21 +49,21 @@ class bvolume_t
 		 * If the bounding volume intersects with the plane then the func returns 0, else it returns the distance. If the distance is <0 then
 		 * the b.v. lies behind the plane and if >0 then in front of it
 		 */
-		virtual float PlaneTest( const plane_t& ) const { ERROR("N.A."); return 0.0; }
+		virtual float PlaneTest(const plane_t&) const { ERROR("N.A."); return 0.0; }
 
 		// Intersections
-		virtual bool Intersects( const lineseg_t& )      const { ERROR("N.A."); return false; }
-		virtual bool Intersects( const ray_t& )          const { ERROR("N.A."); return false; }
-		virtual bool Intersects( const bsphere_t& )      const { ERROR("N.A."); return false; }
-		virtual bool Intersects( const aabb_t& )         const { ERROR("N.A."); return false; }
-		virtual bool Intersects( const obb_t& )          const { ERROR("N.A."); return false; }
-		        bool Intersects( const bvolume_t& bv )   const;        ///< Abstract intersection test
+		virtual bool Intersects(const lineseg_t&)      const { ERROR("N.A."); return false; }
+		virtual bool Intersects(const ray_t&)          const { ERROR("N.A."); return false; }
+		virtual bool Intersects(const bsphere_t&)      const { ERROR("N.A."); return false; }
+		virtual bool Intersects(const aabb_t&)         const { ERROR("N.A."); return false; }
+		virtual bool Intersects(const obb_t&)          const { ERROR("N.A."); return false; }
+		        bool Intersects(const bvolume_t& bv)   const;        ///< Abstract intersection test
 
 		// SeperationTests
-		virtual bool SeperationTest( const bsphere_t&, Vec3&, Vec3&, float& ) const { ERROR("N.A."); return false; }
-		virtual bool SeperationTest( const aabb_t&, Vec3&, Vec3&, float& )    const { ERROR("N.A."); return false; }
-		virtual bool SeperationTest( const obb_t&, Vec3&, Vec3&, float& )     const { ERROR("N.A."); return false; }
-		        bool SeperationTest( const bvolume_t& bv, Vec3& normal, Vec3& impact_point, float& depth ) const; ///< Abstract seperation test
+		virtual bool SeperationTest(const bsphere_t&, Vec3&, Vec3&, float&) const { ERROR("N.A."); return false; }
+		virtual bool SeperationTest(const aabb_t&, Vec3&, Vec3&, float&)    const { ERROR("N.A."); return false; }
+		virtual bool SeperationTest(const obb_t&, Vec3&, Vec3&, float&)     const { ERROR("N.A."); return false; }
+		        bool SeperationTest(const bvolume_t& bv, Vec3& normal, Vec3& impact_point, float& depth) const; ///< Abstract seperation test
 };
 
 
@@ -81,19 +81,19 @@ class lineseg_t: public bvolume_t
 
 		// constructors & distructors
 		lineseg_t(): bvolume_t(LINE_SEG) {}
-		lineseg_t( const lineseg_t& b ): bvolume_t(LINE_SEG) { (*this)=b; }
-		lineseg_t( const Vec3& origin_, const Vec3& dir_ ): bvolume_t(LINE_SEG) { origin=origin_; dir=dir_; }
+		lineseg_t(const lineseg_t& b): bvolume_t(LINE_SEG) { (*this)=b; }
+		lineseg_t(const Vec3& origin_, const Vec3& dir_): bvolume_t(LINE_SEG) { origin=origin_; dir=dir_; }
 
 		// operators
-		lineseg_t& operator =( const lineseg_t& b ) { origin=b.origin; dir=b.dir; return (*this); }
+		lineseg_t& operator =(const lineseg_t& b) { origin=b.origin; dir=b.dir; return (*this); }
 
 		// std funcs
-		lineseg_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		lineseg_t Transformed(const Vec3& translate, const Mat3& rotate, float scale) const;
 		void Render();
-		float PlaneTest( const plane_t& ) const;
-		bool Intersects( const bsphere_t& sphere ) const;
-		bool Intersects( const aabb_t& aabb ) const;
-		bool Intersects( const obb_t& obb ) const;
+		float PlaneTest(const plane_t&) const;
+		bool Intersects(const bsphere_t& sphere) const;
+		bool Intersects(const aabb_t& aabb) const;
+		bool Intersects(const obb_t& obb) const;
 
 		// other funcs
 		/*
@@ -104,12 +104,12 @@ class lineseg_t: public bvolume_t
 		*/
 		float  LengthSquared() const { return dir.getLengthSquared(); }
 		float  Length() const { return dir.getLength(); }
-		float  DistanceSquared( const lineseg_t& seg, float& s_c, float& t_c ) const;   ///< Dist with another segment
-		float  DistanceSquared( const ray_t& ray, float& s_c, float& t_c ) const;       ///< Dist with a ray
-		float  DistanceSquared( const Vec3& point, float& t_c ) const;                ///< Dist with a point.
-		void   ClosestPoints( const lineseg_t& seg, Vec3& point0, Vec3& point1 ) const; ///< Closest points between this and another seg
-		void   ClosestPoints( const ray_t& ray, Vec3& point0, Vec3& point1 ) const;     ///< Closest points between this and a ray
-		Vec3 ClosestPoints( const Vec3& point ) const;                                  ///< Closest points between this and a poin
+		float  DistanceSquared(const lineseg_t& seg, float& s_c, float& t_c) const;   ///< Dist with another segment
+		float  DistanceSquared(const ray_t& ray, float& s_c, float& t_c) const;       ///< Dist with a ray
+		float  DistanceSquared(const Vec3& point, float& t_c) const;                ///< Dist with a point.
+		void   ClosestPoints(const lineseg_t& seg, Vec3& point0, Vec3& point1) const; ///< Closest points between this and another seg
+		void   ClosestPoints(const ray_t& ray, Vec3& point0, Vec3& point1) const;     ///< Closest points between this and a ray
+		Vec3 ClosestPoints(const Vec3& point) const;                                  ///< Closest points between this and a poin
 };
 
 
@@ -127,24 +127,24 @@ class ray_t: bvolume_t
 
 		// constructors & distructors
 		ray_t(): bvolume_t(RAY) {}
-		ray_t( const ray_t& b ): bvolume_t(RAY) { (*this)=b; }
-		ray_t( const Vec3& origin_, const Vec3& dir_ ): bvolume_t(RAY), origin(origin_), dir(dir_) {}
+		ray_t(const ray_t& b): bvolume_t(RAY) { (*this)=b; }
+		ray_t(const Vec3& origin_, const Vec3& dir_): bvolume_t(RAY), origin(origin_), dir(dir_) {}
 
 		// operators
-		ray_t& operator =( const ray_t& b ) { origin=b.origin; dir=b.dir; return (*this); }
+		ray_t& operator =(const ray_t& b) { origin=b.origin; dir=b.dir; return (*this); }
 
 		// std funcs
-		ray_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		ray_t Transformed(const Vec3& translate, const Mat3& rotate, float scale) const;
 		void Render();
-		float PlaneTest( const plane_t& ) const;
-		bool Intersects( const bsphere_t& sphere ) const;
-		bool Intersects( const aabb_t& aabb ) const;
-		bool Intersects( const obb_t& obb ) const;
+		float PlaneTest(const plane_t&) const;
+		bool Intersects(const bsphere_t& sphere) const;
+		bool Intersects(const aabb_t& aabb) const;
+		bool Intersects(const obb_t& obb) const;
 
 		// other funcs
-		float  DistanceSquared( const ray_t& ray, float& s_c, float& t_c ) const;   // this and another ray
-		void   ClosestPoints( const ray_t& ray, Vec3& point0, Vec3& point1 ) const;   // this and another ray
-		Vec3 ClosestPoint( const Vec3& point ) const;                                 // this and point
+		float  DistanceSquared(const ray_t& ray, float& s_c, float& t_c) const;   // this and another ray
+		void   ClosestPoints(const ray_t& ray, Vec3& point0, Vec3& point1) const;   // this and another ray
+		Vec3 ClosestPoint(const Vec3& point) const;                                 // this and point
 };
 
 
@@ -162,34 +162,34 @@ class plane_t: public bvolume_t
 
 		// constructors & distructors
 		plane_t(): bvolume_t(PLANE) {}
-		plane_t( const plane_t& b ): bvolume_t(PLANE) { (*this)=b; }
-		plane_t( const Vec3& normal_, float offset_ ): bvolume_t(PLANE), normal(normal_), offset(offset_) {}
-		plane_t( const Vec3& p0, const Vec3& p1, const Vec3& p2 ): bvolume_t(PLANE) { Set(p0,p1,p2); }
-		plane_t( float a, float b, float c, float d ): bvolume_t(PLANE) { Set(a,b,c,d); }
+		plane_t(const plane_t& b): bvolume_t(PLANE) { (*this)=b; }
+		plane_t(const Vec3& normal_, float offset_): bvolume_t(PLANE), normal(normal_), offset(offset_) {}
+		plane_t(const Vec3& p0, const Vec3& p1, const Vec3& p2): bvolume_t(PLANE) { Set(p0,p1,p2); }
+		plane_t(float a, float b, float c, float d): bvolume_t(PLANE) { Set(a,b,c,d); }
 
 		// operators
-		plane_t& operator =( const plane_t& b ) { normal=b.normal; offset=b.offset; return (*this); }
+		plane_t& operator =(const plane_t& b) { normal=b.normal; offset=b.offset; return (*this); }
 
 		// std funcs
-		plane_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		plane_t Transformed(const Vec3& translate, const Mat3& rotate, float scale) const;
 		void Render();
 
 		// other funcs
-		void Set( const Vec3& p0, const Vec3& p1, const Vec3& p2 ); ///< Set the plane from 3 vectors
-		void Set( float a, float b, float c, float d ); ///< Set from plane where plane equation is ax+by+cz+d
+		void Set(const Vec3& p0, const Vec3& p1, const Vec3& p2); ///< Set the plane from 3 vectors
+		void Set(float a, float b, float c, float d); ///< Set from plane where plane equation is ax+by+cz+d
 
 		/**
 		 * It gives the distance between a point and a plane. if returns >0 then the point lies in front of the plane, if <0 then it
 		 * is behind and if =0 then it is co-planar
 		 */
-		float Test( const Vec3& point ) const { return normal.dot(point) - offset; }
+		float Test(const Vec3& point) const { return normal.dot(point) - offset; }
 
-		float Distance( const Vec3& point ) const { return fabs( Test(point) ); }
+		float Distance(const Vec3& point) const { return fabs(Test(point)); }
 
 		/**
 		 * Returns the perpedicular point of a given point in this plane. Plane's normal and returned-point are perpedicular
 		 */
-		Vec3 ClosestPoint( const Vec3& point ) const { return point - normal*Test(point); };
+		Vec3 ClosestPoint(const Vec3& point) const { return point - normal*Test(point); };
 };
 
 
@@ -207,27 +207,27 @@ class bsphere_t: public bvolume_t
 
 		// constructors & distractor
 		bsphere_t(): bvolume_t(BSPHERE) {}
-		bsphere_t( const bsphere_t& other ): bvolume_t(BSPHERE) { (*this) = other; }
-		bsphere_t( const Vec3& center_, float radius_ ): bvolume_t(BSPHERE), center(center_), radius(radius_) {}
+		bsphere_t(const bsphere_t& other): bvolume_t(BSPHERE) { (*this) = other; }
+		bsphere_t(const Vec3& center_, float radius_): bvolume_t(BSPHERE), center(center_), radius(radius_) {}
 
 		// operators
-		bsphere_t& operator =( const bsphere_t& other ) { center=other.center; radius=other.radius; return (*this); }
+		bsphere_t& operator =(const bsphere_t& other) { center=other.center; radius=other.radius; return (*this); }
 
 		// std funcs
-		bsphere_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		bsphere_t Transformed(const Vec3& translate, const Mat3& rotate, float scale) const;
 		void Render();
-		float PlaneTest( const plane_t& plane ) const;
-		bool Intersects( const ray_t& ray ) const;
-		bool Intersects( const lineseg_t& segment ) const;
-		bool Intersects( const bsphere_t& sphere ) const;
-		bool Intersects( const aabb_t& aabb ) const;
-		bool Intersects( const obb_t& obb ) const;
-		bool SeperationTest( const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth ) const;
-		bool SeperationTest( const aabb_t& aabb, Vec3& normal, Vec3& impact_point, float& depth ) const;
-		bool SeperationTest( const obb_t& obb, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		float PlaneTest(const plane_t& plane) const;
+		bool Intersects(const ray_t& ray) const;
+		bool Intersects(const lineseg_t& segment) const;
+		bool Intersects(const bsphere_t& sphere) const;
+		bool Intersects(const aabb_t& aabb) const;
+		bool Intersects(const obb_t& obb) const;
+		bool SeperationTest(const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth) const;
+		bool SeperationTest(const aabb_t& aabb, Vec3& normal, Vec3& impact_point, float& depth) const;
+		bool SeperationTest(const obb_t& obb, Vec3& normal, Vec3& impact_point, float& depth) const;
 
 		// other funcs
-		void Set( const void* pointer, uint stride, int count ); ///< Set from vec3 array
+		void Set(const void* pointer, uint stride, int count); ///< Set from vec3 array
 };
 
 
@@ -245,27 +245,27 @@ class aabb_t: public bvolume_t
 
 		// constructors & destractor
 		aabb_t(): bvolume_t(AABB) {}
-		aabb_t( const aabb_t& other ): bvolume_t(AABB) { (*this) = other; }
-		aabb_t( const Vec3& min_, const Vec3& max_ ): bvolume_t(AABB), min(min_), max(max_) { DEBUG_ERR( max.x<min.x || max.y<min.y || max.z<min.z ); }
+		aabb_t(const aabb_t& other): bvolume_t(AABB) { (*this) = other; }
+		aabb_t(const Vec3& min_, const Vec3& max_): bvolume_t(AABB), min(min_), max(max_) { DEBUG_ERR(max.x<min.x || max.y<min.y || max.z<min.z); }
 
 		// operators
-		aabb_t& operator =( const aabb_t& other ) { min=other.min; max=other.max; return (*this); }
+		aabb_t& operator =(const aabb_t& other) { min=other.min; max=other.max; return (*this); }
 
 		// std funcs
-		aabb_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		aabb_t Transformed(const Vec3& translate, const Mat3& rotate, float scale) const;
 		void Render();
-		float PlaneTest( const plane_t& plane ) const;
-		bool Intersects( const ray_t& ray ) const;
-		bool Intersects( const lineseg_t& segment ) const;
-		bool Intersects( const bsphere_t& sphere ) const;
-		bool Intersects( const aabb_t& aabb ) const;
-		bool Intersects( const obb_t& obb ) const;
-		bool SeperationTest( const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth ) const;
-		bool SeperationTest( const aabb_t& aabb, Vec3& normal, Vec3& impact_point, float& depth ) const;
-		bool SeperationTest( const obb_t& oob, Vec3& normal, Vec3& impact_point, float& depth ) const;
+		float PlaneTest(const plane_t& plane) const;
+		bool Intersects(const ray_t& ray) const;
+		bool Intersects(const lineseg_t& segment) const;
+		bool Intersects(const bsphere_t& sphere) const;
+		bool Intersects(const aabb_t& aabb) const;
+		bool Intersects(const obb_t& obb) const;
+		bool SeperationTest(const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth) const;
+		bool SeperationTest(const aabb_t& aabb, Vec3& normal, Vec3& impact_point, float& depth) const;
+		bool SeperationTest(const obb_t& oob, Vec3& normal, Vec3& impact_point, float& depth) const;
 
 		// other funcs
-		void Set( const void* pointer, uint stride, int count ); ///< Set from vec3 array
+		void Set(const void* pointer, uint stride, int count); ///< Set from vec3 array
 };
 
 
@@ -284,28 +284,28 @@ class obb_t: public bvolume_t
 
 		// constructors & destractor
 		obb_t(): bvolume_t(OBB) {}
-		obb_t( const obb_t& other ): bvolume_t(OBB) { (*this)=other; }
-		obb_t( const Vec3& c_, const Mat3& r_, const Vec3& e_ ): bvolume_t(OBB) { center=c_; rotation=r_; extends=e_; }
+		obb_t(const obb_t& other): bvolume_t(OBB) { (*this)=other; }
+		obb_t(const Vec3& c_, const Mat3& r_, const Vec3& e_): bvolume_t(OBB) { center=c_; rotation=r_; extends=e_; }
 
 		// operators
-		obb_t& operator =( const obb_t& other ) { center=other.center; rotation=other.rotation; extends=other.extends; return (*this); }
+		obb_t& operator =(const obb_t& other) { center=other.center; rotation=other.rotation; extends=other.extends; return (*this); }
 
 		// std funcs
-		obb_t Transformed( const Vec3& translate, const Mat3& rotate, float scale ) const;
+		obb_t Transformed(const Vec3& translate, const Mat3& rotate, float scale) const;
 		void  Render();
-		float PlaneTest( const plane_t& plane ) const;
-		bool Intersects( const ray_t& ray ) const;
-		bool Intersects( const lineseg_t& segment ) const;
-		bool Intersects( const bsphere_t& sphere ) const;
-		bool Intersects( const aabb_t& aabb ) const;
-		bool Intersects( const obb_t& obb ) const;
-		bool SeperationTest( const bvolume_t& bv, Vec3& normal, Vec3& impact_point, float& depth ) const;
-		bool SeperationTest( const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth ) const;
-		bool SeperationTest( const aabb_t& /*aabb*/, Vec3& /*normal*/, Vec3& /*impact_point*/, float& /*depth*/ ) const { ERROR("ToDo"); return false; }
-		bool SeperationTest( const obb_t& /*obb*/, Vec3& /*normal*/, Vec3& /*impact_point*/, float& /*depth*/ ) const { ERROR("ToDo"); return false; }
+		float PlaneTest(const plane_t& plane) const;
+		bool Intersects(const ray_t& ray) const;
+		bool Intersects(const lineseg_t& segment) const;
+		bool Intersects(const bsphere_t& sphere) const;
+		bool Intersects(const aabb_t& aabb) const;
+		bool Intersects(const obb_t& obb) const;
+		bool SeperationTest(const bvolume_t& bv, Vec3& normal, Vec3& impact_point, float& depth) const;
+		bool SeperationTest(const bsphere_t& sphere, Vec3& normal, Vec3& impact_point, float& depth) const;
+		bool SeperationTest(const aabb_t& /*aabb*/, Vec3& /*normal*/, Vec3& /*impact_point*/, float& /*depth*/) const { ERROR("ToDo"); return false; }
+		bool SeperationTest(const obb_t& /*obb*/, Vec3& /*normal*/, Vec3& /*impact_point*/, float& /*depth*/) const { ERROR("ToDo"); return false; }
 
 		// other funcs
-		void Set( const void* pointer, uint stride, int count ); ///< Set from vec3 array
+		void Set(const void* pointer, uint stride, int count); ///< Set from vec3 array
 };
 
 
@@ -322,11 +322,11 @@ collision triangle
 
 		// constructors & destractor
 		cTriangle() {}
-		cTriangle( const Vec3& a_, const Vec3& b_, const Vec3& c_ ): a(a_), b(b_), c(c_) {}
-		cTriangle( const  )
+		cTriangle(const Vec3& a_, const Vec3& b_, const Vec3& c_): a(a_), b(b_), c(c_) {}
+		cTriangle(const)
 
 		// operators
-		cTriangle& operator =( const cTriangle& other ) { a=other.a; b=other.b; c=other.c; return (*this); }
+		cTriangle& operator =(const cTriangle& other) { a=other.a; b=other.b; c=other.c; return (*this); }
 
 		// std funcs
 };*/

+ 41 - 41
src/Misc/map.cpp

@@ -12,24 +12,24 @@
 CreateRoot                                                                                                             =
 =======================================================================================================================================
 */
-void octree_t::CreateRoot( const Vec<Mesh*>& meshes )
+void octree_t::CreateRoot(const Vec<Mesh*>& meshes)
 {
-	DEBUG_ERR( root ); // root should be NULL
+	DEBUG_ERR(root); // root should be NULL
 
 	/// get the root's aabb size
-	Vec3 min( numeric_limits<float>::max() ), max( numeric_limits<float>::min() );
+	Vec3 min(numeric_limits<float>::max()), max(numeric_limits<float>::min());
 
-	for( uint m=0; m<meshes.size(); m++ )
+	for(uint m=0; m<meshes.size(); m++)
 	{
 		Mesh* cmesh = meshes[m];
-		for( uint v=0; v<cmesh->vertCoords.size(); v++ )
+		for(uint v=0; v<cmesh->vertCoords.size(); v++)
 		{
 			const Vec3& vertCoords = cmesh->vertCoords[v];
-			for( int i=0; i<3; i++ )
+			for(int i=0; i<3; i++)
 			{
-				if( vertCoords[i] > max[i] )
+				if(vertCoords[i] > max[i])
 					max[i] = vertCoords[i];
-				else if( vertCoords[i] < min[i] )
+				else if(vertCoords[i] < min[i])
 					min[i] = vertCoords[i];
 			} // end for 3 times
 		} // end for all mesh verts
@@ -43,13 +43,13 @@ void octree_t::CreateRoot( const Vec<Mesh*>& meshes )
 
 
 	/// create the face and vert ids
-	DEBUG_ERR( node->face_ids.size() != 0 || node->vertIds.size() != 0 || node->meshes.size() != 0 ); // vectors not empty. wrong node init
+	DEBUG_ERR(node->face_ids.size() != 0 || node->vertIds.size() != 0 || node->meshes.size() != 0); // vectors not empty. wrong node init
 
-	node->face_ids.resize( meshes.size() );
-	node->vertIds.resize( meshes.size() );
-	node->meshes.resize( meshes.size() );
+	node->face_ids.resize(meshes.size());
+	node->vertIds.resize(meshes.size());
+	node->meshes.resize(meshes.size());
 
-	for( uint m=0; m<meshes.size(); m++ )
+	for(uint m=0; m<meshes.size(); m++)
 	{
 		Mesh* cmesh = meshes[m];
 
@@ -57,8 +57,8 @@ void octree_t::CreateRoot( const Vec<Mesh*>& meshes )
 		node->meshes[m] = cmesh;
 
 		// then set the face_ids
-		node->face_ids[m].resize( cmesh->tris.size() );
-		for( uint f=0; f<cmesh->tris.size(); f++ )
+		node->face_ids[m].resize(cmesh->tris.size());
+		for(uint f=0; f<cmesh->tris.size(); f++)
 			node->face_ids[m][f] = f; // simple as taking a shit
 
 		// and last the verts
@@ -78,7 +78,7 @@ GetFacesNum
 uint octree_t::node_t::GetFacesNum() const
 {
 	int count = 0;
-	for( uint i=0; i<meshes.size(); i++ )
+	for(uint i=0; i<meshes.size(); i++)
 	{
 		count += meshes[i]->tris.size();
 	}
@@ -93,9 +93,9 @@ returns true when the used difined heuristic is met that sais that we can subdiv
 we can subdivide the node further                                                                                      =
 =======================================================================================================================================
 */
-bool octree_t::IsSubdivHeuristicMet( node_t* node ) const
+bool octree_t::IsSubdivHeuristicMet(node_t* node) const
 {
-	if( node->GetFacesNum() < 100 ) return false;
+	if(node->GetFacesNum() < 100) return false;
 
 	return true;
 }
@@ -108,16 +108,16 @@ SubdivideNode
 subdivides the node and creates max 8 children and then subdivides the children                                        =
 =======================================================================================================================================
 */
-void octree_t::SubdivideNode( node_t* node )
+void octree_t::SubdivideNode(node_t* node)
 {
-	if( !IsSubdivHeuristicMet(node) ) return;
+	if(!IsSubdivHeuristicMet(node)) return;
 
 	// subdivide the children
-	for( int i=0; i<8; i++ )
+	for(int i=0; i<8; i++)
 	{
-		if( node->childs[i] == NULL ) continue;
+		if(node->childs[i] == NULL) continue;
 
-		SubdivideNode( node->childs[i] );
+		SubdivideNode(node->childs[i]);
 	}
 }
 
@@ -127,10 +127,10 @@ void octree_t::SubdivideNode( node_t* node )
 CreateTree                                                                                                             =
 =======================================================================================================================================
 */
-void octree_t::CreateTree( const Vec<Mesh*>& meshes )
+void octree_t::CreateTree(const Vec<Mesh*>& meshes)
 {
-	CreateRoot( meshes );
-	SubdivideNode( root );
+	CreateRoot(meshes);
+	SubdivideNode(root);
 }
 
 
@@ -141,20 +141,20 @@ the func checks the node and returns if its inside the cameras fruntum. It retur
 inside and 2 if totaly inside                                                                                          =
 =======================================================================================================================================
 */
-uint octree_t::CheckNodeAgainstFrustum( node_t* node, const Camera& cam ) const
+uint octree_t::CheckNodeAgainstFrustum(node_t* node, const Camera& cam) const
 {
 	int points_outside_frustum_num = 0;
 	const aabb_t& box = node->bounding_box;
 	Vec3 box_points[] = { box.max, Vec3(box.min.x, box.max.y, box.max.z), Vec3(box.min.x, box.min.y, box.max.z), Vec3(box.max.x, box.min.y, box.max.z),
 	                        box.min, Vec3(box.min.x, box.max.y, box.min.z), Vec3(box.min.x, box.min.y, box.min.z), Vec3(box.max.x, box.min.y, box.min.z), };
 
-	for( int i=0; i<8; i++ )
+	for(int i=0; i<8; i++)
 	{
-		for( int j=0; j<6; j++ )
+		for(int j=0; j<6; j++)
 		{
 			const plane_t& plane = cam.wspaceFrustumPlanes[j];
 
-			if( plane.Test( box_points[i] ) < 0.0  )
+			if(plane.Test(box_points[i]) < 0.0)
 			{
 				++points_outside_frustum_num;
 				continue;
@@ -162,8 +162,8 @@ uint octree_t::CheckNodeAgainstFrustum( node_t* node, const Camera& cam ) const
 		}
 	}
 
-	if( points_outside_frustum_num == 8 ) return 0;
-	if( points_outside_frustum_num < 8 ) return 1;
+	if(points_outside_frustum_num == 8) return 0;
+	if(points_outside_frustum_num < 8) return 1;
 	return 2;
 }
 
@@ -181,28 +181,28 @@ map
 load                                                                                                                   =
 =======================================================================================================================================
 */
-bool map_t::load( const char* filename )
+bool map_t::load(const char* filename)
 {
-	DEBUG_ERR( meshes.size() != 0 ); // meshes vector should be empty
+	DEBUG_ERR(meshes.size() != 0); // meshes vector should be empty
 
 	Scanner scanner;
 	const Scanner::Token* token;
-	if( !scanner.loadFile( filename ) ) return false;
+	if(!scanner.loadFile(filename)) return false;
 
 	do
 	{
 		token = &scanner.getNextToken();
 
 		// strings is what we want in this case... please let it be G-Strings
-		if( token->getCode() == Scanner::TC_STRING )
+		if(token->getCode() == Scanner::TC_STRING)
 		{
-			Mesh* mesh = Rsrc::meshes.load( token->getValue().getString() );
-			if( !mesh ) return false;
+			Mesh* mesh = Rsrc::meshes.load(token->getValue().getString());
+			if(!mesh) return false;
 
-			meshes.push_back( mesh );
+			meshes.push_back(mesh);
 		}
 		// end of file
-		else if( token->getCode() == Scanner::TC_EOF )
+		else if(token->getCode() == Scanner::TC_EOF)
 		{
 			break;
 		}
@@ -213,7 +213,7 @@ bool map_t::load( const char* filename )
 			return false;
 		}
 
-	}while( true );
+	}while(true);
 
 	return true;
 }

+ 7 - 7
src/Misc/map.h

@@ -38,17 +38,17 @@ class octree_t
 
 	protected:
 		// funcs for the tree creation
-		bool IsSubdivHeuristicMet( node_t* node ) const;
-		void SubdivideNode( node_t* node );
-		void CreateRoot( const Vec<Mesh*>& meshes );
+		bool IsSubdivHeuristicMet(node_t* node) const;
+		void SubdivideNode(node_t* node);
+		void CreateRoot(const Vec<Mesh*>& meshes);
 
 		// frustum funcs
-		uint CheckNodeAgainstFrustum( node_t* node, const Camera& cam ) const;
+		uint CheckNodeAgainstFrustum(node_t* node, const Camera& cam) const;
 
 	public:
 		node_t* root;
 
-		void CreateTree( const Vec<Mesh*>& meshes );
+		void CreateTree(const Vec<Mesh*>& meshes);
 };
 
 
@@ -63,8 +63,8 @@ class map_t
 		Vec<Mesh*> meshes;
 		octree_t             octree;
 
-		bool load( const char* filename );
-		void CreateOctree() { DEBUG_ERR( meshes.size() < 1 ); octree.CreateTree(meshes); };
+		bool load(const char* filename);
+		void CreateOctree() { DEBUG_ERR(meshes.size() < 1); octree.CreateTree(meshes); };
 };
 
 

+ 166 - 166
src/Misc/memory.cpp

@@ -75,7 +75,7 @@ size_t free_size = buffer_size;
 
 // block stuff
 const int MAX_MEM_BLOCKS = 20*KILOBYTE;
-mem_block_t mem_blocks[ MAX_MEM_BLOCKS ]; // this is actualy a list
+mem_block_t mem_blocks[MAX_MEM_BLOCKS]; // this is actualy a list
 uint active_mem_blocks_num = 3;
 mem_block_t& head_node = mem_blocks[0];
 mem_block_t& tail_node = mem_blocks[1];
@@ -119,10 +119,10 @@ static int FreeBlocksNum()
 	int num = 0;
 	do
 	{
-		if( mb->free_space )
+		if(mb->free_space)
 			++num;
 		mb = mb->next;
-	} while( mb != &tail_node );
+	} while(mb != &tail_node);
 	return num;
 }
 
@@ -132,9 +132,9 @@ SetOwner
 set the file,func,line to the given block                                                                              =
 =======================================================================================================================================
 */
-static inline void SetOwner( mem_block_t* mb, mblock_owner_t* owner )
+static inline void SetOwner(mem_block_t* mb, mblock_owner_t* owner)
 {
-	DEBUG_ERR( mb == &head_node || mb == &tail_node ); // shouldn't change the head_node or tail node
+	DEBUG_ERR(mb == &head_node || mb == &tail_node); // shouldn't change the head_node or tail node
 	mb->owner.file = owner->file;
 	mb->owner.line = owner->line;
 	mb->owner.func = owner->func;
@@ -149,39 +149,39 @@ SanityChecks
 static bool SanityChecks()
 {
 	// the head_node
-	if( !(head_node.addr == NULL || head_node.size == 0 || head_node.prev == NULL || head_node.id == 0 ||
-	    head_node.active == true || head_node.free_space == false) )
-		MERROR( "In head_node" );
+	if(!(head_node.addr == NULL || head_node.size == 0 || head_node.prev == NULL || head_node.id == 0 ||
+	    head_node.active == true || head_node.free_space == false))
+		MERROR("In head_node");
 
 	// check the list
 	uint num = 0;
-	for( int i=0; i<MAX_MEM_BLOCKS; i++ )
-		if( mem_blocks[i].active ) ++num;
+	for(int i=0; i<MAX_MEM_BLOCKS; i++)
+		if(mem_blocks[i].active) ++num;
 
-	if( active_mem_blocks_num != num ) MERROR( "In mem_blocks list" );
+	if(active_mem_blocks_num != num) MERROR("In mem_blocks list");
 
 	// check the size
 	size_t size = 0;
 	mem_block_t* mb = head_node.next;
 	do
 	{
-		if( !mb->free_space )
+		if(!mb->free_space)
 			size += mb->size;
 
 		// the prev's next has to be ME and the next's prev has to show me also
-		if( mb->prev->next!=mb || mb->next->prev!=mb )
-			MERROR( "Chain is broken" );
+		if(mb->prev->next!=mb || mb->next->prev!=mb)
+			MERROR("Chain is broken");
 
-		if( mb->next!=&tail_node && ((char*)mb->addr)+mb->size!=mb->next->addr )
-			MERROR( "In crnt and next sizes cohisency" );
+		if(mb->next!=&tail_node && ((char*)mb->addr)+mb->size!=mb->next->addr)
+			MERROR("In crnt and next sizes cohisency");
 
-		if( mb->next == NULL || mb->prev==NULL )
-			MERROR( "Prev or next are NULL" );
+		if(mb->next == NULL || mb->prev==NULL)
+			MERROR("Prev or next are NULL");
 
 		mb = mb->next;
-	} while( mb!=&tail_node );
+	} while(mb!=&tail_node);
 
-	if( size != buffer_size-free_size ) MERROR( "In size" );
+	if(size != buffer_size-free_size) MERROR("In size");
 
 	return true;
 }
@@ -192,16 +192,16 @@ static bool SanityChecks()
 BytesStr                                                                                                               =
 =======================================================================================================================================
 */
-static char* BytesStr( size_t size )
+static char* BytesStr(size_t size)
 {
 	static char str[10];
 
-	if( size > MEGABYTE )
-		sprintf( str, "%dMB", (uint)(size/MEGABYTE) );
-	else if( size > KILOBYTE )
-		sprintf( str, "%dKB", (uint)(size/KILOBYTE) );
+	if(size > MEGABYTE)
+		sprintf(str, "%dMB", (uint)(size/MEGABYTE));
+	else if(size > KILOBYTE)
+		sprintf(str, "%dKB", (uint)(size/KILOBYTE));
 	else
-		sprintf( str, "%dB ", (uint)(size) );
+		sprintf(str, "%dB ", (uint)(size));
 	return str;
 }
 
@@ -211,13 +211,13 @@ static char* BytesStr( size_t size )
 printBlockInfo                                                                                                         =
 =======================================================================================================================================
 */
-static void printBlockInfo( const mem_block_t* mb )
+static void printBlockInfo(const mem_block_t* mb)
 {
 	const char cond = (mb->free_space) ? 'F' : 'U';
-	cout << setw(4) << setfill(' ') << mb->id << setw(0) << ' ' << cond << ' ' << setw(6) <<  BytesStr( mb->size ) << setw(0) << hex <<
+	cout << setw(4) << setfill(' ') << mb->id << setw(0) << ' ' << cond << ' ' << setw(6) <<  BytesStr(mb->size) << setw(0) << hex <<
 	     " 0x" << mb->addr << dec;
 
-	if( cond=='U' ) cout << " " << mb->owner.file << ' ' << mb->owner.line << ' ' << mb->owner.func;
+	if(cond=='U') cout << " " << mb->owner.file << ' ' << mb->owner.line << ' ' << mb->owner.func;
 
 	cout << endl;
 }
@@ -228,12 +228,12 @@ static void printBlockInfo( const mem_block_t* mb )
 printInfo                                                                                                              =
 =======================================================================================================================================
 */
-void printInfo( uint flags )
+void printInfo(uint flags)
 {
 	cout << "\n=========================== MEM REPORT =========================" << endl;
 
 	// header
-	if( (flags & PRINT_ALL)==PRINT_ALL || (flags & PRINT_HEADER)==PRINT_HEADER )
+	if((flags & PRINT_ALL)==PRINT_ALL || (flags & PRINT_HEADER)==PRINT_HEADER)
 	{
 		cout << "Used space: " << BytesStr(buffer_size-free_size) << "(" << buffer_size-free_size << ")";
 		cout << ", free: " << BytesStr(free_size) << " (" << free_size << ")";
@@ -248,12 +248,12 @@ void printInfo( uint flags )
 		mem_block_t* mb = &head_node;
 		do
 		{
-			if( tmp->free_space && tmp->size > mb->size )
+			if(tmp->free_space && tmp->size > mb->size)
 				mb = tmp;
 			tmp = tmp->next;
-		} while( tmp!=&tail_node );
+		} while(tmp!=&tail_node);
 
-		cout << "Block with max free space: " << mb->id << ", size: " << BytesStr( mb->size ) << " (" << mb->size << ")" << endl;
+		cout << "Block with max free space: " << mb->id << ", size: " << BytesStr(mb->size) << " (" << mb->size << ")" << endl;
 
 		// print how many times malloc,realloc etc have been called
 		cout << "Func calls: malloc:" << malloc_called_num << ", calloc:" << calloc_called_num << ", realloc:" << realloc_called_num <<
@@ -263,16 +263,16 @@ void printInfo( uint flags )
 	}
 
 	// blocks
-	if( (flags & PRINT_ALL)==PRINT_ALL || (flags & PRINT_BLOCKS)==PRINT_BLOCKS )
+	if((flags & PRINT_ALL)==PRINT_ALL || (flags & PRINT_BLOCKS)==PRINT_BLOCKS)
 	{
 		cout << "Block table (id, type, size [, file, line, func]):" << endl;
 
 		mem_block_t* mb = head_node.next;
 		do
 		{
-			printBlockInfo( mb );
+			printBlockInfo(mb);
 			mb = mb->next;
-		} while( mb!=&tail_node );
+		} while(mb!=&tail_node);
 	}
 
 	cout << "================================================================\n" << endl;
@@ -287,7 +287,7 @@ init
 static void init()
 {
 #ifdef DEBUG_ENABLED
-	memset( buffer, (char)0xCC, buffer_size );
+	memset(buffer, (char)0xCC, buffer_size);
 #endif
 
 	// mem block stuff
@@ -320,8 +320,8 @@ static void init()
 	mem_blocks[2].free_space = true;
 
 	// set the rest
-	memset( &mem_blocks[3], 0, sizeof(mem_block_t)*(MAX_MEM_BLOCKS-3) );
-	for( int i=3; i<MAX_MEM_BLOCKS; i++ )
+	memset(&mem_blocks[3], 0, sizeof(mem_block_t)*(MAX_MEM_BLOCKS-3));
+	for(int i=3; i<MAX_MEM_BLOCKS; i++)
 	{
 		mem_blocks[i].id = i;
 	}
@@ -339,14 +339,14 @@ thread stuff
 */
 static void Lock()
 {
-	if( SDL_SemWait(semaphore)==-1 )
-		MERROR( "Cant lock semaphore" );
+	if(SDL_SemWait(semaphore)==-1)
+		MERROR("Cant lock semaphore");
 }
 
 static void Unlock()
 {
-	if( SDL_SemPost(semaphore)==-1 )
-		MERROR( "Cant unlock semaphore" );
+	if(SDL_SemPost(semaphore)==-1)
+		MERROR("Cant unlock semaphore");
 }
 
 
@@ -355,19 +355,19 @@ static void Unlock()
 Enable                                                                                                                 =
 =======================================================================================================================================
 */
-void Enable( uint flags )
+void Enable(uint flags)
 {
-	if( (flags & THREADS)==THREADS )
+	if((flags & THREADS)==THREADS)
 	{
 		p_Lock = Lock;
 		p_Unlock = Unlock;
 	}
 
-	if( (flags & PRINT_ERRORS)==PRINT_ERRORS )
+	if((flags & PRINT_ERRORS)==PRINT_ERRORS)
 		print_errors = true;
 
 
-	if( (flags & PRINT_CALL_INFO)==PRINT_CALL_INFO )
+	if((flags & PRINT_CALL_INFO)==PRINT_CALL_INFO)
 		print_call_info = true;
 }
 
@@ -377,18 +377,18 @@ void Enable( uint flags )
 Disable                                                                                                                =
 =======================================================================================================================================
 */
-void Disable( uint flags )
+void Disable(uint flags)
 {
-	if( (flags & THREADS)==THREADS )
+	if((flags & THREADS)==THREADS)
 	{
 		p_Lock = DummyFunc;
 		p_Unlock = DummyFunc;
 	}
 
-	if( (flags & PRINT_ERRORS)==PRINT_ERRORS )
+	if((flags & PRINT_ERRORS)==PRINT_ERRORS)
 		print_errors = false;
 
-	if( (flags & PRINT_CALL_INFO)==PRINT_CALL_INFO )
+	if((flags & PRINT_CALL_INFO)==PRINT_CALL_INFO)
 		print_call_info = false;
 }
 
@@ -399,17 +399,17 @@ GetBlock
 find the active block who has for addr the given ptr param. Func used by free and realloc                              =
 =======================================================================================================================================
 */
-static mem_block_t* GetBlock( void* ptr )
+static mem_block_t* GetBlock(void* ptr)
 {
-	//if( ptr<buffer || ptr>((char*)buffer+buffer_size) ) return &head_node;
+	//if(ptr<buffer || ptr>((char*)buffer+buffer_size)) return &head_node;
 
 	mem_block_t* mb = tail_node.prev;
 	do
 	{
-		if( mb->addr==ptr )
+		if(mb->addr==ptr)
 			return mb;
 		mb = mb->prev;
-	} while( mb!=&head_node );
+	} while(mb!=&head_node);
 
 	return NULL;
 
@@ -424,21 +424,21 @@ static mem_block_t* GetBlock( void* ptr )
 //		int tmp = (a+b)/2;
 //
 //		// move the mb to crnt_pos
-//		if( pos < tmp )
-//			for( int i=0; i<tmp-pos; i++ )
+//		if(pos < tmp)
+//			for(int i=0; i<tmp-pos; i++)
 //				mb = mb->next;
 //		else
-//			for( int i=0; i<pos-tmp; i++ )
+//			for(int i=0; i<pos-tmp; i++)
 //				mb = mb->prev;
 //		pos = tmp;
 //
-//		if( ptr < mb->addr )
+//		if(ptr < mb->addr)
 //			b = pos;
-//		else if( ptr > mb->addr )
+//		else if(ptr > mb->addr)
 //			a = pos;
 //		else
 //			return mb;
-//		if( b-a < 2 ) break;
+//		if(b-a < 2) break;
 //	}
 //
 //	return NULL;
@@ -453,13 +453,13 @@ get an inactive node/block
 */
 static mem_block_t* GetInactiveBlock()
 {
-	for( int i=2; i<MAX_MEM_BLOCKS; i++ )
+	for(int i=2; i<MAX_MEM_BLOCKS; i++)
 	{
-		if( !mem_blocks[i].active )
+		if(!mem_blocks[i].active)
 			return &mem_blocks[i];
 	}
 
-	FATAL( "Cannot find an inactive node. Inc the mem_blocks arr" );
+	FATAL("Cannot find an inactive node. Inc the mem_blocks arr");
 	return NULL;
 }
 
@@ -470,16 +470,16 @@ WorstFit
 "worst fit" algorithm. It returns the block with the biger free space                                                  =
 =======================================================================================================================================
 */
-static mem_block_t* WorstFit( size_t size )
+static mem_block_t* WorstFit(size_t size)
 {
 	mem_block_t* tmp = tail_node.prev;
 	mem_block_t* candidate = &head_node;
 	do
 	{
-		if( tmp->size > candidate->size && tmp->free_space )
+		if(tmp->size > candidate->size && tmp->free_space)
 			candidate = tmp;
 		tmp = tmp->prev;
-	} while( tmp!=&head_node );
+	} while(tmp!=&head_node);
 
 	return candidate;
 }
@@ -490,7 +490,7 @@ static mem_block_t* WorstFit( size_t size )
 BestFit                                                                                                                =
 =======================================================================================================================================
 */
-static mem_block_t* BestFit( size_t size )
+static mem_block_t* BestFit(size_t size)
 {
 	mem_block_t* tmp = tail_node.prev;
 	mem_block_t* candidate = &head_node;
@@ -498,28 +498,28 @@ static mem_block_t* BestFit( size_t size )
 	// find a free block firstly
 	do
 	{
-		if( tmp->free_space )
+		if(tmp->free_space)
 		{
 			candidate = tmp;
 			break;
 		}
 		tmp = tmp->prev;
-	} while( tmp!=&head_node );
+	} while(tmp!=&head_node);
 
-	if( candidate == &head_node ) return candidate; // we failed to find free node
+	if(candidate == &head_node) return candidate; // we failed to find free node
 
 	// now run the real deal
 	do
 	{
-		if( tmp->free_space )
+		if(tmp->free_space)
 		{
-			if( (tmp->size < candidate->size) && (tmp->size > size) )
+			if((tmp->size < candidate->size) && (tmp->size > size))
 				candidate = tmp;
-			else if( tmp->size == size )
+			else if(tmp->size == size)
 				return tmp;
 		}
 		tmp = tmp->prev;
-	} while( tmp!=&head_node );
+	} while(tmp!=&head_node);
 
 	return candidate;
 }
@@ -530,15 +530,15 @@ static mem_block_t* BestFit( size_t size )
 BadFit                                                                                                                 =
 =======================================================================================================================================
 */
-static mem_block_t* BadFit( size_t size )
+static mem_block_t* BadFit(size_t size)
 {
 	mem_block_t* tmp = tail_node.prev;
 	do
 	{
-		if( tmp->size >= size && tmp->free_space )
+		if(tmp->size >= size && tmp->free_space)
 			return tmp;
 		tmp = tmp->prev;
-	} while( tmp!=&head_node );
+	} while(tmp!=&head_node);
 
 	return &head_node;
 }
@@ -550,14 +550,14 @@ NewBlock
 just free the given block                                                                                              =
 =======================================================================================================================================
 */
-static mem_block_t* NewBlock( size_t size )
+static mem_block_t* NewBlock(size_t size)
 {
 	p_Init();
 
 	// a simple check
-	if( size < 1 )
+	if(size < 1)
 	{
-		MERROR( "Size is < 1" );
+		MERROR("Size is < 1");
 		return &head_node;
 	}
 
@@ -566,17 +566,17 @@ static mem_block_t* NewBlock( size_t size )
 
 	// use an algorithm to find the best candidate
 	mem_block_t* candidate = BestFit(size);
-	if( candidate==&head_node )
+	if(candidate==&head_node)
 	{
-		FATAL( "There are no free blocks" );
+		FATAL("There are no free blocks");
 		return &head_node;
 	}
 
 	// case 0: we have found a big enought free block
-	if( candidate->size > size )
+	if(candidate->size > size)
 	{
 		// reorganize the prev and the next of the 3 involved blocks
-		DEBUG_ERR( candidate->prev==NULL );
+		DEBUG_ERR(candidate->prev==NULL);
 		candidate->prev->next = newmb;
 		newmb->prev = candidate->prev;
 		newmb->next = candidate;
@@ -594,15 +594,15 @@ static mem_block_t* NewBlock( size_t size )
 		++active_mem_blocks_num;
 	}
 	// case 1: we have found a block with the exchact space
-	else if( candidate->size == size )
+	else if(candidate->size == size)
 	{
 		newmb = candidate;
 		newmb->free_space = false;
 	}
 	// case 2: we cannot find a block!!!
-	else // if( max_free_bytes < bytes )
+	else // if(max_free_bytes < bytes)
 	{
-		FATAL( "Cant find block with " << size << " free space. Inc buffer" );
+		FATAL("Cant find block with " << size << " free space. Inc buffer");
 		return &head_node;
 	}
 
@@ -616,21 +616,21 @@ static mem_block_t* NewBlock( size_t size )
 FreeBlock                                                                                                              =
 =======================================================================================================================================
 */
-static void FreeBlock( mem_block_t* crnt )
+static void FreeBlock(mem_block_t* crnt)
 {
-	DEBUG_ERR( crnt->free_space || !crnt->active || crnt==&head_node || crnt==&tail_node ); // self explanatory
+	DEBUG_ERR(crnt->free_space || !crnt->active || crnt==&head_node || crnt==&tail_node); // self explanatory
 
 	free_size += crnt->size;
 
 #ifdef DEBUG_ENABLED
-	memset( crnt->addr, (char)0xCC, crnt->size );
+	memset(crnt->addr, (char)0xCC, crnt->size);
 #endif
 
 	// rearange the blocks
 	mem_block_t* prev = crnt->prev;
 	mem_block_t* next = crnt->next;
 	// if we have a prev block with free space we resize the prev and then we remove the current one
-	if( prev != &head_node && prev->free_space )
+	if(prev != &head_node && prev->free_space)
 	{
 		prev->size += crnt->size;
 		prev->next = next;
@@ -646,7 +646,7 @@ static void FreeBlock( mem_block_t* crnt )
 	}
 
 	// if we have a next block with free space we resize the next and then we remove the crnt one
-	if( next != &tail_node && next->free_space )
+	if(next != &tail_node && next->free_space)
 	{
 		next->addr = crnt->addr;
 		next->size += crnt->size;
@@ -668,24 +668,24 @@ ReallocBlock
 it gets the block we want to realloc and returns the reallocated (either the same or a new)                            =
 =======================================================================================================================================
 */
-static mem_block_t* ReallocBlock( mem_block_t* crnt, size_t size )
+static mem_block_t* ReallocBlock(mem_block_t* crnt, size_t size)
 {
-	DEBUG_ERR( crnt->free_space || !crnt->active || crnt==&head_node || crnt==&tail_node ); // self explanatory
+	DEBUG_ERR(crnt->free_space || !crnt->active || crnt==&head_node || crnt==&tail_node); // self explanatory
 
 
 	// case 0: If size is 0 and p points to an existing block of memory, the memory block pointed by ptr is deallocated and a NULL...
 	// ...pointer is returned.(ISO behaviour)
-	if( size==0 )
+	if(size==0)
 	{
-		FreeBlock( crnt );
+		FreeBlock(crnt);
 		crnt = &head_node;
 	}
 	// case 1: we want more space
-	else if( size > crnt->size )
+	else if(size > crnt->size)
 	{
 		mem_block_t* next = crnt->next;
 		// case 1.0: the next block has enough space. Then we eat from the next
-		if( next!=&tail_node && next->free_space && next->size >= size )
+		if(next!=&tail_node && next->free_space && next->size >= size)
 		{
 			free_size -= size - crnt->size;
 			next->addr = ((char*)next->addr) + (size - crnt->size); // shift right the addr
@@ -695,22 +695,22 @@ static mem_block_t* ReallocBlock( mem_block_t* crnt, size_t size )
 		// case 1.1: We cannot eat from the next. Create new block and move the crnt's data there
 		else
 		{
-			mem_block_t* mb = NewBlock( size );
-			memcpy( mb->addr, crnt->addr, crnt->size );
-			FreeBlock( crnt );
+			mem_block_t* mb = NewBlock(size);
+			memcpy(mb->addr, crnt->addr, crnt->size);
+			FreeBlock(crnt);
 			crnt = mb;
 		}
 	}
 	// case 2: we want less space
-	else if( size < crnt->size )
+	else if(size < crnt->size)
 	{
 		mem_block_t* next = crnt->next;
 		// case 2.0: we have next
-		if( next!=&tail_node )
+		if(next!=&tail_node)
 		{
 			// case 2.0.0: the next block is free space...
 			// ...resize next and crnt
-			if( next->free_space )
+			if(next->free_space)
 			{
 				free_size -= size - crnt->size;
 				next->addr = ((char*)next->addr) - (crnt->size - size); // shl
@@ -761,14 +761,14 @@ static mem_block_t* ReallocBlock( mem_block_t* crnt, size_t size )
 Malloc                                                                                                                 =
 =======================================================================================================================================
 */
-static void* Malloc( size_t size, mblock_owner_t* owner=&unknown_owner )
+static void* Malloc(size_t size, mblock_owner_t* owner=&unknown_owner)
 {
 	p_Lock();
 
-	PRINT_CALL_INFO( "caller: \"" << owner->file << ':' << owner->line << "\", size: " << size );
+	PRINT_CALL_INFO("caller: \"" << owner->file << ':' << owner->line << "\", size: " << size);
 
-	mem_block_t* mb = NewBlock( size );
-	SetOwner( mb, owner );
+	mem_block_t* mb = NewBlock(size);
+	SetOwner(mb, owner);
 	SANITY_CHECKS
 
 	p_Unlock();
@@ -781,16 +781,16 @@ static void* Malloc( size_t size, mblock_owner_t* owner=&unknown_owner )
 Calloc                                                                                                                 =
 =======================================================================================================================================
 */
-static void* Calloc( size_t num, size_t size, mblock_owner_t* owner=&unknown_owner )
+static void* Calloc(size_t num, size_t size, mblock_owner_t* owner=&unknown_owner)
 {
 	p_Lock();
 
 
-	PRINT_CALL_INFO( "caller: \"" << owner->file << ':' << owner->line << "size: " << size );
+	PRINT_CALL_INFO("caller: \"" << owner->file << ':' << owner->line << "size: " << size);
 
-	mem_block_t* mb = NewBlock( num*size );
-	SetOwner( mb, owner);
-	memset( mb->addr, 0x00000000, num*size );
+	mem_block_t* mb = NewBlock(num*size);
+	SetOwner(mb, owner);
+	memset(mb->addr, 0x00000000, num*size);
 	SANITY_CHECKS
 
 	p_Unlock();
@@ -803,38 +803,38 @@ static void* Calloc( size_t num, size_t size, mblock_owner_t* owner=&unknown_own
 Realloc                                                                                                                =
 =======================================================================================================================================
 */
-static void* Realloc( void* ptr, size_t size, mblock_owner_t* owner=&unknown_owner )
+static void* Realloc(void* ptr, size_t size, mblock_owner_t* owner=&unknown_owner)
 {
 	p_Lock();
 
 	// ISO beheviur
-	if( ptr==NULL )
+	if(ptr==NULL)
 	{
 		p_Unlock();
-		return Malloc( size, owner );
+		return Malloc(size, owner);
 	}
 
 	// find the block we want to realloc
-	mem_block_t* mb = GetBlock( ptr );
+	mem_block_t* mb = GetBlock(ptr);
 
-	PRINT_CALL_INFO( "caller: \"" << owner->file << ':' << owner->line << "\", user: \"" << mb->owner.file << ':' << mb->owner.line <<
-		"\", new size: " << size );
+	PRINT_CALL_INFO("caller: \"" << owner->file << ':' << owner->line << "\", user: \"" << mb->owner.file << ':' << mb->owner.line <<
+		"\", new size: " << size);
 
-	if( mb==NULL )
+	if(mb==NULL)
 	{
-		MERROR( "Addr 0x" << hex << ptr << dec << " not found" );
+		MERROR("Addr 0x" << hex << ptr << dec << " not found");
 		p_Unlock();
 		return NULL;
 	}
-	if( mb->free_space  )
+	if(mb->free_space)
 	{
-		MERROR( "Addr 0x" << hex << ptr << dec << " is free space" );
+		MERROR("Addr 0x" << hex << ptr << dec << " is free space");
 		p_Unlock();
 		return NULL;
 	}
 
-	mem_block_t* crnt = ReallocBlock( mb, size );
-	SetOwner( crnt, owner );
+	mem_block_t* crnt = ReallocBlock(mb, size);
+	SetOwner(crnt, owner);
 	SANITY_CHECKS
 
 	p_Unlock();
@@ -847,29 +847,29 @@ static void* Realloc( void* ptr, size_t size, mblock_owner_t* owner=&unknown_own
 Free                                                                                                                   =
 =======================================================================================================================================
 */
-static void Free( void* ptr, mblock_owner_t* owner=&unknown_owner )
+static void Free(void* ptr, mblock_owner_t* owner=&unknown_owner)
 {
 	p_Lock();
 
 	// find the block we want to delete
-	mem_block_t* mb = GetBlock( ptr );
-	if( mb==NULL )
+	mem_block_t* mb = GetBlock(ptr);
+	if(mb==NULL)
 	{
-		MERROR( "Addr 0x" << hex << ptr << dec << " not found" );
+		MERROR("Addr 0x" << hex << ptr << dec << " not found");
 		p_Unlock();
 		return;
 	}
-	if( mb->free_space  )
+	if(mb->free_space)
 	{
-		MERROR( "Addr 0x" << hex << ptr << dec << " is free space" );
+		MERROR("Addr 0x" << hex << ptr << dec << " is free space");
 		p_Unlock();
 		return;
 	}
 
-	PRINT_CALL_INFO( "caller: \"" << owner->file << ':' << owner->line << "\", user: \"" << mb->owner.file << ':' << mb->owner.line
-		<< "\", mb size: " << mb->size );
+	PRINT_CALL_INFO("caller: \"" << owner->file << ':' << owner->line << "\", user: \"" << mb->owner.file << ':' << mb->owner.line
+		<< "\", mb size: " << mb->size);
 
-	FreeBlock( mb );
+	FreeBlock(mb);
 	SANITY_CHECKS
 
 	p_Unlock();
@@ -884,56 +884,56 @@ overloaded stuff
 */
 
 // malloc
-void* malloc( size_t size ) throw()
+void* malloc(size_t size) throw()
 {
 	++mem::malloc_called_num;
-	return mem::Malloc( size );
+	return mem::Malloc(size);
 }
 
 // realloc
-void* realloc( void* p, size_t size ) throw()
+void* realloc(void* p, size_t size) throw()
 {
 	++mem::realloc_called_num;
-	return mem::Realloc( p, size );
+	return mem::Realloc(p, size);
 }
 
 // calloc
-void* calloc( size_t num, size_t size ) throw()
+void* calloc(size_t num, size_t size) throw()
 {
 	++mem::calloc_called_num;
-	return mem::Calloc( num, size );
+	return mem::Calloc(num, size);
 }
 
 // free
-void free( void* p ) throw()
+void free(void* p) throw()
 {
 	++mem::free_called_num;
-	mem::Free( p );
+	mem::Free(p);
 }
 
 // new
-void* operator new( size_t size ) throw(std::bad_alloc)
+void* operator new(size_t size) throw(std::bad_alloc)
 {
 	++mem::new_called_num;
-	return mem::Malloc( size );
+	return mem::Malloc(size);
 }
 
 // new[]
-void* operator new[]( size_t size ) throw(std::bad_alloc)
+void* operator new[](size_t size) throw(std::bad_alloc)
 {
 	++mem::new_called_num;
-	return mem::Malloc( size );
+	return mem::Malloc(size);
 }
 
 // delete
-void operator delete( void* p ) throw()
+void operator delete(void* p) throw()
 {
 	++mem::delete_called_num;
 	mem::Free(p);
 }
 
 // delete []
-void operator delete[]( void* p ) throw()
+void operator delete[](void* p) throw()
 {
 	++mem::delete_called_num;
 	mem::Free(p);
@@ -947,67 +947,67 @@ overloaded stuff with owner
 */
 
 // malloc
-void* malloc( size_t size, const char* file, int line, const char* func )
+void* malloc(size_t size, const char* file, int line, const char* func)
 {
 	++mem::malloc_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	return mem::Malloc( size, &owner );
+	return mem::Malloc(size, &owner);
 }
 
 // realloc
-void* realloc( void* p, size_t size, const char* file, int line, const char* func )
+void* realloc(void* p, size_t size, const char* file, int line, const char* func)
 {
 	++mem::realloc_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	return mem::Realloc( p, size, &owner );
+	return mem::Realloc(p, size, &owner);
 }
 
 // calloc
-void* calloc( size_t num, size_t size, const char* file, int line, const char* func )
+void* calloc(size_t num, size_t size, const char* file, int line, const char* func)
 {
 	++mem::calloc_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	return mem::Calloc( num, size, &owner );
+	return mem::Calloc(num, size, &owner);
 }
 
 // free
-void free( void* p, const char* file, int line, const char* func )
+void free(void* p, const char* file, int line, const char* func)
 {
 	++mem::free_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	mem::Free( p, &owner );
+	mem::Free(p, &owner);
 }
 
 // new
-void* operator new( size_t size, const char* file, int line, const char* func )
+void* operator new(size_t size, const char* file, int line, const char* func)
 {
 	++mem::new_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	return mem::Malloc( size, &owner );
+	return mem::Malloc(size, &owner);
 }
 
 // new[]
-void* operator new[]( size_t size, const char* file, int line, const char* func )
+void* operator new[](size_t size, const char* file, int line, const char* func)
 {
 	++mem::new_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	return mem::Malloc( size, &owner );
+	return mem::Malloc(size, &owner);
 }
 
 // delete
-void operator delete( void* p, const char* file, int line, const char* func )
+void operator delete(void* p, const char* file, int line, const char* func)
 {
 	++mem::delete_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	mem::Free( p, &owner );
+	mem::Free(p, &owner);
 }
 
 // delete []
-void operator delete[]( void* p, const char* file, int line, const char* func )
+void operator delete[](void* p, const char* file, int line, const char* func)
 {
 	++mem::delete_called_num;
 	mem::mblock_owner_t owner = {file, line, func};
-	mem::Free( p, &owner );
+	mem::Free(p, &owner);
 }
 
 #endif // _USE_MEM_MANAGER_

+ 17 - 17
src/Misc/memory.h

@@ -24,9 +24,9 @@ extern size_t free_size;
 extern const size_t buffer_size;
 extern uint errors_num;
 
-extern void printInfo( uint flags=PRINT_ALL );
-extern void Enable( uint flags );
-extern void Disable( uint flags );
+extern void printInfo(uint flags=PRINT_ALL);
+extern void Enable(uint flags);
+extern void Disable(uint flags);
 
 } // end namespace
 
@@ -36,20 +36,20 @@ extern void Disable( uint flags );
 // MACROS
 #ifdef _USE_MEM_MANAGER_
 
-extern void* malloc( size_t size, const char* file, int line, const char* func );
-extern void* realloc( void* p, size_t size, const char* file, int line, const char* func );
-extern void* calloc( size_t num, size_t size, const char* file, int line, const char* func );
-extern void  free( void* p, const char* file, int line, const char* func );
-extern void* operator new( size_t size, const char* file, int line, const char* func );
-extern void* operator new[]( size_t size, const char* file, int line, const char* func );
-extern void  operator delete( void* p, const char* file, int line, const char* func );
-extern void  operator delete[]( void* p, const char* file, int line, const char* func );
-
-#define new new( __FILENAME__, __LINE__, __FUNCTION__ )
-#define malloc( x ) malloc( x, __FILENAME__, __LINE__, __FUNCTION__ )
-#define realloc( x, y ) realloc( x, y, __FILENAME__, __LINE__, __FUNCTION__ )
-#define calloc( x, y ) calloc( x, y, __FILENAME__, __LINE__, __FUNCTION__ )
-#define free(x) free( x, __FILENAME__, __LINE__, __FUNCTION__ )
+extern void* malloc(size_t size, const char* file, int line, const char* func);
+extern void* realloc(void* p, size_t size, const char* file, int line, const char* func);
+extern void* calloc(size_t num, size_t size, const char* file, int line, const char* func);
+extern void  free(void* p, const char* file, int line, const char* func);
+extern void* operator new(size_t size, const char* file, int line, const char* func);
+extern void* operator new[](size_t size, const char* file, int line, const char* func);
+extern void  operator delete(void* p, const char* file, int line, const char* func);
+extern void  operator delete[](void* p, const char* file, int line, const char* func);
+
+#define new new(__FILENAME__, __LINE__, __FUNCTION__)
+#define malloc(x) malloc(x, __FILENAME__, __LINE__, __FUNCTION__)
+#define realloc(x, y) realloc(x, y, __FILENAME__, __LINE__, __FUNCTION__)
+#define calloc(x, y) calloc(x, y, __FILENAME__, __LINE__, __FUNCTION__)
+#define free(x) free(x, __FILENAME__, __LINE__, __FUNCTION__)
 
 
 #endif

+ 0 - 219
src/Misc/particles.cpp

@@ -1,219 +0,0 @@
-/*
-#include "particles.h"
-#include "Renderer.h"
-#include "Util.h"
-
-using namespace std;
-
-#define MIN 0
-#define MAX 1
-#define VEL0 0
-#define VEL1 1
-
-
-=============================================================================================================================================================
-render @ particle_t                                                                                                                          =
-=============================================================================================================================================================
-
-void particle_t::render()
-{
-	if( !life ) return;
-	//glPointSize( 4.0 );
-	--life;
-
-	// calc new pos
-	float dt = ( float(App::timerTick)/1000 );
-	Vec3 s_vel; // sigma velocity
-	s_vel = Vec3( 0.0, 0.0, 0.0 );
-	for( int i=0; i<PARTICLE_VELS_NUM; i++ )
-	{
-		velocity[i] = (acceleration[i] * dt) + velocity[i];
-		s_vel += velocity[i];
-	}
-
-	translationLspace = s_vel * dt + translationLspace;
-
-	Quat q;
-	q.setFrom2Vec3( Vec3(1.0, 0.0, 0.0), s_vel );
-	rotationLspace = Mat3( q );
-
-	updateWorldTransform();
-
-
-	// draw the point
-	glColor3f( 1.0, 0.0, 0.0 );
-	glBegin( GL_POINTS );
-		glVertex3fv( &translationWspace[0] );
-	glEnd();
-
-	// draw axis
-	if( 1 )
-	{
-		glPushMatrix();
-		R::multMatrix( transformationWspace );
-
-		glBegin( GL_LINES );
-			// x-axis
-			glColor3f( 1.0, 0.0, 0.0 );
-			glVertex3f( 0.0, 0.0, 0.0 );
-			glVertex3f( 1.0, 0.0, 0.0 );
-			// y-axis
-			glColor3f( 0.0, 1.0, 0.0 );
-			glVertex3f( 0.0, 0.0, 0.0 );
-			glVertex3f( 0.0, 1.0, 0.0 );
-			// z-axis
-			glColor3f( 0.0, 0.0, 1.0 );
-			glVertex3f( 0.0, 0.0, 0.0 );
-			glVertex3f( 0.0, 0.0, 1.0 );
-		glEnd();
-
-		glPopMatrix();
-	}
-
-	// draw the velocities
-	if( 0 )
-	{
-		// draw the velocities
-		for( int i=0; i<PARTICLE_VELS_NUM; i++ )
-		{
-			glColor3f( 0.0, 0.0, 1.0 );
-			glBegin( GL_LINES );
-				glVertex3fv( &translationWspace[0] );
-				glVertex3fv( &(velocity[i]+translationWspace)[0] );
-			glEnd();
-		}
-
-		// draw the Sv
-		glColor3f( 1.0, 1.0, 1.0 );
-		glBegin( GL_LINES );
-			glVertex3fv( &translationWspace[0] );
-			glVertex3fv( &(s_vel+translationWspace)[0] );
-		glEnd();
-	}
-}
-
-
-
-=============================================================================================================================================================
-init @ particle_emitter_t                                                                                                                    =
-=============================================================================================================================================================
-
-void particle_emitter_t::init()
-{
-	particles.resize(200);
-
-	particle_life[0] = 200;
-	particle_life[1] = 400;
-	particles_per_frame = 1;
-
-	velocities[VEL0].angs[MIN] = Euler( 0.0, toRad(-30.0), toRad(10.0) );
-	velocities[VEL0].angs[MAX] = Euler( 0.0, toRad(30.0), toRad(45.0) );
-	velocities[VEL0].magnitude = 5.0f;
-	velocities[VEL0].acceleration_magnitude = -0.1f;
-	velocities[VEL0].rotatable = true;
-
-	velocities[VEL1].angs[MIN] = Euler( 0.0, 0.0, toRad(270.0) );
-	velocities[VEL1].angs[MAX] = Euler( 0.0, 0.0, toRad(270.0) );
-	velocities[VEL1].magnitude = 0.0f;
-	velocities[VEL1].acceleration_magnitude = 1.0f;
-	velocities[VEL1].rotatable = false;
-
-	particles_translation_lspace[0] = Vec3( 0.0, 0.0, 0.0 );
-	particles_translation_lspace[1] = Vec3( 0.0, 0.0, 0.0 );
-}
-
-
-
-==============================================================================================================================================================
-ReInitParticle @ particle_emitter_t                                                                                                           =
-==============================================================================================================================================================
-
-void particle_emitter_t::ReInitParticle( particle_t& particle )
-{
-	// life
-	particle.life = Util::randRange( particle_life[MIN], particle_life[MAX] );
-
-	// pos
-	particle.translationLspace = Vec3(
-		Util::randRange( particles_translation_lspace[MIN].x, particles_translation_lspace[MAX].x ),
-		Util::randRange( particles_translation_lspace[MIN].y, particles_translation_lspace[MAX].y ),
-		Util::randRange( particles_translation_lspace[MIN].z, particles_translation_lspace[MAX].z )
-	);
-	particle.rotationLspace = Mat3::getIdentity();
-	particle.scaleLspace = 1.0;
-
-	particle.parent = this;
-	particle.updateWorldTransform();
-
-	particle.translationLspace = particle.translationWspace;
-	particle.rotationLspace = particle.rotationWspace;
-	particle.scaleLspace = particle.scaleWspace;
-	particle.parent = NULL;
-
-	// initial velocities
-	for( int i=0; i<PARTICLE_VELS_NUM; i++ )
-	{
-		Euler tmp_angs = Euler(
-			Util::randRange( velocities[i].angs[MIN].x, velocities[i].angs[MAX].x ),
-			Util::randRange( velocities[i].angs[MIN].y, velocities[i].angs[MAX].y ),
-			Util::randRange( velocities[i].angs[MIN].z, velocities[i].angs[MAX].z )
-		);
-		Mat3 m3;
-		m3 = Mat3(tmp_angs);
-		if( velocities[i].rotatable ) m3 = rotationWspace * m3;
-		particle.velocity[i] = particle.acceleration[i] = m3 * Vec3( 1.0, 0.0, 0.0 );
-		particle.velocity[i] *= velocities[i].magnitude;
-		particle.acceleration[i] *= velocities[i].acceleration_magnitude;
-
-	}
-}
-
-
-
-=============================================================================================================================================================
-render @ particle_emitter_t                                                                                                                  =
-=============================================================================================================================================================
-
-void particle_emitter_t::render()
-{
-	updateWorldTransform();
-
-	// emitt new particles
-	int remain = particles_per_frame;
-	for( uint i=0; i<particles.size(); i++ )
-	{
-		if( particles[i].life != 0 ) continue;
-
-		ReInitParticle( particles[i] );
-
-		--remain;
-		if( remain == 0 ) break;
-	}
-
-	// render all particles
-	for( uint i=0; i<particles.size(); i++ )
-		particles[i].render();
-
-	// render the debug cube
-	if( 1 )
-	{
-		glEnable( GL_DEPTH_TEST );
-		glDisable( GL_TEXTURE_2D );
-		glDisable( GL_BLEND );
-		//glLineWidth( 2.0 );
-		glPolygonMode( GL_FRONT, GL_LINE );
-
-		glPushMatrix();
-
-		updateWorldTransform();
-		R::multMatrix( transformationWspace );
-
-		glColor3f( 0.0, 1.0, 0.0 );
-
-		R::dbg::renderCube();
-
-		glPolygonMode( GL_FRONT, GL_FILL );
-		glPopMatrix();
-	}
-}
-*/

+ 0 - 82
src/Misc/particles.h

@@ -1,82 +0,0 @@
-/*
-#ifndef _PARTICLES_H_
-#define _PARTICLES_H_
-
-#include "Common.h"
-#include "Math.h"
-#include "App.h"
-#include "object.h"
-
-#define PARTICLE_VELS_NUM 2
-
-
-===============================================================================================================================================================
-particle_t                                                                                                                                     =
-===============================================================================================================================================================
-
-class particle_t: public object_t
-{
-	public:
-		Vec3 velocity[PARTICLE_VELS_NUM];
-		Vec3 acceleration[PARTICLE_VELS_NUM];
-		int life; // frames to death
-
-		particle_t(): object_t(LIGHT) {life = 0;}
-
-		void render();
-		void renderDepth() {}
-};
-
-
-
-========
-particle_emitter_t
-========
-
-class particle_emitter_t: public object_t
-{
-	private:
-		struct velocity_t
-		{
-			Euler angs[2]; // MIN MAX
-			float   magnitude;
-			float   acceleration_magnitude;
-			bool    rotatable;
-			Vec3  vel[2];
-		};
-
-	public:
-		Vec<particle_t> particles;
-
-		int start_frame;
-		int stop_frame;
-		int frame;
-		bool repeat_emittion;
-		int particle_life[2];  // []
-		int particles_per_frame;
-
-		Vec3 particles_translation_lspace[2]; // []
-
-		// velocities
-		velocity_t velocities[PARTICLE_VELS_NUM];
-
-		//float initial_fade; // []
-		//int fade_frame;
-		//float fade_rate;
-		//
-		//float initial_size; // []
-		//int size_frame;
-		//float size_rate;
-
-
-		particle_emitter_t(): object_t(LIGHT) {}
-		~particle_emitter_t(){ particles.clear(); }
-
-		void init();
-		void ReInitParticle( particle_t& particle );
-		void render();
-		void renderDepth() {}
-};
-
-#endif
-*/

+ 28 - 28
src/Misc/skybox.cpp

@@ -31,18 +31,18 @@ static float coords [][4][3] =
 load                                                                                                                   =
 =======================================================================================================================================
 */
-bool Skybox::load( const char* filenames[6] )
+bool Skybox::load(const char* filenames[6])
 {
-	for( int i=0; i<6; i++ )
+	for(int i=0; i<6; i++)
 	{
-		textures[i] = Rsrc::textures.load( filenames[i] );
+		textures[i] = Rsrc::textures.load(filenames[i]);
 	}
 
-	noise = Rsrc::textures.load( "gfx/noise2.tga" );
-	noise->setTexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	noise->setTexParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+	noise = Rsrc::textures.load("gfx/noise2.tga");
+	noise->setTexParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
+	noise->setTexParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
 
-	shader = Rsrc::shaders.load( "shaders/ms_mp_skybox.glsl" );
+	shader = Rsrc::shaders.load("shaders/ms_mp_skybox.glsl");
 
 	return true;
 }
@@ -53,44 +53,44 @@ bool Skybox::load( const char* filenames[6] )
 render                                                                                                                 =
 =======================================================================================================================================
 */
-void Skybox::Render( const Mat3& rotation )
+void Skybox::Render(const Mat3& rotation)
 {
-	//glDisable( GL_DEPTH_TEST );
-	glDisable( GL_BLEND );
+	//glDisable(GL_DEPTH_TEST);
+	glDisable(GL_BLEND);
 
 	glPushMatrix();
 
 	shader->bind();
-	glUniform1i( shader->findUniVar("colormap")->getLoc(), 0 );
-	shader->findUniVar("noisemap")->setTexture( *noise, 1 );
-	glUniform1f( shader->findUniVar("timer")->getLoc(), (rotation_ang/(2*PI))*100 );
-	glUniform3fv( shader->findUniVar("sceneAmbientCol")->getLoc(), 1, &(Vec3( 1.0, 1.0, 1.0 ) / app->getScene()->getAmbientCol())[0] );
+	glUniform1i(shader->findUniVar("colormap")->getLoc(), 0);
+	shader->findUniVar("noisemap")->setTexture(*noise, 1);
+	glUniform1f(shader->findUniVar("timer")->getLoc(), (rotation_ang/(2*PI))*100);
+	glUniform3fv(shader->findUniVar("sceneAmbientCol")->getLoc(), 1, &(Vec3(1.0, 1.0, 1.0) / app->getScene()->getAmbientCol())[0]);
 
 	// set the rotation matrix
-	Mat3 tmp( rotation );
+	Mat3 tmp(rotation);
 	tmp.rotateYAxis(rotation_ang);
-	app->getMainRenderer()->loadMatrix( Mat4( tmp ) );
+	app->getMainRenderer()->loadMatrix(Mat4(tmp));
 
 	rotation_ang += 0.0001;
-	if( rotation_ang >= 2*PI ) rotation_ang = 0.0;
+	if(rotation_ang >= 2*PI) rotation_ang = 0.0;
 
 
 
 	const float ffac = 0.001; // fault factor. To eliminate the artefacts in the edge of the quads caused by texture filtering
-	float uvs [][2] = { {1.0-ffac,1.0-ffac}, {0.0+ffac,1.0-ffac}, {0.0+ffac,0.0+ffac}, {1.0-ffac,0.0+ffac} };
+	float uvs [][2] = { {1.0-ffac, 1.0-ffac}, {0.0+ffac, 1.0-ffac}, {0.0+ffac, 0.0+ffac}, {1.0-ffac, 0.0+ffac} };
 
-	for( int i=0; i<6; i++ )
+	for(int i=0; i<6; i++)
 	{
 		textures[i]->bind(0);
-		glBegin( GL_QUADS );
-			glTexCoord2fv( uvs[0] );
-			glVertex3fv( coords[i][0] );
-			glTexCoord2fv( uvs[1] );
-			glVertex3fv( coords[i][1] );
-			glTexCoord2fv( uvs[2] );
-			glVertex3fv( coords[i][2] );
-			glTexCoord2fv( uvs[3] );
-			glVertex3fv( coords[i][3] );
+		glBegin(GL_QUADS);
+			glTexCoord2fv(uvs[0]);
+			glVertex3fv(coords[i][0]);
+			glTexCoord2fv(uvs[1]);
+			glVertex3fv(coords[i][1]);
+			glTexCoord2fv(uvs[2]);
+			glVertex3fv(coords[i][2]);
+			glTexCoord2fv(uvs[3]);
+			glVertex3fv(coords[i][3]);
 		glEnd();
 	}
 

+ 2 - 2
src/Misc/skybox.h

@@ -29,8 +29,8 @@ class Skybox
 	public:
 		Skybox() { rotation_ang=0.0; }
 
-		bool load( const char* filenames[6] );
-		void Render( const Mat3& rotation );
+		bool load(const char* filenames[6]);
+		void Render(const Mat3& rotation);
 };
 
 

+ 10 - 10
src/Physics/MotionState.h

@@ -16,17 +16,17 @@ class MotionState: public btMotionState
 		SceneNode* node;
 
 	public:
-		MotionState( const btTransform& initialTransform, SceneNode* node_ ):
-			worldTransform( initialTransform ),
-			node( node_ )
+		MotionState(const btTransform& initialTransform, SceneNode* node_):
+			worldTransform(initialTransform),
+			node(node_)
 		{
-			DEBUG_ERR( node_==NULL );
+			DEBUG_ERR(node_==NULL);
 		}
 
 		virtual ~MotionState()
 		{}
 
-		virtual void getWorldTransform( btTransform& worldTrans ) const
+		virtual void getWorldTransform(btTransform& worldTrans) const
 		{
 			worldTrans = worldTransform;
 		}
@@ -36,18 +36,18 @@ class MotionState: public btMotionState
 			return worldTransform;
 		}
 
-		virtual void setWorldTransform( const btTransform& worldTrans )
+		virtual void setWorldTransform(const btTransform& worldTrans)
 		{
 			float originalScale = node->getLocalTransform().getScale();
 			worldTransform = worldTrans;
 
-			node->setLocalTransform( Transform( toAnki( worldTrans ) ) );
-			node->getLocalTransform().setScale( originalScale );
+			node->setLocalTransform(Transform(toAnki(worldTrans)));
+			node->getLocalTransform().setScale(originalScale);
 
 			/*btQuaternion rot = worldTrans.getRotation();
-			node->rotationLspace = Mat3( Quat( toAnki(rot) ) );
+			node->rotationLspace = Mat3(Quat(toAnki(rot)));
 			btVector3 pos = worldTrans.getOrigin();
-			node->translationLspace = Vec3( toAnki(pos) );*/
+			node->translationLspace = Vec3(toAnki(pos));*/
 		}
 };
 

+ 7 - 7
src/Physics/PhyCharacter.h

@@ -15,15 +15,15 @@ class PhyCharacter
 		btCapsuleShape* capsule;
 		btKinematicCharacterController* character;
 
-		PhyCharacter( PhyWorld* world, float charHeight, float charWidth, float stepHeight, float maxJumpHeight )
+		PhyCharacter(PhyWorld* world, float charHeight, float charWidth, float stepHeight, float maxJumpHeight)
 		{
 			ghostObject = new btPairCachingGhostObject();
-			world->broadphase->getOverlappingPairCache()->setInternalGhostPairCallback( new btGhostPairCallback() );
-			capsule = new btCapsuleShape( charWidth, charHeight );
-			ghostObject->setCollisionShape( capsule );
-			ghostObject->setCollisionFlags( btCollisionObject::CF_CHARACTER_OBJECT );
-			character = new btKinematicCharacterController( ghostObject, capsule, stepHeight );
-			character->setMaxJumpHeight( maxJumpHeight );
+			world->broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
+			capsule = new btCapsuleShape(charWidth, charHeight);
+			ghostObject->setCollisionShape(capsule);
+			ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
+			character = new btKinematicCharacterController(ghostObject, capsule, stepHeight);
+			character->setMaxJumpHeight(maxJumpHeight);
 		}
 
 

+ 22 - 22
src/Physics/PhyConversions.h

@@ -2,47 +2,47 @@
 #define _PHYCONVERSIONS_H_
 
 
-inline Vec3 toAnki( const btVector3& v )
+inline Vec3 toAnki(const btVector3& v)
 {
-	return Vec3( v.x(), v.y(), v.z() );
+	return Vec3(v.x(), v.y(), v.z());
 }
 
-inline Vec4 toAnki( const btVector4& v )
+inline Vec4 toAnki(const btVector4& v)
 {
-	return Vec4( v.x(), v.y(), v.z(), v.w() );
+	return Vec4(v.x(), v.y(), v.z(), v.w());
 }
 
-inline Mat3 toAnki( const btMatrix3x3& m )
+inline Mat3 toAnki(const btMatrix3x3& m)
 {
 	Mat3 m3;
-	m3.setRows( toAnki(m[0]), toAnki(m[1]), toAnki(m[2]) );
+	m3.setRows(toAnki(m[0]), toAnki(m[1]), toAnki(m[2]));
 	return m3;
 }
 
-inline Quat toAnki( const btQuaternion& q )
+inline Quat toAnki(const btQuaternion& q)
 {
-	return Quat( q.x(), q.y(), q.z(), q.w() );
+	return Quat(q.x(), q.y(), q.z(), q.w());
 }
 
-inline Mat4 toAnki( const btTransform& t )
+inline Mat4 toAnki(const btTransform& t)
 {
 	Mat4 m;
-	t.getOpenGLMatrix( &m[0] );
+	t.getOpenGLMatrix(&m[0]);
 	m.transpose();
 	return m;
 }
 
-inline btVector3 toBt( const Vec3& v )
+inline btVector3 toBt(const Vec3& v)
 {
-	return btVector3( v.x,  v.y, v.z );
+	return btVector3(v.x,  v.y, v.z);
 }
 
-inline btVector4 toBt( const Vec4& v )
+inline btVector4 toBt(const Vec4& v)
 {
-	return btVector4( v.x,  v.y, v.z, v.w );
+	return btVector4(v.x,  v.y, v.z, v.w);
 }
 
-inline btMatrix3x3 toBt( const Mat3 m )
+inline btMatrix3x3 toBt(const Mat3 m)
 {
 	btMatrix3x3 r;
 	r[0] = toBt(m.getRow(0));
@@ -51,23 +51,23 @@ inline btMatrix3x3 toBt( const Mat3 m )
 	return r;
 }
 
-inline btTransform toBt( const Mat4& m )
+inline btTransform toBt(const Mat4& m)
 {
 	btTransform r;
-	r.setFromOpenGLMatrix( &(m.getTransposed())[0] );
+	r.setFromOpenGLMatrix(&(m.getTransposed())[0]);
 	return r;
 }
 
-inline btQuaternion toBt( const Quat& q )
+inline btQuaternion toBt(const Quat& q)
 {
-	return btQuaternion( q.x, q.y, q.z, q.w );
+	return btQuaternion(q.x, q.y, q.z, q.w);
 }
 
-inline btTransform toBt( const Transform& trf )
+inline btTransform toBt(const Transform& trf)
 {
 	btTransform r;
-	r.setOrigin( toBt(trf.getOrigin()) );
-	r.setRotation( toBt( Quat(trf.getRotation()) ) );
+	r.setOrigin(toBt(trf.getOrigin()));
+	r.setRotation(toBt(Quat(trf.getRotation())));
 	return r;
 }
 

+ 13 - 13
src/Physics/PhyWorld.cpp

@@ -4,30 +4,30 @@
 //======================================================================================================================
 // createNewRigidBody                                                                                                  =
 //======================================================================================================================
-btRigidBody* PhyWorld::createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, SceneNode* node, int group,
-                                           int mask )
+btRigidBody* PhyWorld::createNewRigidBody(float mass, const Transform& startTransform, btCollisionShape* shape, SceneNode* node, int group,
+                                           int mask)
 {
-	DEBUG_ERR( shape==NULL || shape->getShapeType()==INVALID_SHAPE_PROXYTYPE );
+	DEBUG_ERR(shape==NULL || shape->getShapeType()==INVALID_SHAPE_PROXYTYPE);
 
 	//rigidbody is dynamic if and only if mass is non zero, otherwise static
 	bool isDynamic = (mass != 0.0);
 
-	btVector3 localInertia( 0, 0, 0 );
-	if( isDynamic )
-		shape->calculateLocalInertia( mass,localInertia );
+	btVector3 localInertia(0, 0, 0);
+	if(isDynamic)
+		shape->calculateLocalInertia(mass,localInertia);
 
 
-	MotionState* myMotionState = new MotionState( toBt(startTransform), node );
+	MotionState* myMotionState = new MotionState(toBt(startTransform), node);
 
-	btRigidBody::btRigidBodyConstructionInfo cInfo( mass, myMotionState, shape, localInertia );
+	btRigidBody::btRigidBodyConstructionInfo cInfo(mass, myMotionState, shape, localInertia);
 
-	btRigidBody* body = new btRigidBody( cInfo );
-	body->setContactProcessingThreshold( defaultContactProcessingThreshold );
+	btRigidBody* body = new btRigidBody(cInfo);
+	body->setContactProcessingThreshold(defaultContactProcessingThreshold);
 
-	if( mask==-1 & group==-1 )
-		dynamicsWorld->addRigidBody( body );
+	if(mask==-1 & group==-1)
+		dynamicsWorld->addRigidBody(body);
 	else
-		dynamicsWorld->addRigidBody( body, group, mask );
+		dynamicsWorld->addRigidBody(body, group, mask);
 
 	return body;
 }

+ 7 - 7
src/Physics/PhyWorld.h

@@ -9,8 +9,8 @@
  */
 class PhyWorld
 {
-	PROPERTY_R( btDiscreteDynamicsWorld*, dynamicsWorld, getDynamicsWorld )
-	PROPERTY_R( float, defaultContactProcessingThreshold, getDefaultContactProcessingThreshold )
+	PROPERTY_R(btDiscreteDynamicsWorld*, dynamicsWorld, getDynamicsWorld)
+	PROPERTY_R(float, defaultContactProcessingThreshold, getDefaultContactProcessingThreshold)
 
 	public:
 		btDefaultCollisionConfiguration* collisionConfiguration;
@@ -30,14 +30,14 @@ class PhyWorld
 
 
 		PhyWorld() :
-			defaultContactProcessingThreshold( BT_LARGE_FLOAT )
+			defaultContactProcessingThreshold(BT_LARGE_FLOAT)
 		{
 			collisionConfiguration = new btDefaultCollisionConfiguration();
 			dispatcher = new	btCollisionDispatcher(collisionConfiguration);
 			broadphase = new btDbvtBroadphase();
 			sol = new btSequentialImpulseConstraintSolver;
-			dynamicsWorld = new btDiscreteDynamicsWorld( dispatcher, broadphase, sol, collisionConfiguration );
-			dynamicsWorld->setGravity( btVector3(0,-10,0) );
+			dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, sol, collisionConfiguration);
+			dynamicsWorld->setGravity(btVector3(0,-10, 0));
 		}
 
 		/**
@@ -50,8 +50,8 @@ class PhyWorld
 		 * @param mask The mask of the body. Leave it blank if there is no mask
 		 * @return A new rigid body
 		 */
-		btRigidBody* createNewRigidBody( float mass, const Transform& startTransform, btCollisionShape* shape, SceneNode* node, int group=-1,
-		                                 int mask=-1 );
+		btRigidBody* createNewRigidBody(float mass, const Transform& startTransform, btCollisionShape* shape, SceneNode* node, int group=-1,
+		                                 int mask=-1);
 };
 
 #endif

+ 20 - 20
src/Renderer/BufferObjects/BufferObject.h

@@ -6,13 +6,13 @@
 
 
 /**
- * A wrapper for OpenGL buffer objects ( vertex arrays, texture buffers etc ) to prevent us from making idiotic errors
+ * A wrapper for OpenGL buffer objects (vertex arrays, texture buffers etc) to prevent us from making idiotic errors
  */
 class BufferObject
 {
 	protected:
 		uint glId; ///< The OpenGL id of the BO
-		GLenum target; ///< Used in glBindBuffer( target, glId ) and its for easy access so we wont have to query the GL driver
+		GLenum target; ///< Used in glBindBuffer(target, glId) and its for easy access so we wont have to query the GL driver
 		GLenum usage; ///< GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW
 
 	public:
@@ -25,7 +25,7 @@ class BufferObject
 		 */
 		uint getGlId() const
 		{
-			DEBUG_ERR( !isCreated() );
+			DEBUG_ERR(!isCreated());
 			return glId;
 		}
 
@@ -35,7 +35,7 @@ class BufferObject
 		 */
 		GLenum getBufferTarget() const
 		{
-			DEBUG_ERR( !isCreated() );
+			DEBUG_ERR(!isCreated());
 			return target;
 		}
 
@@ -45,7 +45,7 @@ class BufferObject
 		 */
 		GLenum getBufferUsage() const
 		{
-			DEBUG_ERR( !isCreated() );
+			DEBUG_ERR(!isCreated());
 			return usage;
 		}
 
@@ -66,26 +66,26 @@ class BufferObject
 		 * @param usage_ It should be: GL_STREAM_DRAW or GL_STATIC_DRAW or GL_DYNAMIC_DRAW only!!!!!!!!!
 		 * @return True on success
 		 */
-		bool create( GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_ )
+		bool create(GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_)
 		{
-			DEBUG_ERR( isCreated() ); // BO already initialized
-			DEBUG_ERR( usage_!=GL_STREAM_DRAW && usage_!=GL_STATIC_DRAW && usage_!=GL_DYNAMIC_DRAW ); // unacceptable usage_
-			DEBUG_ERR( sizeInBytes < 1 ); // unacceptable sizeInBytes
+			DEBUG_ERR(isCreated()); // BO already initialized
+			DEBUG_ERR(usage_!=GL_STREAM_DRAW && usage_!=GL_STATIC_DRAW && usage_!=GL_DYNAMIC_DRAW); // unacceptable usage_
+			DEBUG_ERR(sizeInBytes < 1); // unacceptable sizeInBytes
 
 			usage = usage_;
 			target = target_;
 
-			glGenBuffers( 1, &glId );
+			glGenBuffers(1, &glId);
 			bind();
-			glBufferData( target, sizeInBytes, dataPtr, usage );
+			glBufferData(target, sizeInBytes, dataPtr, usage);
 
 			// make a check
 			int bufferSize = 0;
-			glGetBufferParameteriv( target, GL_BUFFER_SIZE, &bufferSize );
-			if( sizeInBytes != (uint)bufferSize )
+			glGetBufferParameteriv(target, GL_BUFFER_SIZE, &bufferSize);
+			if(sizeInBytes != (uint)bufferSize)
 			{
 				deleteBuff();
-				ERROR( "Data size mismatch" );
+				ERROR("Data size mismatch");
 				return false;
 			}
 
@@ -98,8 +98,8 @@ class BufferObject
 		 */
 		void bind() const
 		{
-			DEBUG_ERR( !isCreated() );
-			glBindBuffer( target, glId );
+			DEBUG_ERR(!isCreated());
+			glBindBuffer(target, glId);
 		}
 
 		/**
@@ -107,8 +107,8 @@ class BufferObject
 		 */
 		void unbind() const
 		{
-			DEBUG_ERR( !isCreated() );
-			glBindBuffer( target, 0 );
+			DEBUG_ERR(!isCreated());
+			glBindBuffer(target, 0);
 		}
 
 		/**
@@ -116,8 +116,8 @@ class BufferObject
 		 */
 		void deleteBuff()
 		{
-			DEBUG_ERR( !isCreated() );
-			glDeleteBuffers( 1, &glId );
+			DEBUG_ERR(!isCreated());
+			glDeleteBuffers(1, &glId);
 			glId = 0;
 		}
 };

+ 16 - 16
src/Renderer/BufferObjects/Fbo.h

@@ -8,7 +8,7 @@
 /// The class is created as a wrapper to avoid common mistakes
 class Fbo
 {
-	PROPERTY_R( uint, glId, getGlId ) ///< OpenGL identification
+	PROPERTY_R(uint, glId, getGlId) ///< OpenGL identification
 
 	public:
 		Fbo(): glId(0) {}
@@ -16,19 +16,19 @@ class Fbo
 		/// Creates a new FBO
 		void create()
 		{
-			DEBUG_ERR( glId != 0 ); // FBO already initialized
-			glGenFramebuffers( 1, &glId );
+			DEBUG_ERR(glId != 0); // FBO already initialized
+			glGenFramebuffers(1, &glId);
 		}
 
 		/// Binds FBO
 		void bind() const
 		{
-			DEBUG_ERR( glId == 0 );  // FBO unitialized
-			glBindFramebuffer( GL_FRAMEBUFFER, glId );
+			DEBUG_ERR(glId == 0);  // FBO unitialized
+			glBindFramebuffer(GL_FRAMEBUFFER, glId);
 		}
 
 		/// Unbinds the FBO. Actualy unbinds all FBOs
-		static void unbind() { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); }
+		static void unbind() { glBindFramebuffer(GL_FRAMEBUFFER, 0); }
 
 		/**
 		 * Checks the status of an initialized FBO
@@ -36,22 +36,22 @@ class Fbo
 		 */
 		bool isGood() const
 		{
-			DEBUG_ERR( glId == 0 );  // FBO unitialized
-			DEBUG_ERR( getCurrentFbo() != glId ); // another FBO is binded
+			DEBUG_ERR(glId == 0);  // FBO unitialized
+			DEBUG_ERR(getCurrentFbo() != glId); // another FBO is binded
 
 			return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
 		}
 
 		/// Set the number of color attachements of the FBO
-		void setNumOfColorAttachements( uint num ) const
+		void setNumOfColorAttachements(uint num) const
 		{
-			DEBUG_ERR( glId == 0 );  // FBO unitialized
-			DEBUG_ERR( getCurrentFbo() != glId ); // another FBO is binded
+			DEBUG_ERR(glId == 0);  // FBO unitialized
+			DEBUG_ERR(getCurrentFbo() != glId); // another FBO is binded
 
-			if( num == 0 )
+			if(num == 0)
 			{
-				glDrawBuffer( GL_NONE );
-				glReadBuffer( GL_NONE );
+				glDrawBuffer(GL_NONE);
+				glReadBuffer(GL_NONE);
 			}
 			else
 			{
@@ -59,7 +59,7 @@ class Fbo
 				                                     GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4, GL_COLOR_ATTACHMENT5,
 				                                     GL_COLOR_ATTACHMENT6, GL_COLOR_ATTACHMENT7 };
 
-				glDrawBuffers( num, colorAttachments );
+				glDrawBuffers(num, colorAttachments);
 			}
 		}
 
@@ -70,7 +70,7 @@ class Fbo
 		static uint getCurrentFbo()
 		{
 			int fboGlId;
-			glGetIntegerv( GL_FRAMEBUFFER_BINDING, &fboGlId );
+			glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fboGlId);
 			return (uint)fboGlId;
 		}
 };

+ 5 - 5
src/Renderer/BufferObjects/Vbo.h

@@ -13,11 +13,11 @@ class Vbo: public BufferObject
 		/**
 		 * It adds an extra check over @ref BufferObject::create. See @ref BufferObject::create for details
 		 */
-		bool create( GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_ )
+		bool create(GLenum target_, uint sizeInBytes, const void* dataPtr, GLenum usage_)
 		{
-			DEBUG_ERR( target_!=GL_ARRAY_BUFFER && target_!=GL_ELEMENT_ARRAY_BUFFER ); // unacceptable target_
+			DEBUG_ERR(target_!=GL_ARRAY_BUFFER && target_!=GL_ELEMENT_ARRAY_BUFFER); // unacceptable target_
 
-			return BufferObject::create( target_, sizeInBytes, dataPtr, usage_ );
+			return BufferObject::create(target_, sizeInBytes, dataPtr, usage_);
 		}
 
 		/**
@@ -25,8 +25,8 @@ class Vbo: public BufferObject
 		 */
 		static void unbindAllTargets()
 		{
-			glBindBufferARB( GL_ARRAY_BUFFER, 0 );
-			glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER, 0 );
+			glBindBufferARB(GL_ARRAY_BUFFER, 0);
+			glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
 		}
 };
 

+ 73 - 73
src/Renderer/Dbg.cpp

@@ -21,12 +21,12 @@ Mat4 Renderer::Dbg::viewProjectionMat;
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-Renderer::Dbg::Dbg( Renderer& r_ ):
-	RenderingStage( r_ ),
-	showAxisEnabled( false ),
-	showLightsEnabled( true ),
-	showSkeletonsEnabled( false ),
-	showCamerasEnabled( true )
+Renderer::Dbg::Dbg(Renderer& r_):
+	RenderingStage(r_),
+	showAxisEnabled(false),
+	showLightsEnabled(true),
+	showSkeletonsEnabled(false),
+	showCamerasEnabled(true)
 {
 }
 
@@ -40,35 +40,35 @@ void Renderer::Dbg::renderGrid()
 	float col1[] = { 0.0, 0.0, 1.0 };
 	float col2[] = { 1.0, 0.0, 0.0 };
 
-	glDisable( GL_TEXTURE_2D );
-	glDisable( GL_LIGHTING );
-	glDisable( GL_LINE_STIPPLE );
+	glDisable(GL_TEXTURE_2D);
+	glDisable(GL_LIGHTING);
+	glDisable(GL_LINE_STIPPLE);
 	//glLineWidth(1.0);
-	glColor3fv( col0 );
+	glColor3fv(col0);
 
 	const float space = 1.0; // space between lines
 	const int num = 57;  // lines number. must be odd
 
 	float opt = ((num-1)*space/2);
-	glBegin( GL_LINES );
-		for( int x=0; x<num; x++ )
+	glBegin(GL_LINES);
+		for(int x=0; x<num; x++)
 		{
-			if( x==num/2 ) // if the middle line then change color
-				glColor3fv( col1 );
-			else if( x==(num/2)+1 ) // if the next line after the middle one change back to default col
-				glColor3fv( col0 );
+			if(x==num/2) // if the middle line then change color
+				glColor3fv(col1);
+			else if(x==(num/2)+1) // if the next line after the middle one change back to default col
+				glColor3fv(col0);
 
 			float opt1 = (x*space);
 			// line in z
-			glVertex3f( opt1-opt, 0.0, -opt );
-			glVertex3f( opt1-opt, 0.0, opt );
+			glVertex3f(opt1-opt, 0.0, -opt);
+			glVertex3f(opt1-opt, 0.0, opt);
 
-			if( x==num/2 ) // if middle line change col so you can highlight the x-axis
-				glColor3fv( col2 );
+			if(x==num/2) // if middle line change col so you can highlight the x-axis
+				glColor3fv(col2);
 
 			// line in the x
-			glVertex3f( -opt, 0.0, opt1-opt );
-			glVertex3f( opt, 0.0, opt1-opt );
+			glVertex3f(-opt, 0.0, opt1-opt);
+			glVertex3f(opt, 0.0, opt1-opt);
 		}
 	glEnd();
 }
@@ -77,7 +77,7 @@ void Renderer::Dbg::renderGrid()
 //======================================================================================================================
 // renderSphere                                                                                                        =
 //======================================================================================================================
-void Renderer::Dbg::renderSphere( int complexity, float radius )
+void Renderer::Dbg::renderSphere(int complexity, float radius)
 {
 	const float twopi  = M::PI*2;
 	const float pidiv2 = M::PI/2;
@@ -98,21 +98,21 @@ void Renderer::Dbg::renderSphere( int complexity, float radius )
 	Vec<Vec3> normals;
 	Vec<Vec2> texCoodrs;
 
-	for( int i = 0; i < complexity/2; ++i )
+	for(int i = 0; i < complexity/2; ++i)
 	{
 		theta1 = i * twopi / complexity - pidiv2;
 		theta2 = (i + 1) * twopi / complexity - pidiv2;
 
-		for( int j = complexity; j >= 0; --j )
+		for(int j = complexity; j >= 0; --j)
 		{
 			theta3 = j * twopi / complexity;
 
 			float sintheta1, costheta1;
-			sinCos( theta1, sintheta1, costheta1 );
+			sinCos(theta1, sintheta1, costheta1);
 			float sintheta2, costheta2;
-			sinCos( theta2, sintheta2, costheta2 );
+			sinCos(theta2, sintheta2, costheta2);
 			float sintheta3, costheta3;
-			sinCos( theta3, sintheta3, costheta3 );
+			sinCos(theta3, sintheta3, costheta3);
 
 
 			ex = costheta2 * costheta3;
@@ -122,9 +122,9 @@ void Renderer::Dbg::renderSphere( int complexity, float radius )
 			py = radius * ey;
 			pz = radius * ez;
 
-			positions.push_back( Vec3(px, py, pz) );
-			normals.push_back( Vec3(ex, ey, ez) );
-			texCoodrs.push_back( Vec2(-(j/(float)complexity), 2*(i+1)/(float)complexity) );
+			positions.push_back(Vec3(px, py, pz));
+			normals.push_back(Vec3(ex, ey, ez));
+			texCoodrs.push_back(Vec2(-(j/(float)complexity), 2*(i+1)/(float)complexity));
 
 			ex = costheta1 * costheta3;
 			ey = sintheta1;
@@ -133,44 +133,44 @@ void Renderer::Dbg::renderSphere( int complexity, float radius )
 			py = radius * ey;
 			pz = radius * ez;
 
-			positions.push_back( Vec3(px, py, pz) );
-			normals.push_back( Vec3(ex, ey, ez) );
-			texCoodrs.push_back( Vec2(-(j/(float)complexity), 2*i/(float)complexity) );
+			positions.push_back(Vec3(px, py, pz));
+			normals.push_back(Vec3(ex, ey, ez));
+			texCoodrs.push_back(Vec2(-(j/(float)complexity), 2*i/(float)complexity));
 		}
 	}
 
-	glEnableVertexAttribArray( 0 );
-	glVertexAttribPointer( 0, 3, GL_FLOAT, false, 0, &(positions[0][0]) );
-	glDrawArrays( GL_QUAD_STRIP, 0, positions.size() );
-	glDisableVertexAttribArray( 0 );
+	glEnableVertexAttribArray(0);
+	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, &(positions[0][0]));
+	glDrawArrays(GL_QUAD_STRIP, 0, positions.size());
+	glDisableVertexAttribArray(0);
 }
 
 
 //======================================================================================================================
 // renderCube                                                                                                          =
 //======================================================================================================================
-void Renderer::Dbg::renderCube( float size )
+void Renderer::Dbg::renderCube(float size)
 {
-	Vec3 maxPos = Vec3( 0.5 * size );
-	Vec3 minPos = Vec3( -0.5 * size );
+	Vec3 maxPos = Vec3(0.5 * size);
+	Vec3 minPos = Vec3(-0.5 * size);
 
 	Vec3 points [] = {
-		Vec3( maxPos.x, maxPos.y, maxPos.z ),  // right top front
-		Vec3( minPos.x, maxPos.y, maxPos.z ),  // left top front
-		Vec3( minPos.x, minPos.y, maxPos.z ),  // left bottom front
-		Vec3( maxPos.x, minPos.y, maxPos.z ),  // right bottom front
-		Vec3( maxPos.x, maxPos.y, minPos.z ),  // right top back
-		Vec3( minPos.x, maxPos.y, minPos.z ),  // left top back
-		Vec3( minPos.x, minPos.y, minPos.z ),  // left bottom back
-		Vec3( maxPos.x, minPos.y, minPos.z )   // right bottom back
+		Vec3(maxPos.x, maxPos.y, maxPos.z),  // right top front
+		Vec3(minPos.x, maxPos.y, maxPos.z),  // left top front
+		Vec3(minPos.x, minPos.y, maxPos.z),  // left bottom front
+		Vec3(maxPos.x, minPos.y, maxPos.z),  // right bottom front
+		Vec3(maxPos.x, maxPos.y, minPos.z),  // right top back
+		Vec3(minPos.x, maxPos.y, minPos.z),  // left top back
+		Vec3(minPos.x, minPos.y, minPos.z),  // left bottom back
+		Vec3(maxPos.x, minPos.y, minPos.z)   // right bottom back
 	};
 
 	const ushort indeces [] = { 0, 1, 2, 3, 4, 0, 3, 7, 1, 5, 6, 2, 5, 4, 7, 6, 0, 4, 5, 1, 3, 2, 6, 7 };
 
-	glEnableVertexAttribArray( 0 );
-	glVertexAttribPointer( 0, 3, GL_FLOAT, false, 0, &(points[0][0]) );
-	glDrawElements( GL_QUADS, sizeof(indeces)/sizeof(ushort), GL_UNSIGNED_SHORT, indeces );
-	glDisableVertexAttribArray( 0 );
+	glEnableVertexAttribArray(0);
+	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, &(points[0][0]));
+	glDrawElements(GL_QUADS, sizeof(indeces)/sizeof(ushort), GL_UNSIGNED_SHORT, indeces);
+	glDisableVertexAttribArray(0);
 }
 
 
@@ -187,21 +187,21 @@ void Renderer::Dbg::init()
 	fbo.setNumOfColorAttachements(1);
 
 	// attach the textures
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r.pps.fai.getGlId(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r.ms.depthFai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, r.pps.fai.getGlId(), 0);
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,  GL_TEXTURE_2D, r.ms.depthFai.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create debug FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create debug FBO");
 
 	// unbind
 	fbo.unbind();
 
 	// shader
-	if( sProg == NULL )
+	if(sProg == NULL)
 	{
 		sProg = new ShaderProg;
-		sProg->customLoad( "shaders/Dbg.glsl" );
+		sProg->customLoad("shaders/Dbg.glsl");
 	}
 
 }
@@ -212,7 +212,7 @@ void Renderer::Dbg::init()
 //======================================================================================================================
 void Renderer::Dbg::run()
 {
-	if( !enabled ) return;
+	if(!enabled) return;
 
 	const Camera& cam = *r.cam;
 
@@ -221,13 +221,13 @@ void Renderer::Dbg::run()
 	viewProjectionMat = cam.getProjectionMatrix() * cam.getViewMatrix();
 
 	// OGL stuff
-	r.setProjectionViewMatrices( cam );
-	Renderer::setViewport( 0, 0, r.width, r.height );
-	glEnable( GL_DEPTH_TEST );
-	glDisable( GL_BLEND );
+	r.setProjectionViewMatrices(cam);
+	Renderer::setViewport(0, 0, r.width, r.height);
+	glEnable(GL_DEPTH_TEST);
+	glDisable(GL_BLEND);
 
 	//R::renderGrid();
-	for( uint i=0; i<app->getScene()->nodes.size(); i++ )
+	for(uint i=0; i<app->getScene()->nodes.size(); i++)
 	{
 		sProg->bind();
 
@@ -241,12 +241,12 @@ void Renderer::Dbg::run()
 		{
 			node->render();
 		}
-		else if( app->getScene()->nodes[i]->type == SceneNode::NT_SKELETON && showSkeletonsEnabled )
+		else if(app->getScene()->nodes[i]->type == SceneNode::NT_SKELETON && showSkeletonsEnabled)
 		{
-			SkelNode* skelNode = static_cast<SkelNode*>( node );
-			glDisable( GL_DEPTH_TEST );
+			SkelNode* skelNode = static_cast<SkelNode*>(node);
+			glDisable(GL_DEPTH_TEST);
 			skelNode->render();
-			glEnable( GL_DEPTH_TEST );
+			glEnable(GL_DEPTH_TEST);
 		}
 	}
 }
@@ -255,18 +255,18 @@ void Renderer::Dbg::run()
 //======================================================================================================================
 // setColor                                                                                                            =
 //======================================================================================================================
-void Renderer::Dbg::setColor( const Vec4& color )
+void Renderer::Dbg::setColor(const Vec4& color)
 {
-	sProg->findUniVar( "color" )->setVec4( &color );
+	sProg->findUniVar("color")->setVec4(&color);
 }
 
 
 //======================================================================================================================
 // setModelMat                                                                                                         =
 //======================================================================================================================
-void Renderer::Dbg::setModelMat( const Mat4& modelMat )
+void Renderer::Dbg::setModelMat(const Mat4& modelMat)
 {
 	Mat4 pmv = viewProjectionMat * modelMat;
-	sProg->findUniVar( "modelViewProjectionMat" )->setMat4( &pmv );
+	sProg->findUniVar("modelViewProjectionMat")->setMat4(&pmv);
 }
 

+ 15 - 15
src/Renderer/Ez.cpp

@@ -15,7 +15,7 @@
 //======================================================================================================================
 void Renderer::Ms::Ez::init()
 {
-	DEBUG_ERR( !enabled );
+	DEBUG_ERR(!enabled);
 
 	//
 	// init FBO
@@ -23,12 +23,12 @@ void Renderer::Ms::Ez::init()
 	fbo.create();
 	fbo.bind();
 
-	fbo.setNumOfColorAttachements( 0 );
+	fbo.setNumOfColorAttachements(0);
 
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, r.ms.depthFai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, r.ms.depthFai.getGlId(), 0);
 
-	if( !fbo.isGood() )
-		FATAL( "Cannot create shadowmapping FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create shadowmapping FBO");
 
 	fbo.unbind();
 }
@@ -39,26 +39,26 @@ void Renderer::Ms::Ez::init()
 //======================================================================================================================
 void Renderer::Ms::Ez::run()
 {
-	DEBUG_ERR( !enabled );
+	DEBUG_ERR(!enabled);
 
 	fbo.bind();
 
-	Renderer::setViewport( 0, 0, r.width, r.height );
+	Renderer::setViewport(0, 0, r.width, r.height);
 
-	glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
-	glEnable( GL_DEPTH_TEST );
-	glDisable( GL_BLEND );
+	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+	glEnable(GL_DEPTH_TEST);
+	glDisable(GL_BLEND);
 
-	for( Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++ )
+	for(Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++)
 	{
 		MeshNode* meshNode = (*it);
-		if( meshNode->material->blends || meshNode->material->refracts ) continue;
+		if(meshNode->material->blends || meshNode->material->refracts) continue;
 
-		DEBUG_ERR( meshNode->material->dpMtl == NULL );
+		DEBUG_ERR(meshNode->material->dpMtl == NULL);
 
-		r.setupMaterial( *meshNode->material->dpMtl, *meshNode, *r.cam );
+		r.setupMaterial(*meshNode->material->dpMtl, *meshNode, *r.cam);
 		meshNode->renderDepth();
 	}
 
-	glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
+	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 }

+ 30 - 30
src/Renderer/Hdr.cpp

@@ -10,7 +10,7 @@
 //======================================================================================================================
 // initFbos                                                                                                            =
 //======================================================================================================================
-void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
+void Renderer::Pps::Hdr::initFbos(Fbo& fbo, Texture& fai, int internalFormat)
 {
 	int width = renderingQuality * r.width;
 	int height = renderingQuality * r.height;
@@ -23,17 +23,17 @@ void Renderer::Pps::Hdr::initFbos( Fbo& fbo, Texture& fai, int internalFormat )
 	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D( width, height, internalFormat, GL_RGB, GL_FLOAT, false );
-	fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	//fai_.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	fai.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	fai.createEmpty2D(width, height, internalFormat, GL_RGB, GL_FLOAT, false);
+	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	//fai_.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create deferred shading post-processing stage HDR passes FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create deferred shading post-processing stage HDR passes FBO");
 
 	// unbind
 	fbo.unbind();
@@ -48,28 +48,28 @@ void Renderer::Pps::Hdr::init()
 	//int width = renderingQuality * r.width;
 	int height = renderingQuality * r.height;
 
-	initFbos( pass0Fbo, pass0Fai, GL_RGB );
-	initFbos( pass1Fbo, pass1Fai, GL_RGB );
-	initFbos( pass2Fbo, fai, GL_RGB );
+	initFbos(pass0Fbo, pass0Fai, GL_RGB);
+	initFbos(pass1Fbo, pass1Fai, GL_RGB);
+	initFbos(pass2Fbo, fai, GL_RGB);
 
-	fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
 	// init shaders
 	const char* shaderFname = "shaders/PpsHdr.glsl";
 	string pps;
 
 	pps = "#define _PPS_HDR_PASS_0_\n#define IS_FAI_WIDTH " + Util::floatToStr(r.width) + "\n";
-	if( !pass0SProg.customLoad( shaderFname, pps.c_str() ) )
-		FATAL( "See prev error" );
+	if(!pass0SProg.customLoad(shaderFname, pps.c_str()))
+		FATAL("See prev error");
 	pass0SProg.uniVars.fai = pass0SProg.findUniVar("fai");
 
 	pps = "#define _PPS_HDR_PASS_1_\n#define PASS0_HEIGHT " + Util::floatToStr(height) + "\n";
-	if( !pass1SProg.customLoad( shaderFname, pps.c_str() ) )
-		FATAL( "See prev error" );
+	if(!pass1SProg.customLoad(shaderFname, pps.c_str()))
+		FATAL("See prev error");
 	pass1SProg.uniVars.fai = pass1SProg.findUniVar("fai");
 
-	if( !pass2SProg.customLoad( shaderFname, "#define _PPS_HDR_PASS_2_\n" ) )
-		FATAL( "See prev error" );
+	if(!pass2SProg.customLoad(shaderFname, "#define _PPS_HDR_PASS_2_\n"))
+		FATAL("See prev error");
 	pass2SProg.uniVars.fai = pass2SProg.findUniVar("fai");
 }
 
@@ -81,31 +81,31 @@ void Renderer::Pps::Hdr::run()
 {
 	int w = renderingQuality * r.width;
 	int h = renderingQuality * r.height;
-	Renderer::setViewport( 0, 0, w, h );
+	Renderer::setViewport(0, 0, w, h);
 
-	glDisable( GL_BLEND );
-	glDisable( GL_DEPTH_TEST );
+	glDisable(GL_BLEND);
+	glDisable(GL_DEPTH_TEST);
 
 	// pass 0
 	pass0Fbo.bind();
 	pass0SProg.bind();
-	r.is.fai.setRepeat( false );
-	pass0SProg.uniVars.fai->setTexture( r.is.fai, 0 );
-	Renderer::drawQuad( 0 );
+	r.is.fai.setRepeat(false);
+	pass0SProg.uniVars.fai->setTexture(r.is.fai, 0);
+	Renderer::drawQuad(0);
 
 	// pass 1
 	pass1Fbo.bind();
 	pass1SProg.bind();
-	pass0Fai.setRepeat( false );
-	pass1SProg.uniVars.fai->setTexture( pass0Fai, 0 );
-	Renderer::drawQuad( 0 );
+	pass0Fai.setRepeat(false);
+	pass1SProg.uniVars.fai->setTexture(pass0Fai, 0);
+	Renderer::drawQuad(0);
 
 	// pass 2
 	pass2Fbo.bind();
 	pass2SProg.bind();
-	pass1Fai.setRepeat( false );
-	pass2SProg.uniVars.fai->setTexture( pass1Fai, 0 );
-	Renderer::drawQuad( 0 );
+	pass1Fai.setRepeat(false);
+	pass2SProg.uniVars.fai->setTexture(pass1Fai, 0);
+	Renderer::drawQuad(0);
 
 	// end
 	Fbo::unbind();

+ 99 - 99
src/Renderer/Is.cpp

@@ -21,15 +21,15 @@ void Renderer::Is::calcViewVector()
 
 	const uint& w = r.width;
 	const uint& h = r.height;
-	uint pixels[4][2]={ {w,h}, {0,h}, {0,0}, {w,0} }; // From right up and CC wise to right down, Just like we render the quad
+	uint pixels[4][2]={ {w,h}, {0,h}, {0, 0}, {w, 0} }; // From right up and CC wise to right down, Just like we render the quad
 	uint viewport[4]={ 0, 0, w, h };
 
-	for( int i=0; i<4; i++ )
+	for(int i=0; i<4; i++)
 	{
 		/*
 		 * Original Code:
-		 * Renderer::unProject( pixels[i][0], pixels[i][1], 10, cam.getViewMatrix(), cam.getProjectionMatrix(), viewport,
-		 *                      viewVectors[i].x, viewVectors[i].y, viewVectors[i].z );
+		 * Renderer::unProject(pixels[i][0], pixels[i][1], 10, cam.getViewMatrix(), cam.getProjectionMatrix(), viewport,
+		 *                      viewVectors[i].x, viewVectors[i].y, viewVectors[i].z);
 		 * viewVectors[i] = cam.getViewMatrix() * viewVectors[i];
 		 * The original code is the above 3 lines. The optimized follows:
 		 */
@@ -39,7 +39,7 @@ void Renderer::Is::calcViewVector()
 		vec.y = (2.0*(pixels[i][1]-viewport[1]))/viewport[3] - 1.0;
 		vec.z = 1.0;
 
-		viewVectors[i] = vec.getTransformed( cam.getInvProjectionMatrix() );
+		viewVectors[i] = vec.getTransformed(cam.getInvProjectionMatrix());
 		// end of optimized code
 	}
 }
@@ -67,24 +67,24 @@ void Renderer::Is::initFbo()
 	fbo.bind();
 
 	// init the stencil render buffer
-	glGenRenderbuffers( 1, &stencilRb );
-	glBindRenderbuffer( GL_RENDERBUFFER, stencilRb );
-	glRenderbufferStorage( GL_RENDERBUFFER, GL_STENCIL_INDEX, r.width, r.height );
-	glFramebufferRenderbufferEXT( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencilRb );
+	glGenRenderbuffers(1, &stencilRb);
+	glBindRenderbuffer(GL_RENDERBUFFER, stencilRb);
+	glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX, r.width, r.height);
+	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencilRb);
 
 	// inform in what buffers we draw
-	fbo.setNumOfColorAttachements( 1 );
+	fbo.setNumOfColorAttachements(1);
 
 	// create the txtrs
-	if( !fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB, GL_FLOAT, false ) )
-		FATAL( "Cannot create deferred shading illumination stage FAI" );
+	if(!fai.createEmpty2D(r.width, r.height, GL_RGB, GL_RGB, GL_FLOAT, false))
+		FATAL("Cannot create deferred shading illumination stage FAI");
 
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create deferred shading illumination stage FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create deferred shading illumination stage FBO");
 
 	// unbind
 	fbo.unbind();
@@ -97,11 +97,11 @@ void Renderer::Is::initFbo()
 void Renderer::Is::init()
 {
 	// load the shaders
-	ambientPassSProg.customLoad( "shaders/IsAp.glsl" );
+	ambientPassSProg.customLoad("shaders/IsAp.glsl");
 	ambientPassSProg.uniVars.ambientCol = ambientPassSProg.findUniVar("ambientCol");
 	ambientPassSProg.uniVars.sceneColMap = ambientPassSProg.findUniVar("sceneColMap");
 
-	pointLightSProg.customLoad( "shaders/IsLpGeneric.glsl", "#define _POINT_LIGHT_\n" );
+	pointLightSProg.customLoad("shaders/IsLpGeneric.glsl", "#define _POINT_LIGHT_\n");
 	pointLightSProg.uniVars.msNormalFai = pointLightSProg.findUniVar("msNormalFai");
 	pointLightSProg.uniVars.msDiffuseFai = pointLightSProg.findUniVar("msDiffuseFai");
 	pointLightSProg.uniVars.msSpecularFai = pointLightSProg.findUniVar("msSpecularFai");
@@ -112,7 +112,7 @@ void Renderer::Is::init()
 	pointLightSProg.uniVars.lightDiffuseCol = pointLightSProg.findUniVar("lightDiffuseCol");
 	pointLightSProg.uniVars.lightSpecularCol = pointLightSProg.findUniVar("lightSpecularCol");
 
-	spotLightNoShadowSProg.customLoad( "shaders/IsLpGeneric.glsl", "#define _SPOT_LIGHT_\n" );
+	spotLightNoShadowSProg.customLoad("shaders/IsLpGeneric.glsl", "#define _SPOT_LIGHT_\n");
 	spotLightNoShadowSProg.uniVars.msNormalFai = spotLightNoShadowSProg.findUniVar("msNormalFai");
 	spotLightNoShadowSProg.uniVars.msDiffuseFai = spotLightNoShadowSProg.findUniVar("msDiffuseFai");
 	spotLightNoShadowSProg.uniVars.msSpecularFai = spotLightNoShadowSProg.findUniVar("msSpecularFai");
@@ -125,10 +125,10 @@ void Renderer::Is::init()
 	spotLightNoShadowSProg.uniVars.lightTex = spotLightNoShadowSProg.findUniVar("lightTex");
 	spotLightNoShadowSProg.uniVars.texProjectionMat = spotLightNoShadowSProg.findUniVar("texProjectionMat");
 
-	string pps = "#define SHADOWMAP_SIZE " + Util::intToStr( sm.resolution ) + "\n#define _SPOT_LIGHT_\n#define _SHADOW_\n";
-	if( sm.pcfEnabled )
+	string pps = "#define SHADOWMAP_SIZE " + Util::intToStr(sm.resolution) + "\n#define _SPOT_LIGHT_\n#define _SHADOW_\n";
+	if(sm.pcfEnabled)
 		pps += "#define PCF_ENABLED";
-	spotLightShadowSProg.customLoad( "shaders/IsLpGeneric.glsl", pps.c_str() );
+	spotLightShadowSProg.customLoad("shaders/IsLpGeneric.glsl", pps.c_str());
 	spotLightShadowSProg.uniVars.msNormalFai = spotLightShadowSProg.findUniVar("msNormalFai");
 	spotLightShadowSProg.uniVars.msDiffuseFai = spotLightShadowSProg.findUniVar("msDiffuseFai");
 	spotLightShadowSProg.uniVars.msSpecularFai = spotLightShadowSProg.findUniVar("msSpecularFai");
@@ -147,7 +147,7 @@ void Renderer::Is::init()
 	initFbo();
 	smo.init();
 
-	if( sm.enabled )
+	if(sm.enabled)
 		sm.init();
 }
 
@@ -155,113 +155,113 @@ void Renderer::Is::init()
 //======================================================================================================================
 // ambientPass                                                                                                         =
 //======================================================================================================================
-void Renderer::Is::ambientPass( const Vec3& color )
+void Renderer::Is::ambientPass(const Vec3& color)
 {
-	glDisable( GL_BLEND );
+	glDisable(GL_BLEND);
 
 	// set the shader
 	ambientPassSProg.bind();
 
 	// set the uniforms
-	ambientPassSProg.uniVars.ambientCol->setVec3( &color );
-	ambientPassSProg.uniVars.sceneColMap->setTexture( r.ms.diffuseFai, 0 );
+	ambientPassSProg.uniVars.ambientCol->setVec3(&color);
+	ambientPassSProg.uniVars.sceneColMap->setTexture(r.ms.diffuseFai, 0);
 
 	// Draw quad
-	Renderer::drawQuad( 0 );
+	Renderer::drawQuad(0);
 }
 
 
 //======================================================================================================================
 // pointLightPass                                                                                                      =
 //======================================================================================================================
-void Renderer::Is::pointLightPass( const PointLight& light )
+void Renderer::Is::pointLightPass(const PointLight& light)
 {
 	const Camera& cam = *r.cam;
 
 	// frustum test
-	bsphere_t sphere( light.getWorldTransform().getOrigin(), light.radius );
-	if( !cam.insideFrustum( sphere ) ) return;
+	bsphere_t sphere(light.getWorldTransform().getOrigin(), light.radius);
+	if(!cam.insideFrustum(sphere)) return;
 
 	// stencil optimization
-	smo.run( light );
+	smo.run(light);
 
 	// shader prog
 	const LightShaderProg& shader = pointLightSProg; // ensure the const-ness
 	shader.bind();
 
-	shader.uniVars.msNormalFai->setTexture( r.ms.normalFai, 0 );
-	shader.uniVars.msDiffuseFai->setTexture( r.ms.diffuseFai, 1 );
-	shader.uniVars.msSpecularFai->setTexture( r.ms.specularFai, 2 );
-	shader.uniVars.msDepthFai->setTexture( r.ms.depthFai, 3 );
-	shader.uniVars.planes->setVec2( &planes );
-	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed( cam.getViewMatrix() );
-	shader.uniVars.lightPos->setVec3( &lightPosEyeSpace );
-	shader.uniVars.lightInvRadius->setFloat( 1.0/light.radius );
-	shader.uniVars.lightDiffuseCol->setVec3( &light.lightProps->getDiffuseColor() );
-	shader.uniVars.lightSpecularCol->setVec3( &light.lightProps->getSpecularColor() );
+	shader.uniVars.msNormalFai->setTexture(r.ms.normalFai, 0);
+	shader.uniVars.msDiffuseFai->setTexture(r.ms.diffuseFai, 1);
+	shader.uniVars.msSpecularFai->setTexture(r.ms.specularFai, 2);
+	shader.uniVars.msDepthFai->setTexture(r.ms.depthFai, 3);
+	shader.uniVars.planes->setVec2(&planes);
+	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
+	shader.uniVars.lightPos->setVec3(&lightPosEyeSpace);
+	shader.uniVars.lightInvRadius->setFloat(1.0/light.radius);
+	shader.uniVars.lightDiffuseCol->setVec3(&light.lightProps->getDiffuseColor());
+	shader.uniVars.lightSpecularCol->setVec3(&light.lightProps->getSpecularColor());
 
 
 	// render quad
-	glEnableVertexAttribArray( 0 );
-	glEnableVertexAttribArray( 1 );
+	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(1);
 
-	glVertexAttribPointer( 0, 2, GL_FLOAT, false, 0, &Renderer::quadVertCoords[0] );
-	glVertexAttribPointer( 1, 3, GL_FLOAT, false, 0, &viewVectors[0] );
+	glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, &Renderer::quadVertCoords[0]);
+	glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, &viewVectors[0]);
 
-	glDrawArrays( GL_QUADS, 0, 4 );
+	glDrawArrays(GL_QUADS, 0, 4);
 
-	glDisableVertexAttribArray( 0 );
-	glDisableVertexAttribArray( 1 );
+	glDisableVertexAttribArray(0);
+	glDisableVertexAttribArray(1);
 }
 
 
 //======================================================================================================================
 // spotLightPass                                                                                                       =
 //======================================================================================================================
-void Renderer::Is::spotLightPass( const SpotLight& light )
+void Renderer::Is::spotLightPass(const SpotLight& light)
 {
 	const Camera& cam = *r.cam;
 
 	// frustum test
-	if( !cam.insideFrustum( light.camera ) ) return;
+	if(!cam.insideFrustum(light.camera)) return;
 
 	// shadow mapping
-	if( light.castsShadow && sm.enabled )
+	if(light.castsShadow && sm.enabled)
 	{
-		sm.run( light.camera );
+		sm.run(light.camera);
 
 		// restore the IS FBO
 		fbo.bind();
 
 		// and restore blending and depth test
-		glEnable( GL_BLEND );
-		glBlendFunc( GL_ONE, GL_ONE );
-		glDisable( GL_DEPTH_TEST );
+		glEnable(GL_BLEND);
+		glBlendFunc(GL_ONE, GL_ONE);
+		glDisable(GL_DEPTH_TEST);
 	}
 
 	// stencil optimization
-	smo.run( light );
+	smo.run(light);
 
 	// set the texture
-	if( light.lightProps->getTexture() == NULL )
+	if(light.lightProps->getTexture() == NULL)
 	{
-		ERROR( "No texture is attached to the light. lightProps name: " << light.lightProps->getRsrcName() );
+		ERROR("No texture is attached to the light. lightProps name: " << light.lightProps->getRsrcName());
 		return;
 	}
 
-	light.lightProps->getTexture()->setRepeat( false );
+	light.lightProps->getTexture()->setRepeat(false);
 
 	/*
 	 * Before we render disable anisotropic in the light.texture because it produces artifacts.
 	 * todo see if this is necessary with future drivers
 	 */
-	light.lightProps->getTexture()->setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-	light.lightProps->getTexture()->setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	light.lightProps->getTexture()->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	light.lightProps->getTexture()->setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
 	// shader prog
 	const LightShaderProg* shdr; // because of the huge name
 
-	if( light.castsShadow && sm.enabled )
+	if(light.castsShadow && sm.enabled)
 		shdr = &spotLightShadowSProg;
 	else
 		shdr = &spotLightNoShadowSProg;
@@ -269,47 +269,47 @@ void Renderer::Is::spotLightPass( const SpotLight& light )
 	shdr->bind();
 
 	// bind the FAIs
-	shdr->uniVars.msNormalFai->setTexture( r.ms.normalFai, 0 );
-	shdr->uniVars.msDiffuseFai->setTexture( r.ms.diffuseFai, 1 );
-	shdr->uniVars.msSpecularFai->setTexture( r.ms.specularFai, 2 );
-	shdr->uniVars.msDepthFai->setTexture( r.ms.depthFai, 3 );
+	shdr->uniVars.msNormalFai->setTexture(r.ms.normalFai, 0);
+	shdr->uniVars.msDiffuseFai->setTexture(r.ms.diffuseFai, 1);
+	shdr->uniVars.msSpecularFai->setTexture(r.ms.specularFai, 2);
+	shdr->uniVars.msDepthFai->setTexture(r.ms.depthFai, 3);
 
 	// the planes
-	shdr->uniVars.planes->setVec2( &planes );
+	shdr->uniVars.planes->setVec2(&planes);
 
 	// the light params
-	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed( cam.getViewMatrix() );
-	shdr->uniVars.lightPos->setVec3( &lightPosEyeSpace );
-	shdr->uniVars.lightInvRadius->setFloat( 1.0/light.getDistance() );
-	shdr->uniVars.lightDiffuseCol->setVec3( &light.lightProps->getDiffuseColor() );
-	shdr->uniVars.lightSpecularCol->setVec3( &light.lightProps->getSpecularColor() );
-	shdr->uniVars.lightTex->setTexture( *light.lightProps->getTexture(), 4 );
+	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
+	shdr->uniVars.lightPos->setVec3(&lightPosEyeSpace);
+	shdr->uniVars.lightInvRadius->setFloat(1.0/light.getDistance());
+	shdr->uniVars.lightDiffuseCol->setVec3(&light.lightProps->getDiffuseColor());
+	shdr->uniVars.lightSpecularCol->setVec3(&light.lightProps->getSpecularColor());
+	shdr->uniVars.lightTex->setTexture(*light.lightProps->getTexture(), 4);
 
 	// set texture matrix for texture & shadowmap projection
-	// Bias * P_light * V_light * inv( V_cam )
-	static Mat4 biasMat4( 0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0 );
+	// Bias * P_light * V_light * inv(V_cam)
+	static Mat4 biasMat4(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);
 	Mat4 texProjectionMat;
 	texProjectionMat = biasMat4 * light.camera.getProjectionMatrix() *
-	                   Mat4::combineTransformations( light.camera.getViewMatrix(), Mat4( cam.getWorldTransform() ) ) ;
-	shdr->uniVars.texProjectionMat->setMat4( &texProjectionMat );
+	                   Mat4::combineTransformations(light.camera.getViewMatrix(), Mat4(cam.getWorldTransform())) ;
+	shdr->uniVars.texProjectionMat->setMat4(&texProjectionMat);
 
 	// the shadowmap
-	if( light.castsShadow && sm.enabled )
+	if(light.castsShadow && sm.enabled)
 	{
-		shdr->uniVars.shadowMap->setTexture( sm.shadowMap, 5 );
+		shdr->uniVars.shadowMap->setTexture(sm.shadowMap, 5);
 	}
 
 	// render quad
-	glEnableVertexAttribArray( 0 );
-	glEnableVertexAttribArray( 1 );
+	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(1);
 
-	glVertexAttribPointer( 0, 2, GL_FLOAT, false, 0, &Renderer::quadVertCoords[0] );
-	glVertexAttribPointer( 1, 3, GL_FLOAT, false, 0, &viewVectors[0] );
+	glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, &Renderer::quadVertCoords[0]);
+	glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, &viewVectors[0]);
 
-	glDrawArrays( GL_QUADS, 0, 4 );
+	glDrawArrays(GL_QUADS, 0, 4);
 
-	glDisableVertexAttribArray( 0 );
-	glDisableVertexAttribArray( 1 );
+	glDisableVertexAttribArray(0);
+	glDisableVertexAttribArray(1);
 }
 
 
@@ -322,50 +322,50 @@ void Renderer::Is::run()
 	fbo.bind();
 
 	// OGL stuff
-	Renderer::setViewport( 0, 0, r.width, r.height );
+	Renderer::setViewport(0, 0, r.width, r.height);
 
-	glMatrixMode( GL_MODELVIEW );
+	glMatrixMode(GL_MODELVIEW);
 	glLoadIdentity();
 
-	glDisable( GL_DEPTH_TEST );
+	glDisable(GL_DEPTH_TEST);
 
 	// ambient pass
-	ambientPass( app->getScene()->getAmbientCol() );
+	ambientPass(app->getScene()->getAmbientCol());
 
 	// light passes
-	glEnable( GL_BLEND );
-	glBlendFunc( GL_ONE, GL_ONE );
-	glEnable( GL_STENCIL_TEST );
+	glEnable(GL_BLEND);
+	glBlendFunc(GL_ONE, GL_ONE);
+	glEnable(GL_STENCIL_TEST);
 
 	calcViewVector();
 	calcPlanes();
 
 	// for all lights
-	for( uint i=0; i<app->getScene()->lights.size(); i++ )
+	for(uint i=0; i<app->getScene()->lights.size(); i++)
 	{
 		const Light& light = *app->getScene()->lights[i];
-		switch( light.type )
+		switch(light.type)
 		{
 			case Light::LT_POINT:
 			{
 				const PointLight& pointl = static_cast<const PointLight&>(light);
-				pointLightPass( pointl );
+				pointLightPass(pointl);
 				break;
 			}
 
 			case Light::LT_SPOT:
 			{
 				const SpotLight& projl = static_cast<const SpotLight&>(light);
-				spotLightPass( projl );
+				spotLightPass(projl);
 				break;
 			}
 
 			default:
-				DEBUG_ERR( 1 );
+				DEBUG_ERR(1);
 		}
 	}
 
-	glDisable( GL_STENCIL_TEST );
+	glDisable(GL_STENCIL_TEST);
 
 	// FBO
 	fbo.unbind();

+ 81 - 81
src/Renderer/MainRenderer.cpp

@@ -9,13 +9,13 @@
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
-void MainRenderer::init( const RendererInitializer& initializer_ )
+void MainRenderer::init(const RendererInitializer& initializer_)
 {
-	INFO( "Main renderer initializing..." );
+	INFO("Main renderer initializing...");
 
 	initGl();
 
-	sProg.customLoad( "shaders/final.glsl" );
+	sProg.customLoad("shaders/final.glsl");
 
 	//
 	// init the offscreen Renderer
@@ -24,9 +24,9 @@ void MainRenderer::init( const RendererInitializer& initializer_ )
 	renderingQuality = initializer.mainRendererQuality;
 	initializer.width = app->getWindowWidth() * renderingQuality;
 	initializer.height = app->getWindowHeight() * renderingQuality;
-	Renderer::init( initializer );
+	Renderer::init(initializer);
 
-	INFO( "Main renderer initialization ends" );
+	INFO("Main renderer initialization ends");
 }
 
 
@@ -36,90 +36,90 @@ void MainRenderer::init( const RendererInitializer& initializer_ )
 void MainRenderer::initGl()
 {
 	GLenum err = glewInit();
-	if( err != GLEW_OK )
-		FATAL( "GLEW initialization failed" );
+	if(err != GLEW_OK)
+		FATAL("GLEW initialization failed");
 
 	// print GL info
-	INFO( "OpenGL info: OGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) );
+	INFO("OpenGL info: OGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION));
 
-	if( !glewIsSupported("GL_VERSION_3_1") )
-		WARNING( "OpenGL ver 3.1 not supported. The application may crash (and burn)" );
+	if(!glewIsSupported("GL_VERSION_3_1"))
+		WARNING("OpenGL ver 3.1 not supported. The application may crash (and burn)");
 
-	if( !glewIsSupported("GL_EXT_framebuffer_object") )
-		WARNING( "Framebuffer objects not supported. The application may crash (and burn)" );
+	if(!glewIsSupported("GL_EXT_framebuffer_object"))
+		WARNING("Framebuffer objects not supported. The application may crash (and burn)");
 
-	if( !glewIsSupported("GL_EXT_packed_depth_stencil") )
-		WARNING( "GL_EXT_packed_depth_stencil not supported. The application may crash (and burn)" );
+	if(!glewIsSupported("GL_EXT_packed_depth_stencil"))
+		WARNING("GL_EXT_packed_depth_stencil not supported. The application may crash (and burn)");
 
-	if( !glewIsSupported("GL_ARB_vertex_buffer_object") )
-		WARNING( "Vertex buffer objects not supported. The application may crash (and burn)" );
+	if(!glewIsSupported("GL_ARB_vertex_buffer_object"))
+		WARNING("Vertex buffer objects not supported. The application may crash (and burn)");
 
-	if( !glewIsSupported("GL_ARB_texture_non_power_of_two") )
-		WARNING( "Textures of non power of two not supported. The application may crash (and burn)" );
+	if(!glewIsSupported("GL_ARB_texture_non_power_of_two"))
+		WARNING("Textures of non power of two not supported. The application may crash (and burn)");
 
-	if( !glewIsSupported("GL_ARB_vertex_buffer_object") )
-		WARNING( "Vertex Buffer Objects not supported. The application may crash (and burn)" );
+	if(!glewIsSupported("GL_ARB_vertex_buffer_object"))
+		WARNING("Vertex Buffer Objects not supported. The application may crash (and burn)");
 
 
 	// get max texture units
-	glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &Texture::textureUnitsNum );
+	glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &Texture::textureUnitsNum);
 
-	glClearColor( 0.1, 0.1, 0.1, 1.0 );
-	glClearDepth( 1.0 );
-	glClearStencil( 0 );
-	glDepthFunc( GL_LEQUAL );
+	glClearColor(0.1, 0.1, 0.1, 1.0);
+	glClearDepth(1.0);
+	glClearStencil(0);
+	glDepthFunc(GL_LEQUAL);
 	// CullFace is always on
-	glCullFace( GL_BACK );
-	glEnable( GL_CULL_FACE );
+	glCullFace(GL_BACK);
+	glEnable(GL_CULL_FACE);
 	// defaults
-	glDisable( GL_LIGHTING );
-	glDisable( GL_TEXTURE_2D );
-	glDisable( GL_BLEND );
-	glDisable( GL_STENCIL_TEST );
-	glPolygonMode( GL_FRONT, GL_FILL );
-	glDepthMask( true );
-	glDepthFunc( GL_LESS );
-
-	glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAtachments );
+	glDisable(GL_LIGHTING);
+	glDisable(GL_TEXTURE_2D);
+	glDisable(GL_BLEND);
+	glDisable(GL_STENCIL_TEST);
+	glPolygonMode(GL_FRONT, GL_FILL);
+	glDepthMask(true);
+	glDepthFunc(GL_LESS);
+
+	glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAtachments);
 }
 
 
 //======================================================================================================================
 // render                                                                                                              =
 //======================================================================================================================
-void MainRenderer::render( Camera& cam_ )
+void MainRenderer::render(Camera& cam_)
 {
-	Renderer::render( cam_ );
+	Renderer::render(cam_);
 
 	//
 	// Render the PPS FAI to the framebuffer
 	//
 	Fbo::unbind();
-	setViewport( 0, 0, app->getWindowWidth(), app->getWindowHeight() );
-	glDisable( GL_DEPTH_TEST );
-	glDisable( GL_BLEND );
+	setViewport(0, 0, app->getWindowWidth(), app->getWindowHeight());
+	glDisable(GL_DEPTH_TEST);
+	glDisable(GL_BLEND);
 	sProg.bind();
-	sProg.findUniVar("rasterImage")->setTexture( pps.fai, 0 );
-	drawQuad( 0 );
+	sProg.findUniVar("rasterImage")->setTexture(pps.fai, 0);
+	drawQuad(0);
 }
 
 
 //======================================================================================================================
 // takeScreenshotTga                                                                                                   =
 //======================================================================================================================
-bool MainRenderer::takeScreenshotTga( const char* filename )
+bool MainRenderer::takeScreenshotTga(const char* filename)
 {
 	// open file and check
 	fstream fs;
-	fs.open( filename, ios::out|ios::binary );
-	if( !fs.good() )
+	fs.open(filename, ios::out|ios::binary);
+	if(!fs.good())
 	{
-		ERROR( "Cannot create screenshot. File \"" << filename << "\"" );
+		ERROR("Cannot create screenshot. File \"" << filename << "\"");
 		return false;
 	}
 
 	// write headers
-	unsigned char tgaHeaderUncompressed[12] = {0,0,2,0,0,0,0,0,0,0,0,0};
+	unsigned char tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 	unsigned char header[6];
 
 	header[1] = getWidth() / 256;
@@ -129,18 +129,18 @@ bool MainRenderer::takeScreenshotTga( const char* filename )
 	header[4] = 24;
 	header[5] = 0;
 
-	fs.write( (char*)tgaHeaderUncompressed, 12 );
-	fs.write( (char*)header, 6 );
+	fs.write((char*)tgaHeaderUncompressed, 12);
+	fs.write((char*)header, 6);
 
 	// write the buffer
-	char* buffer = (char*)calloc( getWidth()*getHeight()*3, sizeof(char) );
+	char* buffer = (char*)calloc(getWidth()*getHeight()*3, sizeof(char));
 
-	glReadPixels( 0, 0, getWidth(), getHeight(), GL_BGR, GL_UNSIGNED_BYTE, buffer );
-	fs.write( buffer, getWidth()*getHeight()*3 );
+	glReadPixels(0, 0, getWidth(), getHeight(), GL_BGR, GL_UNSIGNED_BYTE, buffer);
+	fs.write(buffer, getWidth()*getHeight()*3);
 
 	// end
 	fs.close();
-	free( buffer );
+	free(buffer);
 	return true;
 }
 
@@ -148,14 +148,14 @@ bool MainRenderer::takeScreenshotTga( const char* filename )
 //======================================================================================================================
 // takeScreenshotJpeg                                                                                                  =
 //======================================================================================================================
-bool MainRenderer::takeScreenshotJpeg( const char* filename )
+bool MainRenderer::takeScreenshotJpeg(const char* filename)
 {
 	// open file
-	FILE* outfile = fopen( filename, "wb" );
+	FILE* outfile = fopen(filename, "wb");
 
-	if( !outfile )
+	if(!outfile)
 	{
-		ERROR( "Cannot open file \"" << filename << "\"" );
+		ERROR("Cannot open file \"" << filename << "\"");
 		return false;
 	}
 
@@ -163,36 +163,36 @@ bool MainRenderer::takeScreenshotJpeg( const char* filename )
 	jpeg_compress_struct cinfo;
 	jpeg_error_mgr       jerr;
 
-	cinfo.err = jpeg_std_error( &jerr );
-	jpeg_create_compress( &cinfo );
-	jpeg_stdio_dest( &cinfo, outfile );
+	cinfo.err = jpeg_std_error(&jerr);
+	jpeg_create_compress(&cinfo);
+	jpeg_stdio_dest(&cinfo, outfile);
 
 	cinfo.image_width      = getWidth();
 	cinfo.image_height     = getHeight();
 	cinfo.input_components = 3;
 	cinfo.in_color_space   = JCS_RGB;
-	jpeg_set_defaults( &cinfo);
-	jpeg_set_quality ( &cinfo, screenshotJpegQuality, true );
-	jpeg_start_compress( &cinfo, true );
+	jpeg_set_defaults(&cinfo);
+	jpeg_set_quality (&cinfo, screenshotJpegQuality, true);
+	jpeg_start_compress(&cinfo, true);
 
 	// read from OGL
-	char* buffer = (char*)malloc( getWidth()*getHeight()*3*sizeof(char) );
-	glReadPixels( 0, 0, getWidth(), getHeight(), GL_RGB, GL_UNSIGNED_BYTE, buffer );
+	char* buffer = (char*)malloc(getWidth()*getHeight()*3*sizeof(char));
+	glReadPixels(0, 0, getWidth(), getHeight(), GL_RGB, GL_UNSIGNED_BYTE, buffer);
 
 	// write buffer to file
 	JSAMPROW row_pointer;
 
-	while( cinfo.next_scanline < cinfo.image_height )
+	while(cinfo.next_scanline < cinfo.image_height)
 	{
-		row_pointer = (JSAMPROW) &buffer[ (getHeight()-1-cinfo.next_scanline)*3*getWidth() ];
-		jpeg_write_scanlines( &cinfo, &row_pointer, 1 );
+		row_pointer = (JSAMPROW) &buffer[(getHeight()-1-cinfo.next_scanline)*3*getWidth()];
+		jpeg_write_scanlines(&cinfo, &row_pointer, 1);
 	}
 
 	jpeg_finish_compress(&cinfo);
 
 	// done
-	free( buffer );
-	fclose( outfile );
+	free(buffer);
+	fclose(outfile);
 	return true;
 }
 
@@ -200,29 +200,29 @@ bool MainRenderer::takeScreenshotJpeg( const char* filename )
 //======================================================================================================================
 // takeScreenshot                                                                                                      =
 //======================================================================================================================
-void MainRenderer::takeScreenshot( const char* filename )
+void MainRenderer::takeScreenshot(const char* filename)
 {
-	string ext = Util::getFileExtension( filename );
+	string ext = Util::getFileExtension(filename);
 	bool ret;
 
 	// exec from this extension
-	if( ext == "tga" )
+	if(ext == "tga")
 	{
-		ret = takeScreenshotTga( filename );
+		ret = takeScreenshotTga(filename);
 	}
-	else if( ext == "jpg" || ext == "jpeg" )
+	else if(ext == "jpg" || ext == "jpeg")
 	{
-		ret = takeScreenshotJpeg( filename );
+		ret = takeScreenshotJpeg(filename);
 	}
 	else
 	{
-		ERROR( "File \"" << filename << "\": Unsupported extension. Watch for capital" );
+		ERROR("File \"" << filename << "\": Unsupported extension. Watch for capital");
 		return;
 	}
 
-	if( !ret )
-		ERROR( "In taking screenshot" );
+	if(!ret)
+		ERROR("In taking screenshot");
 	else
-		INFO( "Screenshot \"" << filename << "\" saved" );
+		INFO("Screenshot \"" << filename << "\" saved");
 }
 

+ 8 - 8
src/Renderer/MainRenderer.h

@@ -13,39 +13,39 @@ class MainRenderer: public Renderer
 	/**
 	 * The quality of the JPEG screenshots. From 0 to 100
 	 */
-	PROPERTY_RW( int, screenshotJpegQuality, setScreenshotJpegQuality, getScreenshotJpegQuality )
+	PROPERTY_RW(int, screenshotJpegQuality, setScreenshotJpegQuality, getScreenshotJpegQuality)
 
 	/**
 	 * The global rendering quality of the raster image. Its a percentage of the application's window size. From 0.0(low)
 	 * to 1.0(high)
 	 */
-	PROPERTY_R( float, renderingQuality, getRenderingQuality )
+	PROPERTY_R(float, renderingQuality, getRenderingQuality)
 
 	public:
-		MainRenderer(): screenshotJpegQuality( 90 ) {}
+		MainRenderer(): screenshotJpegQuality(90) {}
 
 		/**
 		 * The same as Renderer::init but with additional initialization. @see Renderer::init
 		 */
-		void init( const RendererInitializer& initializer );
+		void init(const RendererInitializer& initializer);
 
 		/**
 		 * The same as Renderer::render but in addition it renders the final FAI to the framebuffer
 		 * @param cam @see Renderer::render
 		 */
-		void render( Camera& cam );
+		void render(Camera& cam);
 
 		/**
 		 * Save the color buffer to a tga (lossless & uncompressed & slow) or jpeg (lossy & compressed * fast)
 		 * @param filename The file to save
 		 */
-		void takeScreenshot( const char* filename );
+		void takeScreenshot(const char* filename);
 
 	private:
 		ShaderProg sProg; ///< Final pass' shader program
 
-		bool takeScreenshotTga( const char* filename );
-		bool takeScreenshotJpeg( const char* filename );
+		bool takeScreenshotTga(const char* filename);
+		bool takeScreenshotJpeg(const char* filename);
 		static void initGl();
 };
 

+ 34 - 34
src/Renderer/Ms.cpp

@@ -19,33 +19,33 @@ void Renderer::Ms::init()
 
 	// create the FAIs
 	const int internal_format = GL_RGBA16F_ARB;
-	if( !normalFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false ) ||
-	    !diffuseFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false ) ||
-	    !specularFai.createEmpty2D( r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false ) ||
-	    //!depthFai.createEmpty2D( r.width, r.height, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 ) )
-	    !depthFai.createEmpty2D( r.width, r.height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false ) )
+	if(!normalFai.createEmpty2D(r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false) ||
+	    !diffuseFai.createEmpty2D(r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false) ||
+	    !specularFai.createEmpty2D(r.width, r.height, internal_format, GL_RGBA, GL_FLOAT, false) ||
+	    //!depthFai.createEmpty2D(r.width, r.height, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8))
+	    !depthFai.createEmpty2D(r.width, r.height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, false))
 	{
-		FATAL( "Failed to create one MS FAI. See prev error" );
+		FATAL("Failed to create one MS FAI. See prev error");
 	}
 
 
 	// attach the buffers to the FBO
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, normalFai.getGlId(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, diffuseFai.getGlId(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, specularFai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, normalFai.getGlId(), 0);
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, diffuseFai.getGlId(), 0);
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, specularFai.getGlId(), 0);
 
-	//glFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0 );
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0 );
+	//glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0);
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0);
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthFai.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create deferred shading material stage FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create deferred shading material stage FBO");
 
 	// unbind
 	fbo.unbind();
 
-	if( ez.enabled )
+	if(ez.enabled)
 		ez.init();
 }
 
@@ -57,50 +57,50 @@ void Renderer::Ms::run()
 {
 	const Camera& cam = *r.cam;
 
-	if( ez.enabled )
+	if(ez.enabled)
 	{
 		ez.run();
 	}
 
 	fbo.bind();
 
-	if( !ez.enabled )
+	if(!ez.enabled)
 	{
-		glClear( GL_DEPTH_BUFFER_BIT );
+		glClear(GL_DEPTH_BUFFER_BIT);
 	}
 
-	r.setProjectionViewMatrices( cam );
-	Renderer::setViewport( 0, 0, r.width, r.height );
+	r.setProjectionViewMatrices(cam);
+	Renderer::setViewport(0, 0, r.width, r.height);
 
-	//glEnable( GL_DEPTH_TEST );
-	app->getScene()->skybox.Render( cam.getViewMatrix().getRotationPart() );
-	//glDepthFunc( GL_LEQUAL );
+	//glEnable(GL_DEPTH_TEST);
+	app->getScene()->skybox.Render(cam.getViewMatrix().getRotationPart());
+	//glDepthFunc(GL_LEQUAL);
 
 	// if ez then change the default depth test and disable depth writing
-	if( ez.enabled )
+	if(ez.enabled)
 	{
-		glDepthMask( false );
-		glDepthFunc( GL_EQUAL );
+		glDepthMask(false);
+		glDepthFunc(GL_EQUAL);
 	}
 
 	// render the meshes
-	for( Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++ )
+	for(Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++)
 	{
 		MeshNode* meshNode = (*it);
-		DEBUG_ERR( meshNode->material == NULL );
-		if( meshNode->material->blends || meshNode->material->refracts ) continue;
+		DEBUG_ERR(meshNode->material == NULL);
+		if(meshNode->material->blends || meshNode->material->refracts) continue;
 
-		r.setupMaterial( *meshNode->material, *meshNode, cam );
+		r.setupMaterial(*meshNode->material, *meshNode, cam);
 		meshNode->render();
 	}
 
-	glPolygonMode( GL_FRONT, GL_FILL ); // the rendering above fucks the polygon mode
+	glPolygonMode(GL_FRONT, GL_FILL); // the rendering above fucks the polygon mode
 
 	// restore depth
-	if( ez.enabled )
+	if(ez.enabled)
 	{
-		glDepthMask( true );
-		glDepthFunc( GL_LESS );
+		glDepthMask(true);
+		glDepthFunc(GL_LESS);
 	}
 
 	fbo.unbind();

+ 26 - 26
src/Renderer/Pps.cpp

@@ -17,55 +17,55 @@ void Renderer::Pps::init()
 	fbo.bind();
 
 	// inform in what buffers we draw
-	fbo.setNumOfColorAttachements( 1 );
+	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D( r.width, r.height, GL_RGB, GL_RGB, GL_FLOAT, false );
+	fai.createEmpty2D(r.width, r.height, GL_RGB, GL_RGB, GL_FLOAT, false);
 
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create post-processing stage FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create post-processing stage FBO");
 
 	fbo.unbind();
 
 
 	// init the shader and it's vars
 	string pps = "";
-	if( ssao.enabled )
+	if(ssao.enabled)
 	{
 		pps += "#define _SSAO_\n";
 	}
 
-	if( hdr.enabled )
+	if(hdr.enabled)
 	{
 		pps += "#define _HDR_\n";
 	}
 
-	sProg.customLoad( "shaders/Pps.glsl", pps.c_str() );
+	sProg.customLoad("shaders/Pps.glsl", pps.c_str());
 	sProg.bind();
 
-	sProg.uniVars.isFai = sProg.findUniVar( "isFai" );
+	sProg.uniVars.isFai = sProg.findUniVar("isFai");
 
-	if( ssao.enabled )
+	if(ssao.enabled)
 	{
 		ssao.init();
-		sProg.uniVars.ppsSsaoFai = sProg.findUniVar( "ppsSsaoFai" );
+		sProg.uniVars.ppsSsaoFai = sProg.findUniVar("ppsSsaoFai");
 	}
 
-	if( hdr.enabled )
+	if(hdr.enabled)
 	{
 		hdr.init();
-		sProg.uniVars.hdrFai = sProg.findUniVar( "ppsHdrFai" );
+		sProg.uniVars.hdrFai = sProg.findUniVar("ppsHdrFai");
 	}
 
 	/// @ todo enable lscatt
-	/*if( R::Pps::Lscatt::enabled )
+	/*if(R::Pps::Lscatt::enabled)
 	{
 		R::Pps::Lscatt::init();
-		sProg.uniVars.lscattFai = sProg.findUniVar( "ppsLscattFai" )->getLoc();
+		sProg.uniVars.lscattFai = sProg.findUniVar("ppsLscattFai")->getLoc();
 	}*/
 
 }
@@ -76,36 +76,36 @@ void Renderer::Pps::init()
 //======================================================================================================================
 void Renderer::Pps::run()
 {
-	if( ssao.enabled )
+	if(ssao.enabled)
 		ssao.run();
 
-	if( hdr.enabled )
+	if(hdr.enabled)
 		hdr.run();
 
 	fbo.bind();
 
 	// set GL
-	glDisable( GL_DEPTH_TEST );
-	glDisable( GL_BLEND );
+	glDisable(GL_DEPTH_TEST);
+	glDisable(GL_BLEND);
 
-	Renderer::setViewport( 0, 0, r.width, r.height );
+	Renderer::setViewport(0, 0, r.width, r.height);
 
 	// set shader
 	sProg.bind();
-	sProg.uniVars.isFai->setTexture( r.is.fai, 0 );
+	sProg.uniVars.isFai->setTexture(r.is.fai, 0);
 
-	if( hdr.enabled )
+	if(hdr.enabled)
 	{
-		sProg.uniVars.hdrFai->setTexture( hdr.fai, 1 );
+		sProg.uniVars.hdrFai->setTexture(hdr.fai, 1);
 	}
 
-	if( ssao.enabled )
+	if(ssao.enabled)
 	{
-		sProg.uniVars.ppsSsaoFai->setTexture( ssao.fai, 2 );
+		sProg.uniVars.ppsSsaoFai->setTexture(ssao.fai, 2);
 	}
 
 	// draw quad
-	Renderer::drawQuad( 0 );
+	Renderer::drawQuad(0);
 
 	// unbind FBO
 	fbo.unbind();

+ 107 - 100
src/Renderer/Renderer.cpp

@@ -2,12 +2,13 @@
 #include "Camera.h" /// @todo remove this
 #include "RendererInitializer.h"
 #include "Material.h"
+#include "App.h"
 
 
 //======================================================================================================================
 // Statics                                                                                                             =
 //======================================================================================================================
-float Renderer::quadVertCoords [][2] = { {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0} };
+float Renderer::quadVertCoords [][2] = { {1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0} };
 int Renderer::maxColorAtachments = -1;
 
 
@@ -15,19 +16,19 @@ int Renderer::maxColorAtachments = -1;
 // Constructor                                                                                                         =
 //======================================================================================================================
 Renderer::Renderer():
-	width( 640 ),
-	height( 480 ),
-	ms( *this ),
-	is( *this ),
-	pps( *this ),
-	dbg( *this )
+	width(640),
+	height(480),
+	ms(*this),
+	is(*this),
+	pps(*this),
+	dbg(*this)
 {
 }
 
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
-void Renderer::init( const RendererInitializer& initializer )
+void Renderer::init(const RendererInitializer& initializer)
 {
 	// set from the initializer
 	ms.ez.enabled = initializer.ms.ez.enabled;
@@ -47,9 +48,9 @@ void Renderer::init( const RendererInitializer& initializer )
 	aspectRatio = float(width)/height;
 
 	// a few sanity checks
-	if( width < 10 || height < 10 )
+	if(width < 10 || height < 10)
 	{
-		FATAL( "Incorrect width" );
+		FATAL("Incorrect width");
 	}
 
 	// init the stages. Careful with the order!!!!!!!!!!
@@ -63,7 +64,7 @@ void Renderer::init( const RendererInitializer& initializer )
 //======================================================================================================================
 // render                                                                                                              =
 //======================================================================================================================
-void Renderer::render( Camera& cam_ )
+void Renderer::render(Camera& cam_)
 {
 	cam = &cam_;
 
@@ -79,20 +80,20 @@ void Renderer::render( Camera& cam_ )
 //======================================================================================================================
 // drawQuad                                                                                                            =
 //======================================================================================================================
-void Renderer::drawQuad( int vertCoordsUniLoc )
+void Renderer::drawQuad(int vertCoordsUniLoc)
 {
-	DEBUG_ERR( vertCoordsUniLoc == -1 );
-	glEnableVertexAttribArray( vertCoordsUniLoc );
-	glVertexAttribPointer( vertCoordsUniLoc, 2, GL_FLOAT, false, 0, quadVertCoords );
-	glDrawArrays( GL_QUADS, 0, 4 );
-	glDisableVertexAttribArray( vertCoordsUniLoc );
+	DEBUG_ERR(vertCoordsUniLoc == -1);
+	glEnableVertexAttribArray(vertCoordsUniLoc);
+	glVertexAttribPointer(vertCoordsUniLoc, 2, GL_FLOAT, false, 0, quadVertCoords);
+	glDrawArrays(GL_QUADS, 0, 4);
+	glDisableVertexAttribArray(vertCoordsUniLoc);
 }
 
 
 //======================================================================================================================
 // setupMaterial                                                                                                       =
 //======================================================================================================================
-void Renderer::setupMaterial( const Material& mtl, const SceneNode& sceneNode, const Camera& cam )
+void Renderer::setupMaterial(const Material& mtl, const SceneNode& sceneNode, const Camera& cam)
 {
 	mtl.shaderProg->bind();
 	uint textureUnit = 0;
@@ -100,31 +101,31 @@ void Renderer::setupMaterial( const Material& mtl, const SceneNode& sceneNode, c
 	//
 	// FFP stuff
 	//
-	if( mtl.blends )
+	if(mtl.blends)
 	{
-		glEnable( GL_BLEND );
-		//glDisable( GL_BLEND );
-		glBlendFunc( mtl.blendingSfactor, mtl.blendingDfactor );
+		glEnable(GL_BLEND);
+		//glDisable(GL_BLEND);
+		glBlendFunc(mtl.blendingSfactor, mtl.blendingDfactor);
 	}
 	else
-		glDisable( GL_BLEND );
+		glDisable(GL_BLEND);
 
 
-	if( mtl.depthTesting )
-		glEnable( GL_DEPTH_TEST );
+	if(mtl.depthTesting)
+		glEnable(GL_DEPTH_TEST);
 	else
-		glDisable( GL_DEPTH_TEST );
+		glDisable(GL_DEPTH_TEST);
 
-	if( mtl.wireframe )
-		glPolygonMode( GL_FRONT, GL_LINE );
+	if(mtl.wireframe)
+		glPolygonMode(GL_FRONT, GL_LINE);
 	else
-		glPolygonMode( GL_FRONT, GL_FILL );
+		glPolygonMode(GL_FRONT, GL_FILL);
 
 
 	//
-	// matrices
+	// calc needed matrices
 	//
-	Mat4 modelMat( sceneNode.getWorldTransform() );
+	Mat4 modelMat(sceneNode.getWorldTransform());
 	const Mat4& projectionMat = cam.getProjectionMatrix();
 	const Mat4& viewMat = cam.getViewMatrix();
 	Mat4 modelViewMat;
@@ -132,98 +133,104 @@ void Renderer::setupMaterial( const Material& mtl, const SceneNode& sceneNode, c
 	Mat4 modelViewProjectionMat;
 
 	// should I calculate the modelViewMat ?
-	if( mtl.stdUniVars[ Material::SUV_MODELVIEW_MAT ] ||
-			mtl.stdUniVars[ Material::SUV_MODELVIEWPROJECTION_MAT ] ||
-			mtl.stdUniVars[ Material::SUV_NORMAL_MAT ] )
+	if(mtl.stdUniVars[Material::SUV_MODELVIEW_MAT] ||
+	   mtl.stdUniVars[Material::SUV_MODELVIEWPROJECTION_MAT] ||
+	   mtl.stdUniVars[Material::SUV_NORMAL_MAT])
 	{
-		modelViewMat = Mat4::combineTransformations( viewMat, modelMat );
+		modelViewMat = Mat4::combineTransformations(viewMat, modelMat);
 	}
 
-	// set all the matrices
-	if( mtl.stdUniVars[ Material::SUV_MODEL_MAT ] )
-		mtl.stdUniVars[ Material::SUV_MODEL_MAT ]->setMat4( &modelMat );
+	// set matrices
+	if(mtl.stdUniVars[Material::SUV_MODEL_MAT])
+		mtl.stdUniVars[Material::SUV_MODEL_MAT]->setMat4(&modelMat);
 
-	if( mtl.stdUniVars[ Material::SUV_VIEW_MAT ] )
-		mtl.stdUniVars[ Material::SUV_VIEW_MAT ]->setMat4( &viewMat );
+	if(mtl.stdUniVars[Material::SUV_VIEW_MAT])
+		mtl.stdUniVars[Material::SUV_VIEW_MAT]->setMat4(&viewMat);
 
-	if( mtl.stdUniVars[ Material::SUV_PROJECTION_MAT ] )
-		mtl.stdUniVars[ Material::SUV_PROJECTION_MAT ]->setMat4( &projectionMat );
+	if(mtl.stdUniVars[Material::SUV_PROJECTION_MAT])
+		mtl.stdUniVars[Material::SUV_PROJECTION_MAT]->setMat4(&projectionMat);
 
-	if( mtl.stdUniVars[ Material::SUV_MODELVIEW_MAT ] )
-		mtl.stdUniVars[ Material::SUV_MODELVIEW_MAT ]->setMat4( &modelViewMat );
+	if(mtl.stdUniVars[Material::SUV_MODELVIEW_MAT])
+		mtl.stdUniVars[Material::SUV_MODELVIEW_MAT]->setMat4(&modelViewMat);
 
-	if( mtl.stdUniVars[ Material::SUV_NORMAL_MAT ] )
+	if(mtl.stdUniVars[Material::SUV_NORMAL_MAT])
 	{
 		normalMat = modelViewMat.getRotationPart();
-		mtl.stdUniVars[ Material::SUV_NORMAL_MAT ]->setMat3( &normalMat );
+		mtl.stdUniVars[Material::SUV_NORMAL_MAT]->setMat3(&normalMat);
 	}
 
-	if( mtl.stdUniVars[ Material::SUV_MODELVIEWPROJECTION_MAT ] )
+	if(mtl.stdUniVars[Material::SUV_MODELVIEWPROJECTION_MAT])
 	{
 		modelViewProjectionMat = projectionMat * modelViewMat;
-		mtl.stdUniVars[ Material::SUV_MODELVIEWPROJECTION_MAT ]->setMat4( &modelViewProjectionMat );
+		mtl.stdUniVars[Material::SUV_MODELVIEWPROJECTION_MAT]->setMat4(&modelViewProjectionMat);
 	}
 
 
 	//
 	// FAis
 	//
-	if( mtl.stdUniVars[ Material::SUV_MS_NORMAL_FAI ] )
-		mtl.stdUniVars[ Material::SUV_MS_NORMAL_FAI ]->setTexture( ms.normalFai, textureUnit++ );
+	if(mtl.stdUniVars[Material::SUV_MS_NORMAL_FAI])
+		mtl.stdUniVars[Material::SUV_MS_NORMAL_FAI]->setTexture(ms.normalFai, textureUnit++);
 
-	if( mtl.stdUniVars[ Material::SUV_MS_DIFFUSE_FAI ] )
-		mtl.stdUniVars[ Material::SUV_MS_DIFFUSE_FAI ]->setTexture( ms.diffuseFai, textureUnit++ );
+	if(mtl.stdUniVars[Material::SUV_MS_DIFFUSE_FAI])
+		mtl.stdUniVars[Material::SUV_MS_DIFFUSE_FAI]->setTexture(ms.diffuseFai, textureUnit++);
 
-	if( mtl.stdUniVars[ Material::SUV_MS_SPECULAR_FAI ] )
-		mtl.stdUniVars[ Material::SUV_MS_SPECULAR_FAI ]->setTexture( ms.specularFai, textureUnit++ );
+	if(mtl.stdUniVars[Material::SUV_MS_SPECULAR_FAI])
+		mtl.stdUniVars[Material::SUV_MS_SPECULAR_FAI]->setTexture(ms.specularFai, textureUnit++);
 
-	if( mtl.stdUniVars[ Material::SUV_MS_DEPTH_FAI ] )
-		mtl.stdUniVars[ Material::SUV_MS_DEPTH_FAI ]->setTexture( ms.depthFai, textureUnit++ );
+	if(mtl.stdUniVars[Material::SUV_MS_DEPTH_FAI])
+		mtl.stdUniVars[Material::SUV_MS_DEPTH_FAI]->setTexture(ms.depthFai, textureUnit++);
 
-	if( mtl.stdUniVars[ Material::SUV_IS_FAI ] )
-		mtl.stdUniVars[ Material::SUV_IS_FAI ]->setTexture( is.fai, textureUnit++ );
+	if(mtl.stdUniVars[Material::SUV_IS_FAI])
+		mtl.stdUniVars[Material::SUV_IS_FAI]->setTexture(is.fai, textureUnit++);
 
-	if( mtl.stdUniVars[ Material::SUV_PPS_FAI ] )
-		mtl.stdUniVars[ Material::SUV_PPS_FAI ]->setTexture( pps.fai, textureUnit++ );
+	if(mtl.stdUniVars[Material::SUV_PPS_FAI])
+		mtl.stdUniVars[Material::SUV_PPS_FAI]->setTexture(pps.fai, textureUnit++);
 
 
 	//
 	// Other
 	//
-	if( mtl.stdUniVars[ Material::SUV_RENDERER_SIZE ] )
+	if(mtl.stdUniVars[Material::SUV_RENDERER_SIZE])
 	{
-		Vec2 v( width, height );
-		mtl.stdUniVars[ Material::SUV_RENDERER_SIZE ]->setVec2( &v );
+		Vec2 v(width, height);
+		mtl.stdUniVars[Material::SUV_RENDERER_SIZE]->setVec2(&v);
+	}
+
+	if(mtl.stdUniVars[Material::SUV_SCENE_AMBIENT_COLOR])
+	{
+		Vec3 col(app->getScene()->getAmbientCol());
+		mtl.stdUniVars[Material::SUV_SCENE_AMBIENT_COLOR]->setVec3(&col);
 	}
 
 
 	//
-	// now loop all the user defined vars and set them
+	// set user defined vars
 	//
-	for( uint i=0; i<mtl.userDefinedVars.size(); i++ )
+	for(uint i=0; i<mtl.userDefinedVars.size(); i++)
 	{
 		const Material::UserDefinedUniVar* udv = &mtl.userDefinedVars[i];
-		switch( udv->sProgVar->getGlDataType() )
+		switch(udv->sProgVar->getGlDataType())
 		{
 			// texture
 			case GL_SAMPLER_2D:
-				udv->sProgVar->setTexture( *udv->value.texture, textureUnit++ );
+				udv->sProgVar->setTexture(*udv->value.texture, textureUnit++);
 				break;
 			// float
 			case GL_FLOAT:
-				udv->sProgVar->setFloat( udv->value.float_ );
+				udv->sProgVar->setFloat(udv->value.float_);
 				break;
 			// vec2
 			case GL_FLOAT_VEC2:
-				udv->sProgVar->setVec2( &udv->value.vec2 );
+				udv->sProgVar->setVec2(&udv->value.vec2);
 				break;
 			// vec3
 			case GL_FLOAT_VEC3:
-				udv->sProgVar->setVec3( &udv->value.vec3 );
+				udv->sProgVar->setVec3(&udv->value.vec3);
 				break;
 			// vec4
 			case GL_FLOAT_VEC4:
-				udv->sProgVar->setVec4( &udv->value.vec4 );
+				udv->sProgVar->setVec4(&udv->value.vec4);
 				break;
 		}
 	}
@@ -233,28 +240,28 @@ void Renderer::setupMaterial( const Material& mtl, const SceneNode& sceneNode, c
 //======================================================================================================================
 // setProjectionMatrix                                                                                                 =
 //======================================================================================================================
-void Renderer::setProjectionMatrix( const Camera& cam )
+void Renderer::setProjectionMatrix(const Camera& cam)
 {
-	glMatrixMode( GL_PROJECTION );
-	loadMatrix( cam.getProjectionMatrix() );
+	glMatrixMode(GL_PROJECTION);
+	loadMatrix(cam.getProjectionMatrix());
 }
 
 
 //======================================================================================================================
 // setViewMatrix                                                                                                       =
 //======================================================================================================================
-void Renderer::setViewMatrix( const Camera& cam )
+void Renderer::setViewMatrix(const Camera& cam)
 {
-	glMatrixMode( GL_MODELVIEW );
-	loadMatrix( cam.getViewMatrix() );
+	glMatrixMode(GL_MODELVIEW);
+	loadMatrix(cam.getViewMatrix());
 }
 
 
 //======================================================================================================================
 // unproject                                                                                                           =
 //======================================================================================================================
-Vec3 Renderer::unproject( const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
-                          const int view[4] )
+Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
+                          const int view[4])
 {
 	Mat4 invPm = projectionMat * modelViewMat;
 	invPm.invert();
@@ -268,14 +275,14 @@ Vec3 Renderer::unproject( const Vec3& windowCoords, const Mat4& modelViewMat, co
 
 	Vec4 final = invPm * vec;
 	final /= final.w;
-	return Vec3( final );
+	return Vec3(final);
 }
 
 
 //======================================================================================================================
 // ortho                                                                                                               =
 //======================================================================================================================
-Mat4 Renderer::ortho( float left, float right, float bottom, float top, float near, float far )
+Mat4 Renderer::ortho(float left, float right, float bottom, float top, float near, float far)
 {
 	float difx = right-left;
 	float dify = top-bottom;
@@ -285,22 +292,22 @@ Mat4 Renderer::ortho( float left, float right, float bottom, float top, float ne
 	float tz = -(far+near) / difz;
 	Mat4 m;
 
-	m(0,0) = 2.0 / difx;
-	m(0,1) = 0.0;
-	m(0,2) = 0.0;
-	m(0,3) = tx;
-	m(1,0) = 0.0;
-	m(1,1) = 2.0 / dify;
-	m(1,2) = 0.0;
-	m(1,3) = ty;
-	m(2,0) = 0.0;
-	m(2,1) = 0.0;
-	m(2,2) = -2.0 / difz;
-	m(2,3) = tz;
-	m(3,0) = 0.0;
-	m(3,1) = 0.0;
-	m(3,2) = 0.0;
-	m(3,3) = 1.0;
+	m(0, 0) = 2.0 / difx;
+	m(0, 1) = 0.0;
+	m(0, 2) = 0.0;
+	m(0, 3) = tx;
+	m(1, 0) = 0.0;
+	m(1, 1) = 2.0 / dify;
+	m(1, 2) = 0.0;
+	m(1, 3) = ty;
+	m(2, 0) = 0.0;
+	m(2, 1) = 0.0;
+	m(2, 2) = -2.0 / difz;
+	m(2, 3) = tz;
+	m(3, 0) = 0.0;
+	m(3, 1) = 0.0;
+	m(3, 2) = 0.0;
+	m(3, 3) = 1.0;
 
 	return m;
 }
@@ -311,7 +318,7 @@ Mat4 Renderer::ortho( float left, float right, float bottom, float top, float ne
 //======================================================================================================================
 const uchar* Renderer::getLastError()
 {
-	return gluErrorString( glGetError() );
+	return gluErrorString(glGetError());
 }
 
 
@@ -321,7 +328,7 @@ const uchar* Renderer::getLastError()
 void Renderer::printLastError()
 {
 	GLenum errid = glGetError();
-	if( errid != GL_NO_ERROR )
-		ERROR( "OpenGL Error: " << gluErrorString( errid ) );
+	if(errid != GL_NO_ERROR)
+		ERROR("OpenGL Error: " << gluErrorString(errid));
 }
 

+ 61 - 60
src/Renderer/Renderer.h

@@ -15,6 +15,7 @@ class RendererInitializer;
 class SceneNode;
 
 
+
 /**
  * Offscreen renderer
  *
@@ -35,7 +36,7 @@ class Renderer
 				Renderer& r; ///< Just so that the stage can know the father class
 
 			public:
-				RenderingStage( Renderer& r_ ): r(r_) {}
+				RenderingStage(Renderer& r_): r(r_) {}
 		};
 
 		/**
@@ -54,10 +55,10 @@ class Renderer
 					friend class Renderer;
 					friend class Ms;
 
-					PROPERTY_R( bool, enabled, isEnabled )
+					PROPERTY_R(bool, enabled, isEnabled)
 
 					public:
-						Ez( Renderer& r_ ): RenderingStage( r_ ) {}
+						Ez(Renderer& r_): RenderingStage(r_) {}
 
 					private:
 						Fbo fbo;
@@ -73,7 +74,7 @@ class Renderer
 				Texture depthFai;
 				Ez ez;
 
-				Ms( Renderer& r_ ): RenderingStage( r_ ), ez( r_ ) {}
+				Ms(Renderer& r_): RenderingStage(r_), ez(r_) {}
 
 			private:
 				Fbo fbo;
@@ -98,13 +99,13 @@ class Renderer
 					friend class Is;
 					friend class Renderer;
 
-					PROPERTY_R( bool, enabled, isEnabled ) ///< If false then disable
-					PROPERTY_R( bool, pcfEnabled, isPcfEnabled ) ///< Enable Percentage Closer Filtering
-					PROPERTY_R( bool, bilinearEnabled, isBilinearEnabled ) ///< Shadowmap bilinear filtering. Better quality
-					PROPERTY_R( int, resolution, getResolution ) ///< Shadowmap resolution. The higher the better
+					PROPERTY_R(bool, enabled, isEnabled) ///< If false then disable
+					PROPERTY_R(bool, pcfEnabled, isPcfEnabled) ///< Enable Percentage Closer Filtering
+					PROPERTY_R(bool, bilinearEnabled, isBilinearEnabled) ///< Shadowmap bilinear filtering. Better quality
+					PROPERTY_R(int, resolution, getResolution) ///< Shadowmap resolution. The higher the better
 
 					public:
-						Sm( Renderer& r_ ): RenderingStage( r_ ) {}
+						Sm(Renderer& r_): RenderingStage(r_) {}
 
 					private:
 						Fbo fbo; ///< Illumination stage shadowmapping FBO
@@ -116,7 +117,7 @@ class Renderer
 						 * Render the scene only with depth and store the result in the shadowMap
 						 * @param cam The light camera
 						 */
-						void run( const Camera& cam );
+						void run(const Camera& cam);
 				}; // end Sm
 
 				/**
@@ -138,7 +139,7 @@ class Renderer
 						};
 
 					public:
-						Smo( Renderer& r_ ): RenderingStage( r_ ) {}
+						Smo(Renderer& r_): RenderingStage(r_) {}
 
 					private:
 						static float sMOUvSCoords []; ///< Illumination stage stencil masking optimizations UV sphere vertex positions
@@ -146,8 +147,8 @@ class Renderer
 						static SmoShaderProg sProg;
 
 						void init();
-						void run( const PointLight& light );
-						void run( const SpotLight& light );
+						void run(const PointLight& light);
+						void run(const SpotLight& light);
 				}; // end Smo
 
 			private:
@@ -188,7 +189,7 @@ class Renderer
 				Sm sm;
 				Smo smo;
 
-				Is( Renderer& r_ ): RenderingStage( r_ ), sm( r_ ), smo( r_ ) {}
+				Is(Renderer& r_): RenderingStage(r_), sm(r_), smo(r_) {}
 
 			private:
 				Fbo fbo; ///< This FBO writes to the Is::fai
@@ -202,9 +203,9 @@ class Renderer
 
 				void calcViewVector(); ///< Calc the view vector that we will use inside the shader to calculate the frag pos in view space
 				void calcPlanes(); ///< Calc the planes that we will use inside the shader to calculate the frag pos in view space
-				void ambientPass( const Vec3& color );
-				void pointLightPass( const PointLight& light );
-				void spotLightPass( const SpotLight& light );
+				void ambientPass(const Vec3& color);
+				void pointLightPass(const PointLight& light);
+				void spotLightPass(const SpotLight& light);
 				void initFbo();
 				void init();
 				void run();
@@ -228,8 +229,8 @@ class Renderer
 					friend class Pps;
 					friend class Renderer;
 
-					PROPERTY_R( bool, enabled, isEnabled )
-					PROPERTY_R( float, renderingQuality, getRenderingQuality )
+					PROPERTY_R(bool, enabled, isEnabled)
+					PROPERTY_R(float, renderingQuality, getRenderingQuality)
 
 					private:
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
@@ -243,7 +244,7 @@ class Renderer
 						};
 						HdrShaderProg pass0SProg, pass1SProg, pass2SProg;
 
-						void initFbos( Fbo& fbo, Texture& fai, int internalFormat );
+						void initFbos(Fbo& fbo, Texture& fai, int internalFormat);
 						void init();
 						void run();
 
@@ -252,7 +253,7 @@ class Renderer
 						Texture pass1Fai; ///< pass0Fai with the horizontal blur FAI
 						Texture fai; ///< The final FAI
 
-						Hdr( Renderer& r_ ): RenderingStage(r_) {}
+						Hdr(Renderer& r_): RenderingStage(r_) {}
 				}; // end Hrd
 
 				/**
@@ -268,9 +269,9 @@ class Renderer
 					friend class Pps;
 					friend class Renderer;
 
-					PROPERTY_R( bool, enabled, isEnabled )
-					PROPERTY_R( float, renderingQuality, getRenderingQuality )
-					PROPERTY_R( float, bluringQuality, getBluringQuality )
+					PROPERTY_R(bool, enabled, isEnabled)
+					PROPERTY_R(float, renderingQuality, getRenderingQuality)
+					PROPERTY_R(float, bluringQuality, getBluringQuality)
 
 					private:
 						Fbo pass0Fbo, pass1Fbo, pass2Fbo;
@@ -300,26 +301,26 @@ class Renderer
 						};
 						BlurSProg blurSProg, blurSProg2;
 
-						void initBlurFbo( Fbo& fbo, Texture& fai );
+						void initBlurFbo(Fbo& fbo, Texture& fai);
 						void init();
 						void run();
 
 					public:
 						Texture pass0Fai, pass1Fai, fai /** The final FAI */;
 
-						Ssao( Renderer& r_ ): RenderingStage(r_) {}
+						Ssao(Renderer& r_): RenderingStage(r_) {}
 				}; // end Ssao
 
 
-			PROPERTY_R( bool, enabled, isEnabled )
-			PROPERTY_R( float, renderingQuality, getRenderingQuality )
+			PROPERTY_R(bool, enabled, isEnabled)
+			PROPERTY_R(float, renderingQuality, getRenderingQuality)
 
 			public:
 				Texture fai;
 				Hdr hdr;
 				Ssao ssao;
 
-				Pps( Renderer& r_ ): RenderingStage(r_), hdr(r_), ssao(r_) {}
+				Pps(Renderer& r_): RenderingStage(r_), hdr(r_), ssao(r_) {}
 
 			private:
 				class PpsShaderProg: public ShaderProg
@@ -349,20 +350,20 @@ class Renderer
 		{
 			friend class Renderer;
 
-			PROPERTY_R( bool, enabled, isEnabled )
-			PROPERTY_RW( bool, showAxisEnabled, setShowAxis, isShowAxisEnabled )
-			PROPERTY_RW( bool, showLightsEnabled, setShowLights, isShowLightsEnabled )
-			PROPERTY_RW( bool, showSkeletonsEnabled, setShowSkeletons, isShowSkeletonsEnabled )
-			PROPERTY_RW( bool, showCamerasEnabled, setShowCameras, isShowCamerasEnabled )
+			PROPERTY_R(bool, enabled, isEnabled)
+			PROPERTY_RW(bool, showAxisEnabled, setShowAxis, isShowAxisEnabled)
+			PROPERTY_RW(bool, showLightsEnabled, setShowLights, isShowLightsEnabled)
+			PROPERTY_RW(bool, showSkeletonsEnabled, setShowSkeletons, isShowSkeletonsEnabled)
+			PROPERTY_RW(bool, showCamerasEnabled, setShowCameras, isShowCamerasEnabled)
 
 			public:
-				Dbg( Renderer& r_ );
+				Dbg(Renderer& r_);
 				void renderGrid();
-				static void renderSphere( int complexity, float radius = 1.0 );
-				static void renderCube( float size = 1.0 );
+				static void renderSphere(int complexity, float radius = 1.0);
+				static void renderCube(float size = 1.0);
 
-				static void setColor( const Vec4& color );
-				static void setModelMat( const Mat4& modelMat );
+				static void setColor(const Vec4& color);
+				static void setModelMat(const Mat4& modelMat);
 
 			private:
 				Fbo fbo;
@@ -376,10 +377,10 @@ class Renderer
 	//====================================================================================================================
 	// Properties                                                                                                        =
 	//====================================================================================================================
-	PROPERTY_R( uint, width, getWidth ) ///< Width of the rendering. Dont confuse with the window width
-	PROPERTY_R( uint, height, getHeight ) ///< Height of the rendering. Dont confuse with the window width
-	PROPERTY_R( uint, framesNum, getFramesNum ) ///< Frame number
-	PROPERTY_R( float, aspectRatio, getAspectRatio ) ///< Just a precalculated value
+	PROPERTY_R(uint, width, getWidth) ///< Width of the rendering. Dont confuse with the window width
+	PROPERTY_R(uint, height, getHeight) ///< Height of the rendering. Dont confuse with the window width
+	PROPERTY_R(uint, framesNum, getFramesNum) ///< Frame number
+	PROPERTY_R(float, aspectRatio, getAspectRatio) ///< Just a precalculated value
 
 	//====================================================================================================================
 	// Public                                                                                                            =
@@ -397,13 +398,13 @@ class Renderer
 		 * Init the renderer given an initialization class
 		 * @param initializer The initializer class
 		 */
-		void init( const RendererInitializer& initializer );
+		void init(const RendererInitializer& initializer);
 
 		/**
 		 * This function does all the rendering stages and produces a final FAI
 		 * @param cam The camera from where the rendering will be done
 		 */
-		void render( Camera& cam );
+		void render(Camera& cam);
 
 		/**
 		 * My version of gluUnproject
@@ -413,8 +414,8 @@ class Renderer
 		 * @param view The view vector
 		 * @return The unprojected coords coords
 		 */
-		static Vec3 unproject( const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
-		                       const int view[4] );
+		static Vec3 unproject(const Vec3& windowCoords, const Mat4& modelViewMat, const Mat4& projectionMat,
+		                       const int view[4]);
 
 		/**
 		 * It returns an orthographic projection matrix
@@ -426,7 +427,7 @@ class Renderer
 		 * @param far farther distance of depth clipping plane
 		 * @return A 4x4 projection matrix
 		 */
-		static Mat4 ortho( float left, float right, float bottom, float top, float near, float far );
+		static Mat4 ortho(float left, float right, float bottom, float top, float near, float far);
 
 		/**
 		 * Get last OpenGL error string
@@ -456,22 +457,22 @@ class Renderer
 		static float quadVertCoords [][2];
 		static int maxColorAtachments; ///< Max color attachments a FBO can accept
 
-		static void drawQuad( int vertCoordsUniLoc );
-		void setupMaterial( const Material& mtl, const SceneNode& sceneNode, const Camera& cam );
+		static void drawQuad(int vertCoordsUniLoc);
+		void setupMaterial(const Material& mtl, const SceneNode& sceneNode, const Camera& cam);
 
 		// to be removed
 	public:
-		static void color3( const Vec3& v ) { glColor3fv( &((Vec3&)v)[0] ); } ///< OpenGL wrapper
-		static void color4( const Vec4& v ) { glColor4fv( &((Vec4&)v)[0] ); } ///< OpenGL wrapper
-		static void setProjectionMatrix( const Camera& cam );
-		static void setViewMatrix( const Camera& cam );
+		static void color3(const Vec3& v) { glColor3fv(&((Vec3&)v)[0]); } ///< OpenGL wrapper
+		static void color4(const Vec4& v) { glColor4fv(&((Vec4&)v)[0]); } ///< OpenGL wrapper
+		static void setProjectionMatrix(const Camera& cam);
+		static void setViewMatrix(const Camera& cam);
 		static void noShaders() { ShaderProg::unbind(); } ///< unbind shaders @todo remove this. From now on there will be only shaders
-		static void setProjectionViewMatrices( const Camera& cam ) { setProjectionMatrix(cam); setViewMatrix(cam); }
-		static void setViewport( uint x, uint y, uint w, uint h ) { glViewport(x,y,w,h); }
-		static void multMatrix( const Mat4& m4 ) { glMultMatrixf( &(m4.getTransposed())(0,0) ); } ///< OpenGL wrapper
-		static void multMatrix( const Transform& trf ) { glMultMatrixf( &(Mat4(trf).getTransposed())(0,0) ); } ///< OpenGL wrapper
-		static void loadMatrix( const Mat4& m4 ) { glLoadMatrixf( &(m4.getTransposed())(0,0) ); } ///< OpenGL wrapper
-		static void loadMatrix( const Transform& trf ) { glLoadMatrixf( &(Mat4(trf).getTransposed())(0,0) ); } ///< OpenGL wrapper
+		static void setProjectionViewMatrices(const Camera& cam) { setProjectionMatrix(cam); setViewMatrix(cam); }
+		static void setViewport(uint x, uint y, uint w, uint h) { glViewport(x,y,w,h); }
+		static void multMatrix(const Mat4& m4) { glMultMatrixf(&(m4.getTransposed())(0, 0)); } ///< OpenGL wrapper
+		static void multMatrix(const Transform& trf) { glMultMatrixf(&(Mat4(trf).getTransposed())(0, 0)); } ///< OpenGL wrapper
+		static void loadMatrix(const Mat4& m4) { glLoadMatrixf(&(m4.getTransposed())(0, 0)); } ///< OpenGL wrapper
+		static void loadMatrix(const Transform& trf) { glLoadMatrixf(&(Mat4(trf).getTransposed())(0, 0)); } ///< OpenGL wrapper
 };
 
 #endif

+ 2 - 2
src/Renderer/RendererInitializer.h

@@ -63,9 +63,9 @@ struct RendererInitializer
 	// funcs
 	RendererInitializer() {}
 
-	RendererInitializer( const RendererInitializer& initializer )
+	RendererInitializer(const RendererInitializer& initializer)
 	{
-		memcpy( this, &initializer, sizeof(RendererInitializer) );
+		memcpy(this, &initializer, sizeof(RendererInitializer));
 	}
 };
 

+ 33 - 33
src/Renderer/Sm.cpp

@@ -20,34 +20,34 @@ void Renderer::Is::Sm::init()
 	fbo.bind();
 
 	// texture
-	shadowMap.createEmpty2D( resolution, resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, true );
-	shadowMap.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
-	if( bilinearEnabled )
+	shadowMap.createEmpty2D(resolution, resolution, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT, true);
+	shadowMap.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+	if(bilinearEnabled)
 	{
-		shadowMap.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+		shadowMap.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 	}
 	else
 	{
-		shadowMap.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+		shadowMap.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 	}
-	shadowMap.setTexParameter( GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
-	shadowMap.setTexParameter( GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );
+	shadowMap.setTexParameter(GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
+	shadowMap.setTexParameter(GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
 	/*
 	 * If you dont want to use the FFP for comparing the shadowmap (the above two lines) then you can make the comparison
-	 * inside the glsl shader. The GL_LEQUAL means that: shadow = ( R <= Dt ) ? 1.0 : 0.0; . The R is given by:
-	 * R = _tex_coord2.z/_tex_coord2.w; and the Dt = shadow2D(shadow_depth_map, _shadow_uv ).r (see lp_generic.frag).
+	 * inside the glsl shader. The GL_LEQUAL means that: shadow = (R <= Dt) ? 1.0 : 0.0; . The R is given by:
+	 * R = _tex_coord2.z/_tex_coord2.w; and the Dt = shadow2D(shadow_depth_map, _shadow_uv).r (see lp_generic.frag).
 	 * Hardware filters like GL_LINEAR cannot be applied.
 	 */
 
 	// inform the we wont write to color buffers
-	fbo.setNumOfColorAttachements( 0 );
+	fbo.setNumOfColorAttachements(0);
 
 	// attach the texture
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, shadowMap.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, shadowMap.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create shadowmapping FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create shadowmapping FBO");
 
 	// unbind
 	fbo.unbind();
@@ -57,54 +57,54 @@ void Renderer::Is::Sm::init()
 //======================================================================================================================
 // run                                                                                                                 =
 //======================================================================================================================
-void Renderer::Is::Sm::run( const Camera& cam )
+void Renderer::Is::Sm::run(const Camera& cam)
 {
 	// FBO
 	fbo.bind();
 
 	// push attribs
 	/// @todo remove the matrices
-	glMatrixMode( GL_PROJECTION );
+	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
-	glMatrixMode( GL_MODELVIEW );
+	glMatrixMode(GL_MODELVIEW);
 	glPushMatrix();
-	glPushAttrib( GL_VIEWPORT_BIT );
+	glPushAttrib(GL_VIEWPORT_BIT);
 
 
-	glClear( GL_DEPTH_BUFFER_BIT );
-	r.setProjectionViewMatrices( cam );
-	Renderer::setViewport( 0, 0, resolution, resolution );
+	glClear(GL_DEPTH_BUFFER_BIT);
+	r.setProjectionViewMatrices(cam);
+	Renderer::setViewport(0, 0, resolution, resolution);
 
 	// disable color & blend & enable depth test
-	glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
-	glEnable( GL_DEPTH_TEST );
-	glDisable( GL_BLEND );
+	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+	glEnable(GL_DEPTH_TEST);
+	glDisable(GL_BLEND);
 
 	// for artifacts
-	glPolygonOffset( 2.0, 2.0 ); // keep the values as low as possible!!!!
-	glEnable( GL_POLYGON_OFFSET_FILL );
+	glPolygonOffset(2.0, 2.0); // keep the values as low as possible!!!!
+	glEnable(GL_POLYGON_OFFSET_FILL);
 
 	// render all meshes
-	for( Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++ )
+	for(Vec<MeshNode*>::iterator it=app->getScene()->meshNodes.begin(); it!=app->getScene()->meshNodes.end(); it++)
 	{
 		MeshNode* meshNode = (*it);
-		if( meshNode->material->blends || meshNode->material->refracts ) continue;
+		if(meshNode->material->blends || meshNode->material->refracts) continue;
 
-		DEBUG_ERR( meshNode->material->dpMtl == NULL );
+		DEBUG_ERR(meshNode->material->dpMtl == NULL);
 
-		r.setupMaterial( *meshNode->material->dpMtl, *meshNode, cam );
+		r.setupMaterial(*meshNode->material->dpMtl, *meshNode, cam);
 		meshNode->renderDepth();
 	}
 
-	glDisable( GL_POLYGON_OFFSET_FILL );
+	glDisable(GL_POLYGON_OFFSET_FILL);
 
-	glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
+	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 
 	// restore attribs
 	glPopAttrib();
-	glMatrixMode( GL_MODELVIEW );
+	glMatrixMode(GL_MODELVIEW);
 	glPopMatrix();
-	glMatrixMode( GL_PROJECTION );
+	glMatrixMode(GL_PROJECTION);
 	glPopMatrix();
 
 	// FBO

+ 40 - 40
src/Renderer/Smo.cpp

@@ -20,71 +20,71 @@ Renderer::Is::Smo::SmoShaderProg Renderer::Is::Smo::sProg;
 //======================================================================================================================
 void Renderer::Is::Smo::init()
 {
-	if( sMOUvSVbo.isCreated() ) return;
+	if(sMOUvSVbo.isCreated()) return;
 
-	sMOUvSVbo.create( GL_ARRAY_BUFFER, sizeof(sMOUvSCoords), sMOUvSCoords, GL_STATIC_DRAW );
+	sMOUvSVbo.create(GL_ARRAY_BUFFER, sizeof(sMOUvSCoords), sMOUvSCoords, GL_STATIC_DRAW);
 
-	sProg.customLoad( "shaders/IsSmo.glsl" );
-	sProg.uniVars.modelViewProjectionMat = sProg.findUniVar( "modelViewProjectionMat" );
+	sProg.customLoad("shaders/IsSmo.glsl");
+	sProg.uniVars.modelViewProjectionMat = sProg.findUniVar("modelViewProjectionMat");
 }
 
 
 //======================================================================================================================
 // run [PointLight]                                                                                                    =
 //======================================================================================================================
-void Renderer::Is::Smo::run( const PointLight& light )
+void Renderer::Is::Smo::run(const PointLight& light)
 {
 	// set GL
-	glClear( GL_STENCIL_BUFFER_BIT );
-	glStencilFunc( GL_ALWAYS, 0x1, 0x1 );
-	glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
-	glColorMask( false, false, false, false );
+	glClear(GL_STENCIL_BUFFER_BIT);
+	glStencilFunc(GL_ALWAYS, 0x1, 0x1);
+	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+	glColorMask(false, false, false, false);
 
 
-	glDisable( GL_CULL_FACE );
+	glDisable(GL_CULL_FACE);
 
 	// set shared prog
 	const float scale = 1.2; // we scale the sphere a little
 	sProg.bind();
-	Mat4 modelMat = Mat4( light.getWorldTransform().getOrigin(), Mat3::getIdentity(), light.radius*scale );
-	Mat4 trf = r.cam->getProjectionMatrix() * Mat4::combineTransformations( r.cam->getViewMatrix(), modelMat );
-	sProg.uniVars.modelViewProjectionMat->setMat4( &trf );
+	Mat4 modelMat = Mat4(light.getWorldTransform().getOrigin(), Mat3::getIdentity(), light.radius*scale);
+	Mat4 trf = r.cam->getProjectionMatrix() * Mat4::combineTransformations(r.cam->getViewMatrix(), modelMat);
+	sProg.uniVars.modelViewProjectionMat->setMat4(&trf);
 
 	// render sphere to the stencil buffer
 	sMOUvSVbo.bind();
 	const int loc = 0;
-	glEnableVertexAttribArray( loc );
-	glVertexAttribPointer( loc, 3, GL_FLOAT, GL_FALSE, 0, NULL );
-	glDrawArrays( GL_TRIANGLES, 0, sizeof(sMOUvSCoords)/sizeof(float)/3 );
-	glDisableVertexAttribArray( loc );
+	glEnableVertexAttribArray(loc);
+	glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, 0, NULL);
+	glDrawArrays(GL_TRIANGLES, 0, sizeof(sMOUvSCoords)/sizeof(float)/3);
+	glDisableVertexAttribArray(loc);
 	sMOUvSVbo.unbind();
 
 	// restore GL
-	glEnable( GL_CULL_FACE );
-	glColorMask( true, true, true, true );
+	glEnable(GL_CULL_FACE);
+	glColorMask(true, true, true, true);
 
-	glStencilFunc( GL_EQUAL, 0x1, 0x1 );
-	glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
+	glStencilFunc(GL_EQUAL, 0x1, 0x1);
+	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
 }
 
 
 //======================================================================================================================
 // run [SpotLight]                                                                                                     =
 //======================================================================================================================
-void Renderer::Is::Smo::run( const SpotLight& light )
+void Renderer::Is::Smo::run(const SpotLight& light)
 {
 	// set GL state
-	glStencilFunc( GL_ALWAYS, 0x1, 0x1 );
-	glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
-	glClear( GL_STENCIL_BUFFER_BIT );
+	glStencilFunc(GL_ALWAYS, 0x1, 0x1);
+	glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+	glClear(GL_STENCIL_BUFFER_BIT);
 
-	glColorMask( false, false, false, false );
-	glDisable( GL_CULL_FACE );
+	glColorMask(false, false, false, false);
+	glDisable(GL_CULL_FACE);
 
 	// calc camera shape
 	const Camera& lcam = light.camera;
-	float x = lcam.getZFar() / tan( (PI-lcam.getFovX())/2 );
-	float y = tan( lcam.getFovY()/2 ) * lcam.getZFar();
+	float x = lcam.getZFar() / tan((PI-lcam.getFovX())/2);
+	float y = tan(lcam.getFovY()/2) * lcam.getZFar();
 	float z = -lcam.getZFar();
 
 	const int trisNum = 6;
@@ -100,21 +100,21 @@ void Renderer::Is::Smo::run( const SpotLight& light )
 
 	// shader prog
 	sProg.bind();
-	Mat4 modelMat = Mat4( lcam.getWorldTransform() );
-	Mat4 trf = r.cam->getProjectionMatrix() * Mat4::combineTransformations( r.cam->getViewMatrix(), modelMat );
-	sProg.uniVars.modelViewProjectionMat->setMat4( &trf );
+	Mat4 modelMat = Mat4(lcam.getWorldTransform());
+	Mat4 trf = r.cam->getProjectionMatrix() * Mat4::combineTransformations(r.cam->getViewMatrix(), modelMat);
+	sProg.uniVars.modelViewProjectionMat->setMat4(&trf);
 
 	// render camera shape to stencil buffer
 	const int loc = 0;
-	glEnableVertexAttribArray( loc );
-	glVertexAttribPointer( loc, 3, GL_FLOAT, false, 0, verts );
-	glDrawArrays( GL_TRIANGLES, 0, trisNum*3 );
-	glDisableVertexAttribArray( loc );
+	glEnableVertexAttribArray(loc);
+	glVertexAttribPointer(loc, 3, GL_FLOAT, false, 0, verts);
+	glDrawArrays(GL_TRIANGLES, 0, trisNum*3);
+	glDisableVertexAttribArray(loc);
 
 	// restore GL state
-	glEnable( GL_CULL_FACE );
-	glColorMask( true, true, true, true );
+	glEnable(GL_CULL_FACE);
+	glColorMask(true, true, true, true);
 
-	glStencilFunc( GL_EQUAL, 0x1, 0x1 );
-	glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
+	glStencilFunc(GL_EQUAL, 0x1, 0x1);
+	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
 }

+ 40 - 40
src/Renderer/Ssao.cpp

@@ -11,26 +11,26 @@
 //======================================================================================================================
 // initBlurFbos                                                                                                        =
 //======================================================================================================================
-void Renderer::Pps::Ssao::initBlurFbo( Fbo& fbo, Texture& fai )
+void Renderer::Pps::Ssao::initBlurFbo(Fbo& fbo, Texture& fai)
 {
 	// create FBO
 	fbo.create();
 	fbo.bind();
 
 	// inform in what buffers we draw
-	fbo.setNumOfColorAttachements( 1 );
+	fbo.setNumOfColorAttachements(1);
 
 	// create the texes
-	fai.createEmpty2D( bwidth, bheight, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false );
-	fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	fai.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	fai.createEmpty2D(bwidth, bheight, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false);
+	fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fai.getGlId(), 0);
 
 	// test if success
-	if( !fbo.isGood() )
-		FATAL( "Cannot create deferred shading post-processing stage SSAO blur FBO" );
+	if(!fbo.isGood())
+		FATAL("Cannot create deferred shading post-processing stage SSAO blur FBO");
 
 	// unbind
 	fbo.unbind();
@@ -60,33 +60,33 @@ void Renderer::Pps::Ssao::init()
 	pass0Fbo.setNumOfColorAttachements(1);
 
 	// create the FAI
-	pass0Fai.createEmpty2D( width, height, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false );
-	pass0Fai.setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	pass0Fai.setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	pass0Fai.createEmpty2D(width, height, GL_ALPHA8, GL_ALPHA, GL_FLOAT, false);
+	pass0Fai.setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	pass0Fai.setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 
 	// attach
-	glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pass0Fai.getGlId(), 0 );
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, pass0Fai.getGlId(), 0);
 
 	// test if success
-	if( !pass0Fbo.isGood() )
-		FATAL( "Cannot create deferred shading post-processing stage SSAO pass FBO" );
+	if(!pass0Fbo.isGood())
+		FATAL("Cannot create deferred shading post-processing stage SSAO pass FBO");
 
 	// unbind
 	pass0Fbo.unbind();
 
-	initBlurFbo( pass1Fbo, pass1Fai );
-	initBlurFbo( pass2Fbo, fai );
+	initBlurFbo(pass1Fbo, pass1Fai);
+	initBlurFbo(pass2Fbo, fai);
 
 
 	//
 	// Shaders
 	//
 
-	ssaoSProg.customLoad( "shaders/PpsSsao.glsl" );
-	blurSProg.customLoad( "shaders/PpsSsaoBlur.glsl", ("#define _PPS_SSAO_PASS_0_\n#define PASS0_FAI_WIDTH " +
-	                      Util::floatToStr(width) + "\n").c_str() );
-	blurSProg2.customLoad( "shaders/PpsSsaoBlur.glsl", ("#define _PPS_SSAO_PASS_1_\n#define PASS1_FAI_HEIGHT " +
-	                       Util::floatToStr(bheight) + "\n").c_str() );
+	ssaoSProg.customLoad("shaders/PpsSsao.glsl");
+	blurSProg.customLoad("shaders/PpsSsaoBlur.glsl", ("#define _PPS_SSAO_PASS_0_\n#define PASS0_FAI_WIDTH " +
+	                      Util::floatToStr(width) + "\n").c_str());
+	blurSProg2.customLoad("shaders/PpsSsaoBlur.glsl", ("#define _PPS_SSAO_PASS_1_\n#define PASS1_FAI_HEIGHT " +
+	                       Util::floatToStr(bheight) + "\n").c_str());
 
 	ssaoSProg.uniVars.camerarange = ssaoSProg.findUniVar("camerarange");
 	ssaoSProg.uniVars.msDepthFai = ssaoSProg.findUniVar("msDepthFai");
@@ -106,11 +106,11 @@ void Renderer::Pps::Ssao::init()
 	bool mipmaping = Texture::mipmappingEnabled;
 	Texture::compressionEnabled = false;
 	Texture::mipmappingEnabled = true;
-	noiseMap = Rsrc::textures.load( "gfx/noise3.tga" );
-	noiseMap->setTexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-	noiseMap->setTexParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
-	//noise_map->setTexParameter( GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-	//noise_map->setTexParameter( GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+	noiseMap = Rsrc::textures.load("gfx/noise3.tga");
+	noiseMap->setTexParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
+	noiseMap->setTexParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
+	//noise_map->setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+	//noise_map->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 	Texture::compressionEnabled = texCompr;
 	Texture::mipmappingEnabled = mipmaping;
 
@@ -124,35 +124,35 @@ void Renderer::Pps::Ssao::run()
 {
 	const Camera& cam = *r.cam;
 
-	glDisable( GL_BLEND );
-	glDisable( GL_DEPTH_TEST );
+	glDisable(GL_BLEND);
+	glDisable(GL_DEPTH_TEST);
 
 
 	// 1st pass
-	Renderer::setViewport( 0, 0, width, height );
+	Renderer::setViewport(0, 0, width, height);
 	pass0Fbo.bind();
 	ssaoSProg.bind();
-	Vec2 camRange( cam.getZNear(), cam.getZFar() );
-	ssaoSProg.uniVars.camerarange->setVec2( &camRange );
-	ssaoSProg.uniVars.msDepthFai->setTexture( r.ms.depthFai, 0 );
-	ssaoSProg.uniVars.noiseMap->setTexture( *noiseMap, 1 );
-	ssaoSProg.uniVars.msNormalFai->setTexture( r.ms.normalFai, 2 );
-	Renderer::drawQuad( 0 );
+	Vec2 camRange(cam.getZNear(), cam.getZFar());
+	ssaoSProg.uniVars.camerarange->setVec2(&camRange);
+	ssaoSProg.uniVars.msDepthFai->setTexture(r.ms.depthFai, 0);
+	ssaoSProg.uniVars.noiseMap->setTexture(*noiseMap, 1);
+	ssaoSProg.uniVars.msNormalFai->setTexture(r.ms.normalFai, 2);
+	Renderer::drawQuad(0);
 
 	// for 2nd and 3rd passes
-	Renderer::setViewport( 0, 0, bwidth, bheight );
+	Renderer::setViewport(0, 0, bwidth, bheight);
 
 	// 2nd pass
 	pass1Fbo.bind();
 	blurSProg.bind();
-	blurSProg.uniVars.fai->setTexture( pass0Fai, 0 );
-	Renderer::drawQuad( 0 );
+	blurSProg.uniVars.fai->setTexture(pass0Fai, 0);
+	Renderer::drawQuad(0);
 
 	// 3rd pass
 	pass2Fbo.bind();
 	blurSProg2.bind();
-	blurSProg2.uniVars.fai->setTexture( pass1Fai, 0 );
-	Renderer::drawQuad( 0 );
+	blurSProg2.uniVars.fai->setTexture(pass1Fai, 0);
+	Renderer::drawQuad(0);
 
 	// end
 	Fbo::unbind();

+ 9 - 9
src/Resources/Extension.cpp

@@ -2,21 +2,21 @@
 #include "Extension.h"
 
 
-bool Extension::load( const char* filename )
+bool Extension::load(const char* filename)
 {
 	// load libary
-	libHandle = dlopen( filename, RTLD_LAZY );
-	if( libHandle == NULL )
+	libHandle = dlopen(filename, RTLD_LAZY);
+	if(libHandle == NULL)
 	{
-		ERROR( "File \"" << filename << "\": " << dlerror() );
+		ERROR("File \"" << filename << "\": " << dlerror());
 		return false;
 	}
 	
 	// get FooBar
-	foobarPtr = (int(*)(void*))( dlsym(libHandle, "FooBar") );
-	if( foobarPtr == NULL )
+	foobarPtr = (int(*)(void*))(dlsym(libHandle, "FooBar"));
+	if(foobarPtr == NULL)
 	{
-		ERROR( "File \"" << filename << "\": \"FooBar\" entry symbol not found: " << dlerror() );
+		ERROR("File \"" << filename << "\": \"FooBar\" entry symbol not found: " << dlerror());
 		return false;
 	}
 	
@@ -26,8 +26,8 @@ bool Extension::load( const char* filename )
 
 void Extension::unload()
 {
-	DEBUG_ERR( libHandle==NULL || foobarPtr==NULL );
-	dlclose( libHandle );
+	DEBUG_ERR(libHandle==NULL || foobarPtr==NULL);
+	dlclose(libHandle);
 	libHandle = NULL;
 	foobarPtr = NULL;
 }

+ 2 - 2
src/Resources/Extension.h

@@ -15,9 +15,9 @@ class Extension: public Resource
 	public:
 		Extension(): libHandle(NULL), foobarPtr(NULL) {}
 		~Extension() {}
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload();
-		template<typename Type> int FooBar( Type* ptr ) { DEBUG_ERR(foobarPtr==NULL); return (*foobarPtr)( reinterpret_cast<Type*>(ptr) ); }
+		template<typename Type> int FooBar(Type* ptr) { DEBUG_ERR(foobarPtr==NULL); return (*foobarPtr)(reinterpret_cast<Type*>(ptr)); }
 };
 
 

+ 69 - 69
src/Resources/Helpers/Image.cpp

@@ -3,21 +3,21 @@
 #include "Util.h"
 
 
-unsigned char Image::tgaHeaderUncompressed[12] = {0,0,2,0,0,0,0,0,0,0,0,0};
-unsigned char Image::tgaHeaderCompressed[12]   = {0,0,10,0,0,0,0,0,0,0,0,0};
+unsigned char Image::tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+unsigned char Image::tgaHeaderCompressed[12]   = {0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 
 //======================================================================================================================
 // loadUncompressedTGA                                                                                                 =
 //======================================================================================================================
-bool Image::loadUncompressedTGA( const char* filename, fstream& fs )
+bool Image::loadUncompressedTGA(const char* filename, fstream& fs)
 {
 	// read the info from header
 	unsigned char header6[6];
-	fs.read( (char*)&header6[0], sizeof(header6) );
-	if( fs.gcount() != sizeof(header6) )
+	fs.read((char*)&header6[0], sizeof(header6));
+	if(fs.gcount() != sizeof(header6))
 	{
-		ERROR( "File \"" << filename << "\": Cannot read info header" );
+		ERROR("File \"" << filename << "\": Cannot read info header");
 		return false;
 	}
 
@@ -25,26 +25,26 @@ bool Image::loadUncompressedTGA( const char* filename, fstream& fs )
 	height = header6[3] * 256 + header6[2];
 	bpp	= header6[4];
 
-	if( (width <= 0) || (height <= 0) || ((bpp != 24) && (bpp !=32)) )
+	if((width <= 0) || (height <= 0) || ((bpp != 24) && (bpp !=32)))
 	{
-		ERROR( "File \"" << filename << "\": Invalid image information" );
+		ERROR("File \"" << filename << "\": Invalid image information");
 		return false;
 	}
 
 	// read the data
 	int bytes_per_pxl	= (bpp / 8);
 	int image_size = bytes_per_pxl * width * height;
-	data = new char [ image_size ];
+	data = new char [image_size];
 
-	fs.read( data, image_size );
-	if( fs.gcount() != image_size )
+	fs.read(data, image_size);
+	if(fs.gcount() != image_size)
 	{
-		ERROR( "File \"" << filename << "\": Cannot read image data" );
+		ERROR("File \"" << filename << "\": Cannot read image data");
 		return false;
 	}
 
 	// swap red with blue
-	for( int i=0; i<int(image_size); i+=bytes_per_pxl)
+	for(int i=0; i<int(image_size); i+=bytes_per_pxl)
 	{
 		uint temp = data[i];
 		data[i] = data[i + 2];
@@ -58,13 +58,13 @@ bool Image::loadUncompressedTGA( const char* filename, fstream& fs )
 //======================================================================================================================
 // loadCompressedTGA                                                                                                   =
 //======================================================================================================================
-bool Image::loadCompressedTGA( const char* filename, fstream& fs )
+bool Image::loadCompressedTGA(const char* filename, fstream& fs)
 {
 	unsigned char header6[6];
-	fs.read( (char*)&header6[0], sizeof(header6) );
-	if( fs.gcount() != sizeof(header6) )
+	fs.read((char*)&header6[0], sizeof(header6));
+	if(fs.gcount() != sizeof(header6))
 	{
-		ERROR( "File \"" << filename << "\": Cannot read info header" );
+		ERROR("File \"" << filename << "\": Cannot read info header");
 		return false;
 	}
 
@@ -72,9 +72,9 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 	height = header6[3] * 256 + header6[2];
 	bpp	= header6[4];
 
-	if( (width <= 0) || (height <= 0) || ((bpp != 24) && (bpp !=32)) )
+	if((width <= 0) || (height <= 0) || ((bpp != 24) && (bpp !=32)))
 	{
-		ERROR( "File \"" << filename << "\": Invalid texture information" );
+		ERROR("File \"" << filename << "\": Invalid texture information");
 		return false;
 	}
 
@@ -92,22 +92,22 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 	{
 		unsigned char chunkheader = 0;
 
-		fs.read( (char*)&chunkheader, sizeof(unsigned char) );
-		if( fs.gcount() != sizeof(unsigned char) )
+		fs.read((char*)&chunkheader, sizeof(unsigned char));
+		if(fs.gcount() != sizeof(unsigned char))
 		{
-			ERROR( "File \"" << filename << "\": Cannot read RLE header" );
+			ERROR("File \"" << filename << "\": Cannot read RLE header");
 			return false;
 		}
 
-		if( chunkheader < 128 )
+		if(chunkheader < 128)
 		{
 			chunkheader++;
-			for( int counter = 0; counter < chunkheader; counter++ )
+			for(int counter = 0; counter < chunkheader; counter++)
 			{
-				fs.read( (char*)&colorbuffer[0], bytes_per_pxl );
-				if( fs.gcount() != bytes_per_pxl )
+				fs.read((char*)&colorbuffer[0], bytes_per_pxl);
+				if(fs.gcount() != bytes_per_pxl)
 				{
-					ERROR( "File \"" << filename << "\": Cannot read image data" );
+					ERROR("File \"" << filename << "\": Cannot read image data");
 					return false;
 				}
 
@@ -115,7 +115,7 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 				data[currentbyte + 1] = colorbuffer[1];
 				data[currentbyte + 2] = colorbuffer[0];
 
-				if( bytes_per_pxl == 4 )
+				if(bytes_per_pxl == 4)
 				{
 					data[currentbyte + 3] = colorbuffer[3];
 				}
@@ -123,9 +123,9 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 				currentbyte += bytes_per_pxl;
 				currentpixel++;
 
-				if( currentpixel > pixelcount )
+				if(currentpixel > pixelcount)
 				{
-					ERROR( "File \"" << filename << "\": Too many pixels read" );
+					ERROR("File \"" << filename << "\": Too many pixels read");
 					return false;
 				}
 			}
@@ -133,20 +133,20 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 		else
 		{
 			chunkheader -= 127;
-			fs.read( (char*)&colorbuffer[0], bytes_per_pxl );
-			if( fs.gcount() != bytes_per_pxl )
+			fs.read((char*)&colorbuffer[0], bytes_per_pxl);
+			if(fs.gcount() != bytes_per_pxl)
 			{
-				ERROR( "File \"" << filename << "\": Cannot read from file" );
+				ERROR("File \"" << filename << "\": Cannot read from file");
 				return false;
 			}
 
-			for( int counter = 0; counter < chunkheader; counter++ )
+			for(int counter = 0; counter < chunkheader; counter++)
 			{
 				data[currentbyte] = colorbuffer[2];
 				data[currentbyte+1] = colorbuffer[1];
 				data[currentbyte+2] = colorbuffer[0];
 
-				if( bytes_per_pxl == 4 )
+				if(bytes_per_pxl == 4)
 				{
 					data[currentbyte + 3] = colorbuffer[3];
 				}
@@ -154,9 +154,9 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 				currentbyte += bytes_per_pxl;
 				currentpixel++;
 
-				if( currentpixel > pixelcount )
+				if(currentpixel > pixelcount)
 				{
-					ERROR( "File \"" << filename << "\": Too many pixels read" );
+					ERROR("File \"" << filename << "\": Too many pixels read");
 					return false;
 				}
 			}
@@ -170,38 +170,38 @@ bool Image::loadCompressedTGA( const char* filename, fstream& fs )
 //======================================================================================================================
 // loadTGA                                                                                                             =
 //======================================================================================================================
-bool Image::loadTGA( const char* filename )
+bool Image::loadTGA(const char* filename)
 {
 	fstream fs;
 	char my_tga_header[12];
-	fs.open( filename, ios::in|ios::binary );
+	fs.open(filename, ios::in|ios::binary);
 
-	if( !fs.good() )
+	if(!fs.good())
 	{
-		ERROR( "File \"" << filename << "\": Cannot open file" );
+		ERROR("File \"" << filename << "\": Cannot open file");
 		return false;
 	}
 
-	fs.read( &my_tga_header[0], sizeof(my_tga_header) );
-	if( fs.gcount() != sizeof(my_tga_header) )
+	fs.read(&my_tga_header[0], sizeof(my_tga_header));
+	if(fs.gcount() != sizeof(my_tga_header))
 	{
-		ERROR( "File \"" << filename << "\": Cannot read file header" );
+		ERROR("File \"" << filename << "\": Cannot read file header");
 		fs.close();
 		return false;
 	}
 
 	bool funcs_return;
-	if( memcmp(tgaHeaderUncompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0 )
+	if(memcmp(tgaHeaderUncompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0)
 	{
-		funcs_return = loadUncompressedTGA( filename, fs );
+		funcs_return = loadUncompressedTGA(filename, fs);
 	}
-	else if( memcmp(tgaHeaderCompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0 )
+	else if(memcmp(tgaHeaderCompressed, &my_tga_header[0], sizeof(my_tga_header)) == 0)
 	{
-		funcs_return = loadCompressedTGA( filename, fs );
+		funcs_return = loadCompressedTGA(filename, fs);
 	}
 	else
 	{
-		ERROR( "File \"" << filename << "\": Invalid image header" );
+		ERROR("File \"" << filename << "\": Invalid image header");
 		funcs_return = false;
 	}
 
@@ -213,13 +213,13 @@ bool Image::loadTGA( const char* filename )
 //======================================================================================================================
 // loadPNG                                                                                                             =
 //======================================================================================================================
-bool Image::loadPNG( const char* filename )
+bool Image::loadPNG(const char* filename)
 {
 	SDL_Surface *sdli;
-	sdli = IMG_Load( filename );
-	if( !sdli )
+	sdli = IMG_Load(filename);
+	if(!sdli)
 	{
-		ERROR( "File \"" << filename << "\": " << IMG_GetError() );
+		ERROR("File \"" << filename << "\": " << IMG_GetError());
 		return false;
 	}
 
@@ -228,29 +228,29 @@ bool Image::loadPNG( const char* filename )
 
 	bpp = sdli->format->BitsPerPixel;
 
-	if( bpp != 24 && bpp != 32 )
+	if(bpp != 24 && bpp != 32)
 	{
-		ERROR( "File \"" << filename << "\": The image must be 24 or 32 bits" );
-		SDL_FreeSurface( sdli );
+		ERROR("File \"" << filename << "\": The image must be 24 or 32 bits");
+		SDL_FreeSurface(sdli);
 		return false;
 	}
 
 	int bytespp = bpp/8;
 	int bytes = width * height * bytespp;
-	data = new char [ bytes ];
+	data = new char [bytes];
 
 	// copy and flip height
-	for( uint w=0; w<width; w++ )
-		for( uint h=0; h<height; h++ )
+	for(uint w=0; w<width; w++)
+		for(uint h=0; h<height; h++)
 		{
 			memcpy(
-				&data[ (width*h+w) * bytespp ],
-				&((char*)sdli->pixels)[ ( width*(height-h-1)+w ) * bytespp ],
+				&data[(width*h+w) * bytespp],
+				&((char*)sdli->pixels)[(width*(height-h-1)+w) * bytespp],
 				bytespp
 			);
 		}
 
-	SDL_FreeSurface( sdli );
+	SDL_FreeSurface(sdli);
 	return true;
 }
 
@@ -258,23 +258,23 @@ bool Image::loadPNG( const char* filename )
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool Image::load( const char* filename )
+bool Image::load(const char* filename)
 {
 	// get the extension
-	string ext = Util::getFileExtension( filename );
+	string ext = Util::getFileExtension(filename);
 
 	// load from this extension
-	if( ext == "tga" )
+	if(ext == "tga")
 	{
-		if( !loadTGA( filename ) )
+		if(!loadTGA(filename))
 		{
 			unload();
 			return false;
 		}
 	}
-	else if( ext == "png" )
+	else if(ext == "png")
 	{
-		if( !loadPNG( filename ) )
+		if(!loadPNG(filename))
 		{
 			unload();
 			return false;
@@ -282,7 +282,7 @@ bool Image::load( const char* filename )
 	}
 	else
 	{
-		ERROR( "File \"" << filename << "\": Unsupported extension" );
+		ERROR("File \"" << filename << "\": Unsupported extension");
 		return false;
 	}
 	return true;

+ 6 - 6
src/Resources/Helpers/Image.h

@@ -13,10 +13,10 @@ class Image
 		static unsigned char tgaHeaderUncompressed[12];
 		static unsigned char tgaHeaderCompressed[12];
 
-		bool loadUncompressedTGA( const char* filename, fstream& fs );
-		bool loadCompressedTGA( const char* filename, fstream& fs );
-		bool loadPNG( const char* filename );
-		bool loadTGA( const char* filename );
+		bool loadUncompressedTGA(const char* filename, fstream& fs);
+		bool loadCompressedTGA(const char* filename, fstream& fs);
+		bool loadPNG(const char* filename);
+		bool loadTGA(const char* filename);
 
 	public:
 		uint  width;
@@ -27,8 +27,8 @@ class Image
 		 Image(): data(NULL) {}
 		~Image() { unload(); }
 
-		bool load( const char* filename );
-		void unload() { if( data ) delete [] data; data=NULL; }
+		bool load(const char* filename);
+		void unload() { if(data) delete [] data; data=NULL; }
 };
 
 #endif

+ 128 - 107
src/Resources/Helpers/ShaderPrePreprocessor.cpp

@@ -4,15 +4,17 @@
 #include "Parser.h"
 #include "Util.h"
 
+const char* MULTIPLE_DEF_MSG = " already defined in the same place. Check for circular or multiple includance";
+
 
 //======================================================================================================================
 // printSourceLines                                                                                                    =
 //======================================================================================================================
 void ShaderPrePreprocessor::printSourceLines() const
 {
-	for( uint i=0; i<sourceLines.size(); ++i )
+	for(uint i=0; i<sourceLines.size(); ++i)
 	{
-		PRINT( setw(3) << i+1 << ": " << sourceLines[i] );
+		PRINT(setw(3) << i+1 << ": " << sourceLines[i]);
 	}
 }
 
@@ -22,10 +24,10 @@ void ShaderPrePreprocessor::printSourceLines() const
 //======================================================================================================================
 void ShaderPrePreprocessor::printShaderVars() const
 {
-	PRINT( "TYPE" << setw(20) << "NAME" << setw(4) << "LOC" );
-	for( uint i=0; i<output.attributes.size(); ++i )
+	PRINT("TYPE" << setw(20) << "NAME" << setw(4) << "LOC");
+	for(uint i=0; i<output.attributes.size(); ++i)
 	{
-		PRINT( setw(4) << "A" << setw(20) << output.attributes[i].name << setw(4) << output.attributes[i].customLoc );
+		PRINT(setw(4) << "A" << setw(20) << output.attributes[i].name << setw(4) << output.attributes[i].customLoc);
 	}
 }
 
@@ -33,11 +35,11 @@ void ShaderPrePreprocessor::printShaderVars() const
 //======================================================================================================================
 // findShaderVar                                                                                                       =
 //======================================================================================================================
-Vec<ShaderPrePreprocessor::ShaderVarPragma>::iterator ShaderPrePreprocessor::findShaderVar( Vec<ShaderVarPragma>& vec,
-                                                                                            const string& name ) const
+Vec<ShaderPrePreprocessor::ShaderVarPragma>::iterator ShaderPrePreprocessor::findShaderVar(Vec<ShaderVarPragma>& vec,
+                                                                                            const string& name) const
 {
 	Vec<ShaderVarPragma>::iterator it = vec.begin();
-	while( it != vec.end() && it->name != name )
+	while(it != vec.end() && it->name != name)
 	{
 		++it;
 	}
@@ -48,26 +50,26 @@ Vec<ShaderPrePreprocessor::ShaderVarPragma>::iterator ShaderPrePreprocessor::fin
 //======================================================================================================================
 // parseFileForPragmas                                                                                                 =
 //======================================================================================================================
-bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int depth )
+bool ShaderPrePreprocessor::parseFileForPragmas(const string& filename, int depth)
 {
 	// first check the depth
-	if( depth > 99 )
+	if(depth > 99)
 	{
-		ERROR( "The include depth is too high. Probably circular includance (Im in file \"" << filename << "\")" );
+		ERROR("The include depth is too high. Probably circular includance (Im in file \"" << filename << "\")");
 		return false;
 	}
 
 	// load file in lines
-	Vec<string> lines = Util::getFileLines( filename.c_str() );
-	if( lines.size() < 1 )
+	Vec<string> lines = Util::getFileLines(filename.c_str());
+	if(lines.size() < 1)
 	{
-		ERROR( "Cannot parse file \"" << filename << "\"" );
+		ERROR("Cannot parse file \"" << filename << "\"");
 		return false;
 	}
 
 	// scanner
-	Scanner scanner( false );
-	if( !scanner.loadFile( filename.c_str() ) ) return false;
+	Scanner scanner(false);
+	if(!scanner.loadFile(filename.c_str())) return false;
 	const Scanner::Token* token;
 
 	
@@ -75,245 +77,264 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 	{
 		token = &scanner.getNextToken();
 
-		if( token->getCode() == Scanner::TC_SHARP )
+		if(token->getCode() == Scanner::TC_SHARP)
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "pragma") == 0 )
+			if(token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "pragma") == 0)
 			{
 				token = &scanner.getNextToken();
-				if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "anki") == 0 )
+				if(token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "anki") == 0)
 				{
 					token = &scanner.getNextToken();
 /* vertShaderBegins */
-					if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "vertShaderBegins") == 0 )
+					if(token->getCode() == Scanner::TC_IDENTIFIER &&
+					   strcmp(token->getValue().getString(), "vertShaderBegins") == 0)
 					{
 						// play
 
 						// its defined in same place so there is probable circular includance
-						if( vertShaderBegins.definedInLine==scanner.getLineNumber() && vertShaderBegins.definedInFile==filename )
+						if(vertShaderBegins.definedInLine==scanner.getLineNumber() && vertShaderBegins.definedInFile==filename)
 						{
-							PARSE_ERR( "vertShaderBegins already defined in the same place. Check for circular or multiple includance" );
+							PARSE_ERR("vertShaderBegins" << MULTIPLE_DEF_MSG);
 							return false;
 						}
 
 						// already defined elsewhere => error
-						if( vertShaderBegins.definedInLine != -1 )
+						if(vertShaderBegins.definedInLine != -1)
 						{
-							PARSE_ERR( "vertShaderBegins already defined at " << vertShaderBegins.definedInFile << ":" <<
-							           vertShaderBegins.definedInLine );
+							PARSE_ERR("vertShaderBegins already defined at " << vertShaderBegins.definedInFile << ":" <<
+							           vertShaderBegins.definedInLine);
 							return false;
 						}
 
 						// vert shader should be before frag
-						if( fragShaderBegins.definedInLine != -1 )
+						if(fragShaderBegins.definedInLine != -1)
 						{
-							PARSE_ERR( "vertShaderBegins must precede fragShaderBegins defined at " << fragShaderBegins.definedInFile <<
-							           ":" << fragShaderBegins.definedInLine );
+							PARSE_ERR("vertShaderBegins must precede fragShaderBegins defined at " <<
+							          fragShaderBegins.definedInFile << ":" << fragShaderBegins.definedInLine);
 							return false;
 						}
 						
 						// vert shader should be before geom
-						if( geomShaderBegins.definedInLine != -1 )
+						if(geomShaderBegins.definedInLine != -1)
 						{
-							PARSE_ERR( "vertShaderBegins must precede geomShaderBegins defined at " << geomShaderBegins.definedInFile <<
-							           ":" << geomShaderBegins.definedInLine );
+							PARSE_ERR("vertShaderBegins must precede geomShaderBegins defined at " <<
+							          geomShaderBegins.definedInFile << ":" << geomShaderBegins.definedInLine);
 							return false;
 						}
 
 						vertShaderBegins.definedInFile = filename;
 						vertShaderBegins.definedInLine = scanner.getLineNumber();
 						vertShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
-						                       Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1] );
+						sourceLines.push_back(string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
+						                       Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1]);
 						// stop play
 					}
 /* geomShaderBegins */
-					else if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "geomShaderBegins") == 0 )
+					else if(token->getCode() == Scanner::TC_IDENTIFIER &&
+					        strcmp(token->getValue().getString(), "geomShaderBegins") == 0)
 					{
 						// play
 
 						// its defined in same place so there is probable circular includance
-						if( geomShaderBegins.definedInLine==scanner.getLineNumber() && geomShaderBegins.definedInFile==filename )
+						if(geomShaderBegins.definedInLine==scanner.getLineNumber() && geomShaderBegins.definedInFile==filename)
 						{
-							PARSE_ERR( "geomShaderBegins already defined in the same place. Check for circular or multiple includance" );
+							PARSE_ERR("geomShaderBegins" << MULTIPLE_DEF_MSG);
 							return false;
 						}
 
 						// already defined elsewhere => error
-						if( geomShaderBegins.definedInLine != -1 )
+						if(geomShaderBegins.definedInLine != -1)
 						{
-							PARSE_ERR( "geomShaderBegins already defined at " << geomShaderBegins.definedInFile << ":" <<
-							           geomShaderBegins.definedInLine );
+							PARSE_ERR("geomShaderBegins already defined at " << geomShaderBegins.definedInFile << ":" <<
+							           geomShaderBegins.definedInLine);
 							return false;
 						}
 
 						// vert shader entry point not defined => error
-						if( vertShaderBegins.definedInLine == -1 )
+						if(vertShaderBegins.definedInLine == -1)
 						{
-							PARSE_ERR( "geomShaderBegins must follow vertShaderBegins" );
+							PARSE_ERR("geomShaderBegins must follow vertShaderBegins");
 							return false;
 						}
 
 						// frag shader entry point defined => error
-						if( fragShaderBegins.definedInLine != -1 )
+						if(fragShaderBegins.definedInLine != -1)
 						{
-							PARSE_ERR( "geomShaderBegins must precede fragShaderBegins defined at " << fragShaderBegins.definedInFile << ":" <<
-							           fragShaderBegins.definedInLine );
+							PARSE_ERR("geomShaderBegins must precede fragShaderBegins defined at " <<
+							          fragShaderBegins.definedInFile << ":" << fragShaderBegins.definedInLine);
 							return false;
 						}
 
 						geomShaderBegins.definedInFile = filename;
 						geomShaderBegins.definedInLine = scanner.getLineNumber();
 						geomShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
-						                       Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1] );
+						sourceLines.push_back(string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
+						                       Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1]);
 						// stop play
 					}
 /* fragShaderBegins */
-					else if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "fragShaderBegins") == 0 )
+					else if(token->getCode() == Scanner::TC_IDENTIFIER &&
+					        strcmp(token->getValue().getString(), "fragShaderBegins") == 0)
 					{
 						// play
 
 						// its defined in same place so there is probable circular includance
-						if( fragShaderBegins.definedInLine==scanner.getLineNumber() && fragShaderBegins.definedInFile==filename )
+						if(fragShaderBegins.definedInLine==scanner.getLineNumber() && fragShaderBegins.definedInFile==filename)
 						{
-							PARSE_ERR( "fragShaderBegins already defined in the same place. Check for circular or multiple includance" );
+							PARSE_ERR("fragShaderBegins" << MULTIPLE_DEF_MSG);
 							return false;
 						}
 
-						if( fragShaderBegins.definedInLine != -1 ) // if already defined elsewhere throw error
+						if(fragShaderBegins.definedInLine != -1) // if already defined elsewhere throw error
 						{
-							PARSE_ERR( "fragShaderBegins already defined at " << fragShaderBegins.definedInFile << ":" <<
-							           fragShaderBegins.definedInLine );
+							PARSE_ERR("fragShaderBegins already defined at " << fragShaderBegins.definedInFile << ":" <<
+							           fragShaderBegins.definedInLine);
 							return false;
 						}
 						
 						// vert shader entry point not defined
-						if( vertShaderBegins.definedInLine == -1 )
+						if(vertShaderBegins.definedInLine == -1)
 						{
-							PARSE_ERR( "fragShaderBegins must follow vertShaderBegins" );
+							PARSE_ERR("fragShaderBegins must follow vertShaderBegins");
 							return false;
 						}
 
 						fragShaderBegins.definedInFile = filename;
 						fragShaderBegins.definedInLine = scanner.getLineNumber();
 						fragShaderBegins.globalLine = sourceLines.size() + 1;
-						sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
-						                       Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1] );
+						sourceLines.push_back(string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
+						                       Util::intToStr(depth) + " // " + lines[scanner.getLineNumber()-1]);
 						// stop play
 					}
 /* include */
-					else if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "include") == 0 )
+					else if(token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "include") == 0)
 					{
 						token = &scanner.getNextToken();
-						if( token->getCode() == Scanner::TC_STRING )
+						if(token->getCode() == Scanner::TC_STRING)
 						{
 							// play
 							//int line = sourceLines.size();
-							sourceLines.push_back( string("#line 0 ") + Util::intToStr(depth+1) + " // " + lines[scanner.getLineNumber()-1] );
-							if( !parseFileForPragmas( token->getValue().getString(), depth+1 ) ) return false;
-							sourceLines.push_back( string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
-							                       Util::intToStr(depth) +  " // end of " + lines[scanner.getLineNumber()-1] );
+							sourceLines.push_back(string("#line 0 ") + Util::intToStr(depth+1) + " // " +
+							                      lines[scanner.getLineNumber()-1]);
+							if(!parseFileForPragmas(token->getValue().getString(), depth+1)) return false;
+							sourceLines.push_back(string("#line ") + Util::intToStr(scanner.getLineNumber()) + ' ' +
+							                       Util::intToStr(depth) +  " // end of " + lines[scanner.getLineNumber()-1]);
 							// stop play
 						}
 						else
 						{
-							PARSE_ERR_EXPECTED( "string" );
+							PARSE_ERR_EXPECTED("string");
+							return false;
+						}
+					}
+/* transformFeedbackVarying */
+					else if(token->getCode() == Scanner::TC_IDENTIFIER &&
+					        strcmp(token->getValue().getString(), "transformFeedbackVarying") == 0)
+					{
+						token = &scanner.getNextToken();
+						if(token->getCode() == Scanner::TC_STRING)
+						{
+							ERROR( "todo" );
+						}
+						else
+						{
+							PARSE_ERR_EXPECTED("string");
 							return false;
 						}
 					}
 /* attribute */
-					else if( token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "attribute") == 0 )
+					else if(token->getCode() == Scanner::TC_IDENTIFIER && strcmp(token->getValue().getString(), "attribute") == 0)
 					{
 						token = &scanner.getNextToken();
-						if( token->getCode() == Scanner::TC_IDENTIFIER )
+						if(token->getCode() == Scanner::TC_IDENTIFIER)
 						{
 							string varName = token->getValue().getString();
 							token = &scanner.getNextToken();
-							if( token->getCode() == Scanner::TC_NUMBER && token->getDataType() == Scanner::DT_INT )
+							if(token->getCode() == Scanner::TC_NUMBER && token->getDataType() == Scanner::DT_INT)
 							{
-								int loc = token->getValue().getInt();
+								uint loc = token->getValue().getInt();
 
 								// check if already defined and for circular includance
-								Vec<ShaderVarPragma>::iterator attrib = findShaderVar( output.attributes, varName );
-								if( attrib != output.attributes.end() )
+								Vec<ShaderVarPragma>::iterator attrib = findShaderVar(output.attributes, varName);
+								if(attrib != output.attributes.end())
 								{
-									if( attrib->definedInLine==scanner.getLineNumber() && attrib->definedInFile==filename )
+									if(attrib->definedInLine==scanner.getLineNumber() && attrib->definedInFile==filename)
 									{
-										PARSE_ERR( "\"" << varName << "\" already defined in the same place. Check for circular or multiple includance" );
+										PARSE_ERR("\"" << varName << "\"" << MULTIPLE_DEF_MSG);
 									}
 									else
 									{
-										PARSE_ERR( "Attribute \"" << varName << "\" already defined at " << attrib->definedInFile << ":" <<
-										           attrib->definedInLine );
+										PARSE_ERR("Attribute \"" << varName << "\" already defined at " << attrib->definedInFile << ":" <<
+										           attrib->definedInLine);
 									}
 									return false;
 								}
 								// search if another var has the same loc
-								for( attrib = output.attributes.begin(); attrib!=output.attributes.end(); ++attrib )
+								for(attrib = output.attributes.begin(); attrib!=output.attributes.end(); ++attrib)
 								{
-									if( attrib->customLoc == loc )
+									if(attrib->customLoc == loc)
 									{
-										PARSE_ERR( "The attributes \"" << attrib->name << "\" (" << attrib->definedInFile << ":" <<
-										           attrib->definedInLine << ") and \"" << varName << "\" share the same location" );
+										PARSE_ERR("The attributes \"" << attrib->name << "\" (" << attrib->definedInFile << ":" <<
+										           attrib->definedInLine << ") and \"" << varName << "\" share the same location");
 										return false;
 									}
 								}
 								
 								// all ok, push it back
-								output.attributes.push_back( ShaderVarPragma( filename, scanner.getLineNumber(), varName, loc ) );
-								sourceLines.push_back( lines[scanner.getLineNumber()-1] );
+								output.attributes.push_back(ShaderVarPragma(filename, scanner.getLineNumber(), varName, loc));
+								sourceLines.push_back(lines[scanner.getLineNumber()-1]);
 							}
 							else
 							{
-								PARSE_ERR_EXPECTED( "integer" );
+								PARSE_ERR_EXPECTED("integer");
 								return false;
 							}
 						}
 						else
 						{
-							PARSE_ERR_EXPECTED( "identifier" );
+							PARSE_ERR_EXPECTED("identifier");
 							return false;
 						}
 					}
 					else
 					{
-						PARSE_WARN( "Ignoring incorrect #pragma anki" );
+						PARSE_WARN("Ignoring incorrect #pragma anki");
 					}
 				} // end if anki
 				
 				token = &scanner.getNextToken();
-				if( token->getCode()!=Scanner::TC_NEWLINE && token->getCode()!=Scanner::TC_EOF )
+				if(token->getCode()!=Scanner::TC_NEWLINE && token->getCode()!=Scanner::TC_EOF)
 				{
-					PARSE_ERR_EXPECTED( "newline or end of file" );
+					PARSE_ERR_EXPECTED("newline or end of file");
 					return false;
 				}
 				
-				if( token->getCode() == Scanner::TC_EOF )
+				if(token->getCode() == Scanner::TC_EOF)
 					break;
 				
 			} // end if pragma
 		} // end if #
 /* newline */		
-		else if( token->getCode() == Scanner::TC_NEWLINE )
+		else if(token->getCode() == Scanner::TC_NEWLINE)
 		{
-			sourceLines.push_back( lines[ scanner.getLineNumber() - 2 ] );
-			//PRINT( lines[ scanner.getLineNmbr() - 2 ] )
+			sourceLines.push_back(lines[scanner.getLineNumber() - 2]);
+			//PRINT(lines[scanner.getLineNmbr() - 2])
 		}
 /* EOF */
-		else if( token->getCode() == Scanner::TC_EOF )
+		else if(token->getCode() == Scanner::TC_EOF)
 		{
-			sourceLines.push_back( lines[ scanner.getLineNumber() - 1 ] );
-			//PRINT( lines[ scanner.getLineNmbr() - 1 ] )
+			sourceLines.push_back(lines[scanner.getLineNumber() - 1]);
+			//PRINT(lines[scanner.getLineNmbr() - 1])
 			break;
 		}
 /* error */
-		else if( token->getCode() == Scanner::TC_ERROR )
+		else if(token->getCode() == Scanner::TC_ERROR)
 		{
 			return false;
 		}
 
-	} while( true );
+	} while(true);
 	
 	return true;
 }
@@ -322,20 +343,20 @@ bool ShaderPrePreprocessor::parseFileForPragmas( const string& filename, int dep
 //======================================================================================================================
 // parseFile                                                                                                           =
 //======================================================================================================================
-bool ShaderPrePreprocessor::parseFile( const char* filename )
+bool ShaderPrePreprocessor::parseFile(const char* filename)
 {
 	// parse master file
-	if( !parseFileForPragmas( filename ) ) return false;
+	if(!parseFileForPragmas(filename)) return false;
 
 	// sanity checks
-	if( vertShaderBegins.globalLine == -1 )
+	if(vertShaderBegins.globalLine == -1)
 	{
-		ERROR( "Entry point \"vertShaderBegins\" is not defined in file \"" << filename << "\"" );
+		ERROR("Entry point \"vertShaderBegins\" is not defined in file \"" << filename << "\"");
 		return false;
 	}
-	if( fragShaderBegins.globalLine == -1 )
+	if(fragShaderBegins.globalLine == -1)
 	{
-		ERROR( "Entry point \"fragShaderBegins\" is not defined in file \"" << filename << "\"" );
+		ERROR("Entry point \"fragShaderBegins\" is not defined in file \"" << filename << "\"");
 		return false;
 	}
 	
@@ -347,11 +368,11 @@ bool ShaderPrePreprocessor::parseFile( const char* filename )
 		output.fragShaderSource = "";
 
 		// put global source code
-		for( int i=0; i<vertShaderBegins.globalLine-1; ++i )
+		for(int i=0; i<vertShaderBegins.globalLine-1; ++i)
 		{
 			output.vertShaderSource += sourceLines[i] + "\n";
 
-			if( geomShaderBegins.definedInLine != -1 )
+			if(geomShaderBegins.definedInLine != -1)
 				output.geomShaderSource += sourceLines[i] + "\n";
 
 			output.fragShaderSource += sourceLines[i] + "\n";
@@ -359,29 +380,29 @@ bool ShaderPrePreprocessor::parseFile( const char* filename )
 
 		// vert shader code
 		int limit = (geomShaderBegins.definedInLine != -1) ? geomShaderBegins.globalLine-1 : fragShaderBegins.globalLine-1;
-		for( int i=vertShaderBegins.globalLine-1; i<limit; ++i )
+		for(int i=vertShaderBegins.globalLine-1; i<limit; ++i)
 		{
 			output.vertShaderSource += sourceLines[i] + "\n";
 		}
 
 		// geom shader code
-		if( geomShaderBegins.definedInLine != -1 )
+		if(geomShaderBegins.definedInLine != -1)
 		{
-			for( int i=geomShaderBegins.globalLine-1; i<fragShaderBegins.globalLine-1; ++i )
+			for(int i=geomShaderBegins.globalLine-1; i<fragShaderBegins.globalLine-1; ++i)
 			{
 				output.geomShaderSource += sourceLines[i] + "\n";
 			}
 		}
 
 		// frag shader code
-		for( int i=fragShaderBegins.globalLine-1; i<int(sourceLines.size()); ++i )
+		for(int i=fragShaderBegins.globalLine-1; i<int(sourceLines.size()); ++i)
 		{
 			output.fragShaderSource += sourceLines[i] + "\n";
 		}
 	} // end construct shader's source code
 
-	//PRINT( "vertShaderBegins.globalLine: " << vertShaderBegins.globalLine )
-	//PRINT( "fragShaderBegins.globalLine: " << fragShaderBegins.globalLine )
+	//PRINT("vertShaderBegins.globalLine: " << vertShaderBegins.globalLine)
+	//PRINT("fragShaderBegins.globalLine: " << fragShaderBegins.globalLine)
 	//printSourceLines();
 	//printShaderVars();
 

+ 47 - 35
src/Resources/Helpers/ShaderPrePreprocessor.h

@@ -17,6 +17,9 @@
  */
 class ShaderPrePreprocessor
 {
+	//====================================================================================================================
+	// Nested                                                                                                            =
+	//====================================================================================================================
 	protected:
 		/**
 		 * The pragma base class
@@ -27,8 +30,9 @@ class ShaderPrePreprocessor
 			string definedInFile;
 			int    definedInLine;
 			Pragma(): definedInLine(-1) {}
-			Pragma( const string& definedInFile_, int definedInLine_ ):
-				definedInFile(definedInFile_), definedInLine(definedInLine_)
+			Pragma(const string& definedInFile_, int definedInLine_):
+				definedInFile(definedInFile_),
+				definedInLine(definedInLine_)
 			{}
 		};
 		
@@ -42,8 +46,8 @@ class ShaderPrePreprocessor
 			string name;
 			uint   customLoc;
 
-			ShaderVarPragma( const string& definedInFile_, int definedInLine_, const string& name_, uint customLoc_ ):
-				Pragma( definedInFile_, definedInLine_ ),
+			ShaderVarPragma(const string& definedInFile_, int definedInLine_, const string& name_, uint customLoc_):
+				Pragma(definedInFile_, definedInLine_),
 				name(name_),
 				customLoc(customLoc_)
 			{}
@@ -55,30 +59,6 @@ class ShaderPrePreprocessor
 
 			CodeBeginningPragma(): globalLine(-1) {}
 		};
-		
-		Vec<string> sourceLines;  ///< The parseFileForPragmas fills this
-		CodeBeginningPragma vertShaderBegins;
-		CodeBeginningPragma geomShaderBegins;
-		CodeBeginningPragma fragShaderBegins;
-		
-		/**
-		 * A recursive function that parses a file for pragmas and updates the output
-		 * @param filename The file to parse
-		 * @param depth The #line in GLSL does not support filename so an depth it being used. It also tracks the include depth
-		 * @return True on success
-		 */
-		bool parseFileForPragmas( const string& filename, int depth = 0 );
-
-		/**
-		 * Searches inside the Output::uniforms or Output::attributes vectors
-		 * @param vec Output::uniforms or Output::attributes
-		 * @param name The name of the location
-		 * @return Iterator to the vector
-		 */
-		Vec<ShaderVarPragma>::iterator findShaderVar( Vec<ShaderVarPragma>& vec, const string& name ) const;
-
-		void printSourceLines() const;  ///< For debugging
-		void printShaderVars() const;  ///< For debugging
 
 		/**
 		 * The output of the class packed in this struct
@@ -87,14 +67,15 @@ class ShaderPrePreprocessor
 		{
 			friend class ShaderPrePreprocessor;
 
-			PROPERTY_R( Vec<ShaderVarPragma>, attributes, getAttribLocs ) ///< It holds the name and the custom location
-			PROPERTY_R( string, vertShaderSource, getVertShaderSource ) ///< The vert shader source
-			PROPERTY_R( string, geomShaderSource, getGeomShaderSource ) ///< The geom shader source
-			PROPERTY_R( string, fragShaderSource, getFragShaderSource ) ///< The frag shader source
+			PROPERTY_R(Vec<ShaderVarPragma>, attributes, getAttribLocs) ///< It holds the name and the custom location
+			PROPERTY_R(string, vertShaderSource, getVertShaderSource) ///< The vert shader source
+			PROPERTY_R(string, geomShaderSource, getGeomShaderSource) ///< The geom shader source
+			PROPERTY_R(string, fragShaderSource, getFragShaderSource) ///< The frag shader source
 		};
 
-		Output output; ///< The output of the parser. parseFile fills it
-
+	//====================================================================================================================
+	// Public                                                                                                            =
+	//====================================================================================================================
 	public:
 		ShaderPrePreprocessor() {}
 		~ShaderPrePreprocessor() {}
@@ -104,13 +85,44 @@ class ShaderPrePreprocessor
 		 * @param fname The file to parse
 		 * @return True on success
 		 */
-		bool parseFile( const char* fname );
+		bool parseFile(const char* fname);
 
 		/**
 		 * Accessor func to get the output. Use it after calling parseFile
 		 * @return The output
 		 */
 		const Output& getOutput() const { return output; }
+
+	//====================================================================================================================
+	// Protected                                                                                                         =
+	//====================================================================================================================
+	protected:
+		Vec<string> sourceLines;  ///< The parseFileForPragmas fills this
+		CodeBeginningPragma vertShaderBegins;
+		CodeBeginningPragma geomShaderBegins;
+		CodeBeginningPragma fragShaderBegins;
+		
+		/**
+		 * A recursive function that parses a file for pragmas and updates the output
+		 * @param filename The file to parse
+		 * @param depth The #line in GLSL does not support filename so an depth it being used. It also tracks the includance
+		 * depth
+		 * @return True on success
+		 */
+		bool parseFileForPragmas(const string& filename, int depth = 0);
+
+		/**
+		 * Searches inside the Output::uniforms or Output::attributes vectors
+		 * @param vec Output::uniforms or Output::attributes
+		 * @param name The name of the location
+		 * @return Iterator to the vector
+		 */
+		Vec<ShaderVarPragma>::iterator findShaderVar(Vec<ShaderVarPragma>& vec, const string& name) const;
+
+		void printSourceLines() const;  ///< For debugging
+		void printShaderVars() const;  ///< For debugging
+
+		Output output; ///< The output of the parser. parseFile fills it
 };
 
 

+ 30 - 30
src/Resources/LightProps.cpp

@@ -6,10 +6,10 @@
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool LightProps::load( const char* filename )
+bool LightProps::load(const char* filename)
 {
 Scanner scanner;
-	if( !scanner.loadFile( filename ) ) return false;
+	if(!scanner.loadFile(filename)) return false;
 
 	const Scanner::Token* token;
 
@@ -18,90 +18,90 @@ Scanner scanner;
 		token = &scanner.getNextToken();
 
 		//** DIFFUSE_COL **
-		if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "DIFFUSE_COLOR" ) )
+		if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "DIFFUSE_COLOR"))
 		{
-			Parser::parseArrOfNumbers<float>( scanner, true, true, 3, &diffuseCol[0] );
+			Parser::parseArrOfNumbers<float>(scanner, true, true, 3, &diffuseCol[0]);
 		}
 		//** SPECULAR_COL **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "SPECULAR_COLOR" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "SPECULAR_COLOR"))
 		{
-			Parser::parseArrOfNumbers<float>( scanner, true, true, 3, &specularCol[0] );
+			Parser::parseArrOfNumbers<float>(scanner, true, true, 3, &specularCol[0]);
 		}
 		//** RADIUS **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "RADIUS" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "RADIUS"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 
 			radius = (token->getDataType() == Scanner::DT_FLOAT) ? token->getValue().getFloat() : float(token->getValue().getInt());
 		}
 		//** CASTS_SHADOW **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "CASTS_SHADOW" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "CASTS_SHADOW"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+			if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 
 			castsShadow_ = token->getValue().getInt();
 		}
 		//** DISTANCE **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "DISTANCE" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "DISTANCE"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 
 			distance = (token->getDataType() == Scanner::DT_FLOAT) ? token->getValue().getFloat() : float(token->getValue().getInt());
 		}
 		//** FOV_X **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "FOV_X" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "FOV_X"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 
 			fovX = (token->getDataType() == Scanner::DT_FLOAT) ? token->getValue().getFloat() : float(token->getValue().getInt());
 		}
 		//** FOV_Y **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "FOV_Y" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "FOV_Y"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 
 			fovY = (token->getDataType() == Scanner::DT_FLOAT) ? token->getValue().getFloat() : float(token->getValue().getInt());
 		}
 		//** TEXTURE **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "TEXTURE" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "TEXTURE"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_STRING )
+			if(token->getCode() != Scanner::TC_STRING)
 			{
-				PARSE_ERR_EXPECTED( "string" );
+				PARSE_ERR_EXPECTED("string");
 				return false;
 			}
 				
-			texture = Rsrc::textures.load( token->getValue().getString() );
-			texture->setTexParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, 0 );
+			texture = Rsrc::textures.load(token->getValue().getString());
+			texture->setTexParameter(GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
 		}
 		// end of file
-		else if( token->getCode() == Scanner::TC_EOF )
+		else if(token->getCode() == Scanner::TC_EOF)
 		{
 			break;
 		}
@@ -112,7 +112,7 @@ Scanner scanner;
 			return false;
 		}
 
-	}while( true );
+	}while(true);
 	
 	return true;
 }
@@ -123,6 +123,6 @@ Scanner scanner;
 //======================================================================================================================
 void LightProps::unload()
 {
-	if( texture != NULL )
-		Rsrc::textures.unload( texture );
+	if(texture != NULL)
+		Rsrc::textures.unload(texture);
 }

+ 8 - 8
src/Resources/LightProps.h

@@ -13,13 +13,13 @@ class Texture;
 class LightProps: public Resource
 {
 	// data
-	PROPERTY_R( Vec3, diffuseCol, getDiffuseColor )
-	PROPERTY_R( Vec3, specularCol, getSpecularColor )
-	PROPERTY_R( float, radius, getRadius ) ///< For point lights
-	PROPERTY_R( bool, castsShadow_, castsShadow ) ///< For spot lights
-	PROPERTY_R( float, distance, getDistance ) ///< For spot lights. A.K.A.: camera's zFar
-	PROPERTY_R( float, fovX, getFovX ) ///< For spot lights
-	PROPERTY_R( float, fovY, getFovY ) ///< For spot lights
+	PROPERTY_R(Vec3, diffuseCol, getDiffuseColor)
+	PROPERTY_R(Vec3, specularCol, getSpecularColor)
+	PROPERTY_R(float, radius, getRadius) ///< For point lights
+	PROPERTY_R(bool, castsShadow_, castsShadow) ///< For spot lights
+	PROPERTY_R(float, distance, getDistance) ///< For spot lights. A.K.A.: camera's zFar
+	PROPERTY_R(float, fovX, getFovX) ///< For spot lights
+	PROPERTY_R(float, fovY, getFovY) ///< For spot lights
 		
 	private:
 		Texture* texture; ///< For spot lights
@@ -39,7 +39,7 @@ class LightProps: public Resource
 			texture(NULL) 
 		{}
 		virtual ~LightProps() { /* ToDo */ }
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload();
 };
 

+ 89 - 86
src/Resources/Material.cpp

@@ -10,13 +10,13 @@
 
 
 /// Customized @ref ERROR used in @ref Material class
-#define MTL_ERROR( x ) ERROR( "Material (" << getRsrcPath() << getRsrcName() << "): " << x );
+#define MTL_ERROR(x) ERROR("Material (" << getRsrcPath() << getRsrcName() << "): " << x);
 
 
 //======================================================================================================================
 // Statics                                                                                                             =
 //======================================================================================================================
-Material::StdVarInfo Material::stdAttribVarInfos[ SAV_NUM ] =
+Material::StdVarInfo Material::stdAttribVarInfos[SAV_NUM] =
 {
 	{ "position", GL_FLOAT_VEC3 },
 	{ "tangent", GL_FLOAT_VEC4 },
@@ -27,7 +27,7 @@ Material::StdVarInfo Material::stdAttribVarInfos[ SAV_NUM ] =
 	{ "vertWeightWeights", GL_FLOAT_VEC4 }
 };
 
-Material::StdVarInfo Material::stdUniVarInfos[ SUV_NUM ] =
+Material::StdVarInfo Material::stdUniVarInfos[SUV_NUM] =
 {
 	{ "skinningRotations", GL_FLOAT_MAT3},
 	{ "skinningTranslations", GL_FLOAT_VEC3 },
@@ -43,7 +43,8 @@ Material::StdVarInfo Material::stdUniVarInfos[ SUV_NUM ] =
 	{ "msDepthFai", GL_SAMPLER_2D },
 	{ "isFai", GL_SAMPLER_2D },
 	{ "ppsFai", GL_SAMPLER_2D },
-	{ "rendererSize", GL_FLOAT_VEC2 }
+	{ "rendererSize", GL_FLOAT_VEC2 },
+	{ "sceneAmbientColor", GL_FLOAT_VEC3 }
 };
 
 
@@ -73,11 +74,11 @@ static BlendParam blendingParams [] =
 
 const int BLEND_PARAMS_NUM = 11;
 
-static bool searchBlendEnum( const char* str, int& gl_enum )
+static bool searchBlendEnum(const char* str, int& gl_enum)
 {
-	for( int i=0; i<BLEND_PARAMS_NUM; i++ )
+	for(int i=0; i<BLEND_PARAMS_NUM; i++)
 	{
-		if( !strcmp( blendingParams[i].str, str) )
+		if(!strcmp(blendingParams[i].str, str))
 		{
 			gl_enum = blendingParams[i].glEnum;
 			return true;
@@ -90,10 +91,10 @@ static bool searchBlendEnum( const char* str, int& gl_enum )
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool Material::load( const char* filename )
+bool Material::load(const char* filename)
 {
 	Scanner scanner;
-	if( !scanner.loadFile( filename ) ) return false;
+	if(!scanner.loadFile(filename)) return false;
 
 	const Scanner::Token* token;
 
@@ -102,135 +103,135 @@ bool Material::load( const char* filename )
 		token = &scanner.getNextToken();
 
 		//** SHADER_PROG **
-		if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "SHADER_PROG" ) )
+		if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "SHADER_PROG"))
 		{
-			if( shaderProg ) ERROR( "Shader program already loaded" );
+			if(shaderProg) ERROR("Shader program already loaded");
 
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_STRING )
+			if(token->getCode() != Scanner::TC_STRING)
 			{
-				PARSE_ERR_EXPECTED( "string" );
+				PARSE_ERR_EXPECTED("string");
 				return false;
 			}
-			shaderProg = Rsrc::shaders.load( token->getValue().getString() );
+			shaderProg = Rsrc::shaders.load(token->getValue().getString());
 		}
 		//** DEPTH_MATERIAL **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "DEPTH_PASS_MATERIAL" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "DEPTH_PASS_MATERIAL"))
 		{
-			if( dpMtl ) ERROR( "Depth material already loaded" );
+			if(dpMtl) ERROR("Depth material already loaded");
 
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_STRING )
+			if(token->getCode() != Scanner::TC_STRING)
 			{
-				PARSE_ERR_EXPECTED( "string" );
+				PARSE_ERR_EXPECTED("string");
 				return false;
 			}
-			dpMtl = Rsrc::materials.load( token->getValue().getString() );
+			dpMtl = Rsrc::materials.load(token->getValue().getString());
 		}
 		//** BLENDS **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "BLENDS" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "BLENDS"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 			blends = token->getValue().getInt();
 		}
 		//** REFRACTS **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "REFRACTS" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "REFRACTS"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 			refracts = token->getValue().getInt();
 		}
 		//** BLENDING_SFACTOR **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "BLENDING_SFACTOR" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "BLENDING_SFACTOR"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_IDENTIFIER )
+			if(token->getCode() != Scanner::TC_IDENTIFIER)
 			{
-				PARSE_ERR_EXPECTED( "identifier" );
+				PARSE_ERR_EXPECTED("identifier");
 				return false;
 			}
 			int gl_enum;
-			if( !searchBlendEnum(token->getValue().getString(), gl_enum) )
+			if(!searchBlendEnum(token->getValue().getString(), gl_enum))
 			{
-				PARSE_ERR( "Incorrect blending factor \"" << token->getValue().getString() << "\"" );
+				PARSE_ERR("Incorrect blending factor \"" << token->getValue().getString() << "\"");
 				return false;
 			}
 			blendingSfactor = gl_enum;
 		}
 		//** BLENDING_DFACTOR **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "BLENDING_DFACTOR" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "BLENDING_DFACTOR"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_IDENTIFIER )
+			if(token->getCode() != Scanner::TC_IDENTIFIER)
 			{
-				PARSE_ERR_EXPECTED( "identifier" );
+				PARSE_ERR_EXPECTED("identifier");
 				return false;
 			}
 			int gl_enum;
-			if( !searchBlendEnum(token->getValue().getString(), gl_enum) )
+			if(!searchBlendEnum(token->getValue().getString(), gl_enum))
 			{
-				PARSE_ERR( "Incorrect blending factor \"" << token->getValue().getString() << "\"" );
+				PARSE_ERR("Incorrect blending factor \"" << token->getValue().getString() << "\"");
 				return false;
 			}
 			blendingDfactor = gl_enum;
 		}
 		//** DEPTH_TESTING **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "DEPTH_TESTING" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "DEPTH_TESTING"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 			depthTesting = token->getValue().getInt();
 		}
 		//** WIREFRAME **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "WIREFRAME" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "WIREFRAME"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 			wireframe = token->getValue().getInt();
 		}
 		//** CASTS_SHADOW **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "CASTS_SHADOW" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "CASTS_SHADOW"))
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER )
+			if(token->getCode() != Scanner::TC_NUMBER)
 			{
-				PARSE_ERR_EXPECTED( "number" );
+				PARSE_ERR_EXPECTED("number");
 				return false;
 			}
 			castsShadow = token->getValue().getInt();
 		}
 		//** USER_DEFINED_VARS **
-		else if( token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "USER_DEFINED_VARS" ) )
+		else if(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "USER_DEFINED_VARS"))
 		{
 			// first check if the shader is defined
-			if( shaderProg == NULL )
+			if(shaderProg == NULL)
 			{
-				PARSE_ERR( "You have to define the shader program before the user defined vars" );
+				PARSE_ERR("You have to define the shader program before the user defined vars");
 				return false;
 			}
 
 			// read {
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_LBRACKET )
+			if(token->getCode() != Scanner::TC_LBRACKET)
 			{
-				PARSE_ERR_EXPECTED( "{" );
+				PARSE_ERR_EXPECTED("{");
 				return false;
 			}
 			// loop all the vars
@@ -238,67 +239,67 @@ bool Material::load( const char* filename )
 			{
 				// read the name
 				token = &scanner.getNextToken();
-				if( token->getCode() == Scanner::TC_RBRACKET ) break;
+				if(token->getCode() == Scanner::TC_RBRACKET) break;
 
-				if( token->getCode() != Scanner::TC_IDENTIFIER )
+				if(token->getCode() != Scanner::TC_IDENTIFIER)
 				{
-					PARSE_ERR_EXPECTED( "identifier" );
+					PARSE_ERR_EXPECTED("identifier");
 					return false;
 				}
 
 				string varName;
 				varName = token->getValue().getString();
 
-				userDefinedVars.push_back( UserDefinedUniVar() ); // create new var
+				userDefinedVars.push_back(UserDefinedUniVar()); // create new var
 				UserDefinedUniVar& var = userDefinedVars.back();
 
 				// check if the uniform exists
-				if( !shaderProg->uniVarExists( varName.c_str() ) )
+				if(!shaderProg->uniVarExists(varName.c_str()))
 				{
-					PARSE_ERR( "The variable \"" << varName << "\" is not an active uniform" );
+					PARSE_ERR("The variable \"" << varName << "\" is not an active uniform");
 					return false;
 				}
 
-				var.sProgVar = shaderProg->findUniVar( varName.c_str() );
+				var.sProgVar = shaderProg->findUniVar(varName.c_str());
 
 				// read the values
-				switch( var.sProgVar->getGlDataType() )
+				switch(var.sProgVar->getGlDataType())
 				{
 					// texture
 					case GL_SAMPLER_2D:
 						token = &scanner.getNextToken();
-						if( token->getCode() == Scanner::TC_STRING )
+						if(token->getCode() == Scanner::TC_STRING)
 						{
-							var.value.texture = Rsrc::textures.load( token->getValue().getString() );
+							var.value.texture = Rsrc::textures.load(token->getValue().getString());
 						}
 						else
 						{
-							PARSE_ERR_EXPECTED( "string" );
+							PARSE_ERR_EXPECTED("string");
 							return false;
 						}
 						break;
 					// float
 					case GL_FLOAT:
 						token = &scanner.getNextToken();
-						if( token->getCode() == Scanner::TC_NUMBER && token->getDataType() == Scanner::DT_FLOAT )
+						if(token->getCode() == Scanner::TC_NUMBER && token->getDataType() == Scanner::DT_FLOAT)
 							var.value.float_ = token->getValue().getFloat();
 						else
 						{
-							PARSE_ERR_EXPECTED( "float" );
+							PARSE_ERR_EXPECTED("float");
 							return false;
 						}
 						break;
 					// vec2
 					case GL_FLOAT_VEC2:
-						if( !Parser::parseArrOfNumbers<float>( scanner, true, true, 2, &var.value.vec2[0] ) ) return false;
+						if(!Parser::parseArrOfNumbers<float>(scanner, true, true, 2, &var.value.vec2[0])) return false;
 						break;
 					// vec3
 					case GL_FLOAT_VEC3:
-						if( !Parser::parseArrOfNumbers<float>( scanner, true, true, 3, &var.value.vec3[0] ) ) return false;
+						if(!Parser::parseArrOfNumbers<float>(scanner, true, true, 3, &var.value.vec3[0])) return false;
 						break;
 					// vec4
 					case GL_FLOAT_VEC4:
-						if( !Parser::parseArrOfNumbers<float>( scanner, true, true, 4, &var.value.vec4[0] ) ) return false;
+						if(!Parser::parseArrOfNumbers<float>(scanner, true, true, 4, &var.value.vec4[0])) return false;
 						break;
 				};
 
@@ -306,7 +307,7 @@ bool Material::load( const char* filename )
 
 		}
 		// end of file
-		else if( token->getCode() == Scanner::TC_EOF )
+		else if(token->getCode() == Scanner::TC_EOF)
 		{
 			break;
 		}
@@ -317,7 +318,7 @@ bool Material::load( const char* filename )
 			return false;
 		}
 
-	}while( true );
+	}while(true);
 
 	return initStdShaderVars();
 }
@@ -329,52 +330,54 @@ bool Material::load( const char* filename )
 bool Material::initStdShaderVars()
 {
 	// sanity checks
-	if( !shaderProg )
+	if(!shaderProg)
 	{
-		MTL_ERROR( "Without shader is like cake without sugar (missing SHADER_PROG)" );
+		MTL_ERROR("Without shader is like cake without sugar (missing SHADER_PROG)");
 		return false;
 	}
 
 	// the attributes
-	for( uint i=0; i<SAV_NUM; i++ )
+	for(uint i=0; i<SAV_NUM; i++)
 	{
 		// if the var is not in the sProg then... bye
-		if( !shaderProg->attribVarExists( stdAttribVarInfos[i].varName ) )
+		if(!shaderProg->attribVarExists(stdAttribVarInfos[i].varName))
 		{
-			stdAttribVars[ i ] = NULL;
+			stdAttribVars[i] = NULL;
 			continue;
 		}
 
 		// set the std var
-		stdAttribVars[ i ] = shaderProg->findAttribVar( stdAttribVarInfos[i].varName );
+		stdAttribVars[i] = shaderProg->findAttribVar(stdAttribVarInfos[i].varName);
 
 		// check if the shader has different GL data type from that it suppose to have
-		if( stdAttribVars[ i ]->getGlDataType() != stdAttribVarInfos[i].dataType )
+		if(stdAttribVars[i]->getGlDataType() != stdAttribVarInfos[i].dataType)
 		{
-			MTL_ERROR( "The \"" << stdAttribVarInfos[i].varName << "\" attribute var has incorrect GL data type from the expected (0x" <<
-			           hex << stdAttribVars[ i ]->getGlDataType() << ")" );
+			MTL_ERROR("The \"" << stdAttribVarInfos[i].varName <<
+			          "\" attribute var has incorrect GL data type from the expected (0x" << hex <<
+			          stdAttribVars[i]->getGlDataType() << ")");
 			return false;
 		}
 	}
 
 	// the uniforms
-	for( uint i=0; i<SUV_NUM; i++ )
+	for(uint i=0; i<SUV_NUM; i++)
 	{
 		// if the var is not in the sProg then... bye
-		if( !shaderProg->uniVarExists( stdUniVarInfos[i].varName ) )
+		if(!shaderProg->uniVarExists(stdUniVarInfos[i].varName))
 		{
-			stdUniVars[ i ] = NULL;
+			stdUniVars[i] = NULL;
 			continue;
 		}
 
 		// set the std var
-		stdUniVars[ i ] = shaderProg->findUniVar( stdUniVarInfos[i].varName );
+		stdUniVars[i] = shaderProg->findUniVar(stdUniVarInfos[i].varName);
 
 		// check if the shader has different GL data type from that it suppose to have
-		if( stdUniVars[ i ]->getGlDataType() != stdUniVarInfos[i].dataType )
+		if(stdUniVars[i]->getGlDataType() != stdUniVarInfos[i].dataType)
 		{
-			MTL_ERROR( "The \"" << stdUniVarInfos[i].varName << "\" uniform var has incorrect GL data type from the expected (0x" <<
-			           hex << stdUniVars[ i ]->getGlDataType() << ")" );
+			MTL_ERROR("The \"" << stdUniVarInfos[i].varName <<
+			          "\" uniform var has incorrect GL data type from the expected (0x" << hex <<
+			          stdUniVars[i]->getGlDataType() << ")");
 			return false;
 		}
 	}
@@ -405,12 +408,12 @@ Material::Material()
 //======================================================================================================================
 void Material::unload()
 {
-	Rsrc::shaders.unload( shaderProg );
+	Rsrc::shaders.unload(shaderProg);
 
 	// loop all user defined vars and unload the textures
-	for( uint i=0; i<userDefinedVars.size(); i++ )
+	for(uint i=0; i<userDefinedVars.size(); i++)
 	{
-		Rsrc::textures.unload( userDefinedVars[i].value.texture );
+		Rsrc::textures.unload(userDefinedVars[i].value.texture);
 	}
 }
 

+ 8 - 7
src/Resources/Material.h

@@ -68,6 +68,7 @@ class Material: public Resource
 			SUV_PPS_FAI,
 			// Other
 			SUV_RENDERER_SIZE,
+			SUV_SCENE_AMBIENT_COLOR,
 			// num
 			SUV_NUM ///< The number of standard uniform variables
 		};
@@ -107,10 +108,10 @@ class Material: public Resource
 		}; // end UserDefinedVar
 
 
-		static StdVarInfo stdAttribVarInfos[ SAV_NUM ];
-		static StdVarInfo stdUniVarInfos[ SUV_NUM ];
-		const ShaderProg::AttribVar* stdAttribVars[ SAV_NUM ];
-		const ShaderProg::UniVar* stdUniVars[ SUV_NUM ];
+		static StdVarInfo stdAttribVarInfos[SAV_NUM];
+		static StdVarInfo stdUniVarInfos[SUV_NUM];
+		const ShaderProg::AttribVar* stdAttribVars[SAV_NUM];
+		const ShaderProg::UniVar* stdUniVars[SUV_NUM];
 		ShaderProg* shaderProg; ///< The most important aspect of materials
 		Material* dpMtl; ///< The material for depth passes. To be removed when skinning is done using tranform feedback
 		Vec<UserDefinedUniVar> userDefinedVars;
@@ -131,12 +132,12 @@ class Material: public Resource
 		 */
 		bool initStdShaderVars();
 
-		bool hasHWSkinning() const { return stdAttribVars[ SAV_VERT_WEIGHT_BONES_NUM ] != NULL; }
-		bool hasAlphaTesting() const { return dpMtl!=NULL && dpMtl->stdAttribVars[ SAV_TEX_COORDS ] != NULL; }
+		bool hasHWSkinning() const { return stdAttribVars[SAV_VERT_WEIGHT_BONES_NUM] != NULL; }
+		bool hasAlphaTesting() const { return dpMtl!=NULL && dpMtl->stdAttribVars[SAV_TEX_COORDS] != NULL; }
 
 	public:
 		Material();
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload();
 };
 

+ 84 - 84
src/Resources/Mesh.cpp

@@ -8,28 +8,28 @@
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool Mesh::load( const char* filename )
+bool Mesh::load(const char* filename)
 {
 	Scanner scanner;
-	if( !scanner.loadFile( filename ) ) return false;
+	if(!scanner.loadFile(filename)) return false;
 
 	const Scanner::Token* token;
 
 
 	//** MATERIAL **
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_STRING )
+	if(token->getCode() != Scanner::TC_STRING)
 	{
-		PARSE_ERR_EXPECTED( "string" );
+		PARSE_ERR_EXPECTED("string");
 		return false;
 	}
 	materialName = token->getValue().getString();
 
 	//** DP_MATERIAL **
 	/*token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_STRING )
+	if(token->getCode() != Scanner::TC_STRING)
 	{
-		PARSE_ERR_EXPECTED( "string" );
+		PARSE_ERR_EXPECTED("string");
 		return false;
 	}
 	dp_materialName = token->getValue().getString();*/
@@ -37,99 +37,99 @@ bool Mesh::load( const char* filename )
 	//** VERTS **
 	// verts num
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	vertCoords.resize( token->getValue().getInt() );
+	vertCoords.resize(token->getValue().getInt());
 
 	// read the verts
-	for( uint i=0; i<vertCoords.size(); i++ )
+	for(uint i=0; i<vertCoords.size(); i++)
 	{
-		if( !Parser::parseArrOfNumbers<float>( scanner, false, true, 3, &vertCoords[i][0] ) ) return false;
+		if(!Parser::parseArrOfNumbers<float>(scanner, false, true, 3, &vertCoords[i][0])) return false;
 	}
 
 	//** FACES **
 	// faces num
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	tris.resize( token->getValue().getInt() );
+	tris.resize(token->getValue().getInt());
 	// read the faces
-	for( uint i=0; i<tris.size(); i++ )
+	for(uint i=0; i<tris.size(); i++)
 	{
-		if( !Parser::parseArrOfNumbers<uint>( scanner, false, true, 3, tris[i].vertIds ) ) return false;
+		if(!Parser::parseArrOfNumbers<uint>(scanner, false, true, 3, tris[i].vertIds)) return false;
 	}
 
 	//** UVS **
 	// UVs num
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	texCoords.resize( token->getValue().getInt() );
+	texCoords.resize(token->getValue().getInt());
 	// read the texCoords
-	for( uint i=0; i<texCoords.size(); i++ )
+	for(uint i=0; i<texCoords.size(); i++)
 	{
-		if( !Parser::parseArrOfNumbers( scanner, false, true, 2, &texCoords[i][0] ) ) return false;
+		if(!Parser::parseArrOfNumbers(scanner, false, true, 2, &texCoords[i][0])) return false;
 	}
 
 	//** VERTEX WEIGHTS **
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	vertWeights.resize( token->getValue().getInt() );
-	for( uint i=0; i<vertWeights.size(); i++ )
+	vertWeights.resize(token->getValue().getInt());
+	for(uint i=0; i<vertWeights.size(); i++)
 	{
 		// get the bone connections num
 		token = &scanner.getNextToken();
-		if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+		if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 		{
-			PARSE_ERR_EXPECTED( "integer" );
+			PARSE_ERR_EXPECTED("integer");
 			return false;
 		}
 
 		// we treat as error if one vert doesnt have a bone
-		if( token->getValue().getInt() < 1 )
+		if(token->getValue().getInt() < 1)
 		{
-			ERROR( "Vert \"" << i << "\" doesnt have at least one bone" );
+			ERROR("Vert \"" << i << "\" doesnt have at least one bone");
 			return false;
 		}
 
 		// and here is another possible error
-		if( token->getValue().getInt() > VertexWeight::MAX_BONES_PER_VERT )
+		if(token->getValue().getInt() > VertexWeight::MAX_BONES_PER_VERT)
 		{
-			ERROR( "Cannot have more than " << VertexWeight::MAX_BONES_PER_VERT << " bones per vertex" );
+			ERROR("Cannot have more than " << VertexWeight::MAX_BONES_PER_VERT << " bones per vertex");
 			return false;
 		}
 		vertWeights[i].bonesNum = token->getValue().getInt();
 
 		// for all the weights of the current vertes
-		for( uint j=0; j<vertWeights[i].bonesNum; j++ )
+		for(uint j=0; j<vertWeights[i].bonesNum; j++)
 		{
 			// read bone id
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+			if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 			{
-				PARSE_ERR_EXPECTED( "integer" );
+				PARSE_ERR_EXPECTED("integer");
 				return false;
 			}
 			vertWeights[i].boneIds[j] = token->getValue().getInt();
 
 			// read the weight of that bone
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_FLOAT )
+			if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_FLOAT)
 			{
-				PARSE_ERR_EXPECTED( "float" );
+				PARSE_ERR_EXPECTED("float");
 				return false;
 			}
 			vertWeights[i].weights[j] = token->getValue().getFloat();
@@ -137,24 +137,24 @@ bool Mesh::load( const char* filename )
 	}
 
 	// Sanity checks
-	if( vertCoords.size()<1 || tris.size()<1 )
+	if(vertCoords.size()<1 || tris.size()<1)
 	{
-		ERROR( "Vert coords and tris must be filled \"" << filename << "\"" );
+		ERROR("Vert coords and tris must be filled \"" << filename << "\"");
 		return false;
 	}
-	if( texCoords.size()!=0 && texCoords.size()!=vertCoords.size() )
+	if(texCoords.size()!=0 && texCoords.size()!=vertCoords.size())
 	{
-		ERROR( "Tex coords num must be zero or equal to vertex coords num \"" << filename << "\"" );
+		ERROR("Tex coords num must be zero or equal to vertex coords num \"" << filename << "\"");
 		return false;
 	}
-	if( vertWeights.size()!=0 && vertWeights.size()!=vertCoords.size() )
+	if(vertWeights.size()!=0 && vertWeights.size()!=vertCoords.size())
 	{
-		ERROR( "Vert weights num must be zero or equal to vertex coords num \"" << filename << "\"" );
+		ERROR("Vert weights num must be zero or equal to vertex coords num \"" << filename << "\"");
 		return false;
 	}
 
 	createAllNormals();
-	if( texCoords.size() > 0 ) createVertTangents();
+	if(texCoords.size() > 0) createVertTangents();
 	createVertIndeces();
 	createVbos();
 	calcBSphere();
@@ -177,10 +177,10 @@ void Mesh::unload()
 //======================================================================================================================
 void Mesh::createVertIndeces()
 {
-	DEBUG_ERR( vertIndeces.size() > 0 );
+	DEBUG_ERR(vertIndeces.size() > 0);
 
-	vertIndeces.resize( tris.size() * 3 );
-	for( uint i=0; i<tris.size(); i++ )
+	vertIndeces.resize(tris.size() * 3);
+	for(uint i=0; i<tris.size(); i++)
 	{
 		vertIndeces[i*3+0] = tris[i].vertIds[0];
 		vertIndeces[i*3+1] = tris[i].vertIds[1];
@@ -194,14 +194,14 @@ void Mesh::createVertIndeces()
 //======================================================================================================================
 void Mesh::createFaceNormals()
 {
-	for( uint i=0; i<tris.size(); i++ )
+	for(uint i=0; i<tris.size(); i++)
 	{
 		Triangle& tri = tris[i];
-		const Vec3& v0 = vertCoords[ tri.vertIds[0] ];
-		const Vec3& v1 = vertCoords[ tri.vertIds[1] ];
-		const Vec3& v2 = vertCoords[ tri.vertIds[2] ];
+		const Vec3& v0 = vertCoords[tri.vertIds[0]];
+		const Vec3& v1 = vertCoords[tri.vertIds[1]];
+		const Vec3& v2 = vertCoords[tri.vertIds[2]];
 
-		tri.normal = ( v1 - v0 ).cross( v2 - v0 );
+		tri.normal = (v1 - v0).cross(v2 - v0);
 
 		tri.normal.normalize();
 	}
@@ -213,20 +213,20 @@ void Mesh::createFaceNormals()
 //======================================================================================================================
 void Mesh::createVertNormals()
 {
-	vertNormals.resize( vertCoords.size() ); // alloc
+	vertNormals.resize(vertCoords.size()); // alloc
 
-	for( uint i=0; i<vertCoords.size(); i++ )
-		vertNormals[i] = Vec3( 0.0, 0.0, 0.0 );
+	for(uint i=0; i<vertCoords.size(); i++)
+		vertNormals[i] = Vec3(0.0, 0.0, 0.0);
 
-	for( uint i=0; i<tris.size(); i++ )
+	for(uint i=0; i<tris.size(); i++)
 	{
 		const Triangle& tri = tris[i];
-		vertNormals[ tri.vertIds[0] ] += tri.normal;
-		vertNormals[ tri.vertIds[1] ] += tri.normal;
-		vertNormals[ tri.vertIds[2] ] += tri.normal;
+		vertNormals[tri.vertIds[0]] += tri.normal;
+		vertNormals[tri.vertIds[1]] += tri.normal;
+		vertNormals[tri.vertIds[2]] += tri.normal;
 	}
 
-	for( uint i=0; i<vertNormals.size(); i++ )
+	for(uint i=0; i<vertNormals.size(); i++)
 		vertNormals[i].normalize();
 }
 
@@ -236,25 +236,25 @@ void Mesh::createVertNormals()
 //======================================================================================================================
 void Mesh::createVertTangents()
 {
-	vertTangents.resize( vertCoords.size() ); // alloc
+	vertTangents.resize(vertCoords.size()); // alloc
 
-	Vec<Vec3> bitagents( vertCoords.size() );
+	Vec<Vec3> bitagents(vertCoords.size());
 
-	for( uint i=0; i<vertTangents.size(); i++ )
+	for(uint i=0; i<vertTangents.size(); i++)
 	{
-		vertTangents[i] = Vec4( 0.0 );
-		bitagents[i] = Vec3( 0.0 );
+		vertTangents[i] = Vec4(0.0);
+		bitagents[i] = Vec3(0.0);
 	}
 
-	for( uint i=0; i<tris.size(); i++ )
+	for(uint i=0; i<tris.size(); i++)
 	{
 		const Triangle& tri = tris[i];
 		const int i0 = tri.vertIds[0];
 		const int i1 = tri.vertIds[1];
 		const int i2 = tri.vertIds[2];
-		const Vec3& v0 = vertCoords[ i0 ];
-		const Vec3& v1 = vertCoords[ i1 ];
-		const Vec3& v2 = vertCoords[ i2 ];
+		const Vec3& v0 = vertCoords[i0];
+		const Vec3& v1 = vertCoords[i1];
+		const Vec3& v2 = vertCoords[i2];
 		Vec3 edge01 = v1 - v0;
 		Vec3 edge02 = v2 - v0;
 		Vec2 uvedge01 = texCoords[i1] - texCoords[i0];
@@ -262,11 +262,11 @@ void Mesh::createVertTangents()
 
 
 		float det = (uvedge01.y * uvedge02.x) - (uvedge01.x * uvedge02.y);
-		DEBUG_ERR( isZero(det) );
+		DEBUG_ERR(isZero(det));
 		det = 1.0f / det;
 
-		Vec3 t = ( edge02 * uvedge01.y - edge01 * uvedge02.y ) * det;
-		Vec3 b = ( edge02 * uvedge01.x - edge01 * uvedge02.x ) * det;
+		Vec3 t = (edge02 * uvedge01.y - edge01 * uvedge02.y) * det;
+		Vec3 b = (edge02 * uvedge01.x - edge01 * uvedge02.x) * det;
 		t.normalize();
 		b.normalize();
 
@@ -279,7 +279,7 @@ void Mesh::createVertTangents()
 		bitagents[i2] += b;
 	}
 
-	for( uint i=0; i<vertTangents.size(); i++ )
+	for(uint i=0; i<vertTangents.size(); i++)
 	{
 		Vec3 t = Vec3(vertTangents[i]);
 		const Vec3& n = vertNormals[i];
@@ -290,9 +290,9 @@ void Mesh::createVertTangents()
 
 		b.normalize();
 
-		float w = ( (n.cross(t)).dot( b ) < 0.0) ? 1.0 : -1.0;
+		float w = ((n.cross(t)).dot(b) < 0.0) ? 1.0 : -1.0;
 
-		vertTangents[i] = Vec4( t, w );
+		vertTangents[i] = Vec4(t, w);
 	}
 
 	bitagents.clear();
@@ -304,15 +304,15 @@ void Mesh::createVertTangents()
 //======================================================================================================================
 void Mesh::createVbos()
 {
-	vbos.vertIndeces.create( GL_ELEMENT_ARRAY_BUFFER, vertIndeces.getSizeInBytes(), &vertIndeces[0], GL_STATIC_DRAW );
-	vbos.vertCoords.create( GL_ARRAY_BUFFER, vertCoords.getSizeInBytes(), &vertCoords[0], GL_STATIC_DRAW );
-	vbos.vertNormals.create( GL_ARRAY_BUFFER, vertNormals.getSizeInBytes(), &vertNormals[0], GL_STATIC_DRAW );
-	if( vertTangents.size() > 1 )
-		vbos.vertTangents.create( GL_ARRAY_BUFFER, vertTangents.getSizeInBytes(), &vertTangents[0], GL_STATIC_DRAW );
-	if( texCoords.size() > 1 )
-		vbos.texCoords.create( GL_ARRAY_BUFFER, texCoords.getSizeInBytes(), &texCoords[0], GL_STATIC_DRAW );
-	if( vertWeights.size() > 1 )
-		vbos.vertWeights.create( GL_ARRAY_BUFFER, vertWeights.getSizeInBytes(), &vertWeights[0], GL_STATIC_DRAW );
+	vbos.vertIndeces.create(GL_ELEMENT_ARRAY_BUFFER, vertIndeces.getSizeInBytes(), &vertIndeces[0], GL_STATIC_DRAW);
+	vbos.vertCoords.create(GL_ARRAY_BUFFER, vertCoords.getSizeInBytes(), &vertCoords[0], GL_STATIC_DRAW);
+	vbos.vertNormals.create(GL_ARRAY_BUFFER, vertNormals.getSizeInBytes(), &vertNormals[0], GL_STATIC_DRAW);
+	if(vertTangents.size() > 1)
+		vbos.vertTangents.create(GL_ARRAY_BUFFER, vertTangents.getSizeInBytes(), &vertTangents[0], GL_STATIC_DRAW);
+	if(texCoords.size() > 1)
+		vbos.texCoords.create(GL_ARRAY_BUFFER, texCoords.getSizeInBytes(), &texCoords[0], GL_STATIC_DRAW);
+	if(vertWeights.size() > 1)
+		vbos.vertWeights.create(GL_ARRAY_BUFFER, vertWeights.getSizeInBytes(), &vertWeights[0], GL_STATIC_DRAW);
 }
 
 
@@ -321,5 +321,5 @@ void Mesh::createVbos()
 //======================================================================================================================
 void Mesh::calcBSphere()
 {
-	bsphere.Set( &vertCoords[0], 0, vertCoords.size() );
+	bsphere.Set(&vertCoords[0], 0, vertCoords.size());
 }

+ 1 - 1
src/Resources/Mesh.h

@@ -66,7 +66,7 @@ class Mesh: public Resource
 	public:
 		Mesh() {}
 		virtual ~Mesh() { /*ToDo*/ }
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload();
 
 };

+ 1 - 1
src/Resources/Path.h

@@ -17,7 +17,7 @@ class Path: public Resource
 
 		Path() {}
 		~Path() {}
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload() { points.clear(); }
 };
 

+ 28 - 28
src/Resources/Resource.h

@@ -25,9 +25,9 @@ template< typename Type > class Container;
  */
 class Resource
 {
-	PROPERTY_R( string, path, getRsrcPath );
-	PROPERTY_R( string, name, getRsrcName );
-	PROPERTY_R( uint, usersNum, getRsrcUsersNum );
+	PROPERTY_R(string, path, getRsrcPath);
+	PROPERTY_R(string, name, getRsrcName);
+	PROPERTY_R(uint, usersNum, getRsrcUsersNum);
 
 	// friends
 	friend class Rsrc::Container<Texture>;
@@ -44,7 +44,7 @@ class Resource
 		 * @param filename The file to load
 		 * @return True on success
 		 */
-		virtual bool load( const char* filename ) = 0;
+		virtual bool load(const char* filename) = 0;
 		virtual void unload() = 0;
 
 		Resource(): usersNum(0) {}
@@ -77,12 +77,12 @@ template<typename Type> class Container: public Vec<Type*>
 		 * @param name The name of the resource
 		 * @return The iterator of the content end of vector if not found
 		 */
-		Iterator findByName( const char* name )
+		Iterator findByName(const char* name)
 		{
 			Iterator it = BaseClass::begin();
-			while( it != BaseClass::end() )
+			while(it != BaseClass::end())
 			{
-				if( (*it).name == name )
+				if((*it).name == name)
 					return it;
 				++it;
 			}
@@ -97,12 +97,12 @@ template<typename Type> class Container: public Vec<Type*>
 		 * @param path The path of the resource
 		 * @return The iterator of the content end of vector if not found
 		 */
-		Iterator findByNameAndPath( const char* name, const char* path )
+		Iterator findByNameAndPath(const char* name, const char* path)
 		{
 			Iterator it = BaseClass::begin();
-			while( it != BaseClass::end() )
+			while(it != BaseClass::end())
 			{
-				if( (*it)->name == name && (*it)->path == path )
+				if((*it)->name == name && (*it)->path == path)
 					return it;
 				++it;
 			}
@@ -116,12 +116,12 @@ template<typename Type> class Container: public Vec<Type*>
 		 * @param name The name of the resource object
 		 * @return The iterator of the content end of vector if not found
 		 */
-		Iterator findByPtr( Type* ptr )
+		Iterator findByPtr(Type* ptr)
 		{
 			Iterator it = BaseClass::begin();
-			while( it != BaseClass::end() )
+			while(it != BaseClass::end())
 			{
-				if( ptr == (*it) )
+				if(ptr == (*it))
 					return it;
 				++it;
 			}
@@ -135,14 +135,14 @@ template<typename Type> class Container: public Vec<Type*>
 		 * @param fname The filename that initializes the object
 		 * @return A pointer of a new resource or NULL on fail
 		 */
-		Type* load( const char* fname )
+		Type* load(const char* fname)
 		{
-			char* name = Util::cutPath( fname );
-			string path = Util::getPath( fname );
-			Iterator it = findByNameAndPath( name, path.c_str() );
+			char* name = Util::cutPath(fname);
+			string path = Util::getPath(fname);
+			Iterator it = findByNameAndPath(name, path.c_str());
 
 			// if already loaded then inc the users and return the pointer
-			if( it != BaseClass::end() )
+			if(it != BaseClass::end())
 			{
 				++ (*it)->usersNum;
 				return (*it);
@@ -154,13 +154,13 @@ template<typename Type> class Container: public Vec<Type*>
 			new_instance->path = path;
 			new_instance->usersNum = 1;
 
-			if( !new_instance->load( fname ) )
+			if(!new_instance->load(fname))
 			{
-				ERROR( "Cannot load \"" << fname << '\"' );
+				ERROR("Cannot load \"" << fname << '\"');
 				delete new_instance;
 				return NULL;
 			}
-			BaseClass::push_back( new_instance );
+			BaseClass::push_back(new_instance);
 
 			return new_instance;
 		}
@@ -170,26 +170,26 @@ template<typename Type> class Container: public Vec<Type*>
 		 * unload item. If nobody else uses it then delete it completely
 		 * @param x Pointer to the instance we want to unload
 		 */
-		void unload( Type* x )
+		void unload(Type* x)
 		{
-			Iterator it = findByPtr( x );
-			if( it == BaseClass::end() )
+			Iterator it = findByPtr(x);
+			if(it == BaseClass::end())
 			{
-				ERROR( "Cannot find resource with pointer 0x" << x );
+				ERROR("Cannot find resource with pointer 0x" << x);
 				return;
 			}
 
 			Type* del_ = (*it);
-			DEBUG_ERR( del_->usersNum < 1 ); // WTF?
+			DEBUG_ERR(del_->usersNum < 1); // WTF?
 
 			--del_->usersNum;
 
 			// if no other users then call unload and update the container
-			if( del_->usersNum == 0 )
+			if(del_->usersNum == 0)
 			{
 				del_->unload();
 				delete del_;
-				BaseClass::erase( it );
+				BaseClass::erase(it);
 			}
 		}
 }; // end class Container

+ 107 - 107
src/Resources/ShaderProg.cpp

@@ -4,8 +4,8 @@
 #include "Texture.h"
 
 
-#define SHADER_ERROR( x ) ERROR( "Shader (" << getRsrcName() << "): " << x )
-#define SHADER_WARNING( x ) WARNING( "Shader (" << getRsrcName() << "): " << x )
+#define SHADER_ERROR(x) ERROR("Shader (" << getRsrcName() << "): " << x)
+#define SHADER_WARNING(x) WARNING("Shader (" << getRsrcName() << "): " << x)
 
 
 //======================================================================================================================
@@ -28,104 +28,104 @@ string ShaderProg::stdSourceCode(
  * - if the current shader program is the var's shader program
  * - if the GL driver gives the same location as the one the var has
  */
-#define STD_SET_UNI_CHECK() DEBUG_ERR( getLoc() == -1 ); \
-                            DEBUG_ERR( ShaderProg::getCurrentProgramGlId() != fatherSProg->getGlId() ); \
-                            DEBUG_ERR( glGetUniformLocation( fatherSProg->getGlId(), getName().c_str() ) != getLoc() );
+#define STD_SET_UNI_CHECK() DEBUG_ERR(getLoc() == -1); \
+                            DEBUG_ERR(ShaderProg::getCurrentProgramGlId() != fatherSProg->getGlId()); \
+                            DEBUG_ERR(glGetUniformLocation(fatherSProg->getGlId(), getName().c_str()) != getLoc());
 
 
-void ShaderProg::UniVar::setFloat( float f ) const
+void ShaderProg::UniVar::setFloat(float f) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT );
-	glUniform1f( getLoc(), f );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT);
+	glUniform1f(getLoc(), f);
 }
 
-void ShaderProg::UniVar::setFloatVec( float f[], uint size ) const
+void ShaderProg::UniVar::setFloatVec(float f[], uint size) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT );
-	glUniform1fv( getLoc(), size, f );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT);
+	glUniform1fv(getLoc(), size, f);
 }
 
-void ShaderProg::UniVar::setVec2( const Vec2 v2[], uint size ) const
+void ShaderProg::UniVar::setVec2(const Vec2 v2[], uint size) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT_VEC2 );
-	glUniform2fv( getLoc(), size, &( const_cast<Vec2&>(v2[0]) )[0] );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT_VEC2);
+	glUniform2fv(getLoc(), size, &(const_cast<Vec2&>(v2[0]))[0]);
 }
 
-void ShaderProg::UniVar::setVec3( const Vec3 v3[], uint size ) const
+void ShaderProg::UniVar::setVec3(const Vec3 v3[], uint size) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT_VEC3 );
-	glUniform3fv( getLoc(), size, &( const_cast<Vec3&>(v3[0]) )[0] );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT_VEC3);
+	glUniform3fv(getLoc(), size, &(const_cast<Vec3&>(v3[0]))[0]);
 }
 
-void ShaderProg::UniVar::setVec4( const Vec4 v4[], uint size ) const
+void ShaderProg::UniVar::setVec4(const Vec4 v4[], uint size) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT_VEC4 );
-	glUniform4fv( getLoc(), size, &( const_cast<Vec4&>(v4[0]) )[0] );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT_VEC4);
+	glUniform4fv(getLoc(), size, &(const_cast<Vec4&>(v4[0]))[0]);
 }
 
-void ShaderProg::UniVar::setMat3( const Mat3 m3[], uint size ) const
+void ShaderProg::UniVar::setMat3(const Mat3 m3[], uint size) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT_MAT3 );
-	glUniformMatrix3fv( getLoc(), size, true, &(m3[0])[0] );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT_MAT3);
+	glUniformMatrix3fv(getLoc(), size, true, &(m3[0])[0]);
 }
 
-void ShaderProg::UniVar::setMat4( const Mat4 m4[], uint size ) const
+void ShaderProg::UniVar::setMat4(const Mat4 m4[], uint size) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_FLOAT_MAT4 );
-	glUniformMatrix4fv( getLoc(), size, true, &(m4[0])[0] );
+	DEBUG_ERR(getGlDataType() != GL_FLOAT_MAT4);
+	glUniformMatrix4fv(getLoc(), size, true, &(m4[0])[0]);
 }
 
-void ShaderProg::UniVar::setTexture( const Texture& tex, uint texUnit ) const
+void ShaderProg::UniVar::setTexture(const Texture& tex, uint texUnit) const
 {
 	STD_SET_UNI_CHECK();
-	DEBUG_ERR( getGlDataType() != GL_SAMPLER_2D && getGlDataType() != GL_SAMPLER_2D_SHADOW );
-	tex.bind( texUnit );
-	glUniform1i( getLoc(), texUnit );
+	DEBUG_ERR(getGlDataType() != GL_SAMPLER_2D && getGlDataType() != GL_SAMPLER_2D_SHADOW);
+	tex.bind(texUnit);
+	glUniform1i(getLoc(), texUnit);
 }
 
 
 //======================================================================================================================
 // createAndCompileShader                                                                                              =
 //======================================================================================================================
-uint ShaderProg::createAndCompileShader( const char* sourceCode, const char* preproc, int type ) const
+uint ShaderProg::createAndCompileShader(const char* sourceCode, const char* preproc, int type) const
 {
 	uint glId = 0;
 	const char* sourceStrs[2] = {NULL, NULL};
 
 	// create the shader
-	glId = glCreateShader( type );
+	glId = glCreateShader(type);
 
 	// attach the source
 	sourceStrs[1] = sourceCode;
 	sourceStrs[0] = preproc;
 
 	// compile
-	glShaderSource( glId, 2, sourceStrs, NULL );
-	glCompileShader( glId );
+	glShaderSource(glId, 2, sourceStrs, NULL);
+	glCompileShader(glId);
 
 	int success;
-	glGetShaderiv( glId, GL_COMPILE_STATUS, &success );
+	glGetShaderiv(glId, GL_COMPILE_STATUS, &success);
 
-	if( !success )
+	if(!success)
 	{
 		// print info log
 		int info_len = 0;
 		int charsWritten = 0;
 		char* infoLog = NULL;
 
-		glGetShaderiv( glId, GL_INFO_LOG_LENGTH, &info_len );
-		infoLog = (char*)malloc( (info_len+1)*sizeof(char) );
-		glGetShaderInfoLog( glId, info_len, &charsWritten, infoLog );
+		glGetShaderiv(glId, GL_INFO_LOG_LENGTH, &info_len);
+		infoLog = (char*)malloc((info_len+1)*sizeof(char));
+		glGetShaderInfoLog(glId, info_len, &charsWritten, infoLog);
 		
 		const char* shaderType;
-		switch( type )
+		switch(type)
 		{
 			case GL_VERTEX_SHADER:
 				shaderType = "Vertex shader";
@@ -134,11 +134,11 @@ uint ShaderProg::createAndCompileShader( const char* sourceCode, const char* pre
 				shaderType = "Fragment shader";
 				break;
 			default:
-				DEBUG_ERR( 1 ); // Not supported
+				DEBUG_ERR(1); // Not supported
 		}
-		SHADER_ERROR( shaderType << " compiler log follows:\n" << infoLog );
+		SHADER_ERROR(shaderType << " compiler log follows:\n" << infoLog);
 		
-		free( infoLog );
+		free(infoLog);
 		return 0;
 	}
 
@@ -152,24 +152,24 @@ uint ShaderProg::createAndCompileShader( const char* sourceCode, const char* pre
 bool ShaderProg::link()
 {
 	// link
-	glLinkProgram( glId );
+	glLinkProgram(glId);
 
 	// check if linked correctly
 	int success;
-	glGetProgramiv( glId, GL_LINK_STATUS, &success );
+	glGetProgramiv(glId, GL_LINK_STATUS, &success);
 
-	if( !success )
+	if(!success)
 	{
 		int info_len = 0;
 		int chars_written = 0;
 		char* info_log_txt = NULL;
 
-		glGetProgramiv( glId, GL_INFO_LOG_LENGTH, &info_len );
+		glGetProgramiv(glId, GL_INFO_LOG_LENGTH, &info_len);
 
-		info_log_txt = (char*)malloc( (info_len+1)*sizeof(char) );
-		glGetProgramInfoLog( glId, info_len, &chars_written, info_log_txt );
-		SHADER_ERROR( "Link log follows:\n" << info_log_txt );
-		free( info_log_txt );
+		info_log_txt = (char*)malloc((info_len+1)*sizeof(char));
+		glGetProgramInfoLog(glId, info_len, &chars_written, info_log_txt);
+		SHADER_ERROR("Link log follows:\n" << info_log_txt);
+		free(info_log_txt);
 		return false;
 	}
 
@@ -190,44 +190,44 @@ void ShaderProg::getUniAndAttribVars()
 
 
 	// attrib locations
-	glGetProgramiv( glId, GL_ACTIVE_ATTRIBUTES, &num );
-	attribVars.reserve( num );
-	for( int i=0; i<num; i++ ) // loop all attributes
+	glGetProgramiv(glId, GL_ACTIVE_ATTRIBUTES, &num);
+	attribVars.reserve(num);
+	for(int i=0; i<num; i++) // loop all attributes
 	{
-		glGetActiveAttrib( glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
-		name_[ length ] = '\0';
+		glGetActiveAttrib(glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_);
+		name_[length] = '\0';
 
 		// check if its FFP location
 		int loc = glGetAttribLocation(glId, name_);
-		if( loc == -1 ) // if -1 it means that its an FFP var
+		if(loc == -1) // if -1 it means that its an FFP var
 		{
-			SHADER_WARNING( "You are using FFP vertex attributes (\"" << name_ << "\")" );
+			SHADER_WARNING("You are using FFP vertex attributes (\"" << name_ << "\")");
 			continue;
 		}
 
-		attribVars.push_back( AttribVar( loc, name_, type, this ) );
-		attribNameToVar[ name_ ] = &attribVars.back();
+		attribVars.push_back(AttribVar(loc, name_, type, this));
+		attribNameToVar[name_] = &attribVars.back();
 	}
 
 
 	// uni locations
-	glGetProgramiv( glId, GL_ACTIVE_UNIFORMS, &num );
-	uniVars.reserve( num );
-	for( int i=0; i<num; i++ ) // loop all uniforms
+	glGetProgramiv(glId, GL_ACTIVE_UNIFORMS, &num);
+	uniVars.reserve(num);
+	for(int i=0; i<num; i++) // loop all uniforms
 	{
-		glGetActiveUniform( glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_ );
-		name_[ length ] = '\0';
+		glGetActiveUniform(glId, i, sizeof(name_)/sizeof(char), &length, &size, &type, name_);
+		name_[length] = '\0';
 
 		// check if its FFP location
 		int loc = glGetUniformLocation(glId, name_);
-		if( loc == -1 ) // if -1 it means that its an FFP var
+		if(loc == -1) // if -1 it means that its an FFP var
 		{
-			SHADER_WARNING( "You are using FFP uniforms (\"" << name_ << "\")" );
+			SHADER_WARNING("You are using FFP uniforms (\"" << name_ << "\")");
 			continue;
 		}
 
-		uniVars.push_back( UniVar( loc, name_, type, this ) );
-		uniNameToVar[ name_ ] = &uniVars.back();
+		uniVars.push_back(UniVar(loc, name_, type, this));
+		uniNameToVar[name_] = &uniVars.back();
 	}
 }
 
@@ -235,20 +235,20 @@ void ShaderProg::getUniAndAttribVars()
 //======================================================================================================================
 // bindCustomAttribLocs                                                                                                =
 //======================================================================================================================
-bool ShaderProg::bindCustomAttribLocs( const ShaderPrePreprocessor& pars ) const
+bool ShaderProg::bindCustomAttribLocs(const ShaderPrePreprocessor& pars) const
 {
-	for( uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i )
+	for(uint i=0; i<pars.getOutput().getAttribLocs().size(); ++i)
 	{
 		const string& name = pars.getOutput().getAttribLocs()[i].name;
 		int loc = pars.getOutput().getAttribLocs()[i].customLoc;
-		glBindAttribLocation( glId, loc, name.c_str() );
+		glBindAttribLocation(glId, loc, name.c_str());
 
 		// check for error
 		GLenum errId = glGetError();
-		if( errId != GL_NO_ERROR )
+		if(errId != GL_NO_ERROR)
 		{
-			SHADER_ERROR( "Something went wrong for attrib \"" << name << "\" and location " << loc << " (" <<
-			              gluErrorString( errId ) << ")" );
+			SHADER_ERROR("Something went wrong for attrib \"" << name << "\" and location " << loc << " (" <<
+			              gluErrorString(errId) << ")");
 			return false;
 		}
 	}
@@ -259,9 +259,9 @@ bool ShaderProg::bindCustomAttribLocs( const ShaderPrePreprocessor& pars ) const
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool ShaderProg::load( const char* filename )
+bool ShaderProg::load(const char* filename)
 {
-	if( !customLoad( filename, "" ) ) return false;
+	if(!customLoad(filename, "")) return false;
 	return true;
 }
 
@@ -269,45 +269,45 @@ bool ShaderProg::load( const char* filename )
 //======================================================================================================================
 // customLoad                                                                                                          =
 //======================================================================================================================
-bool ShaderProg::customLoad( const char* filename, const char* extraSource )
+bool ShaderProg::customLoad(const char* filename, const char* extraSource)
 {
-	DEBUG_ERR( glId != numeric_limits<uint>::max() );
+	DEBUG_ERR(glId != numeric_limits<uint>::max());
 
-	if( getRsrcName().length() == 0 )
+	if(getRsrcName().length() == 0)
 	{
-		name = Util::cutPath( filename );
-		path = Util::getPath( filename );
+		name = Util::cutPath(filename);
+		path = Util::getPath(filename);
 	}
 
 	ShaderPrePreprocessor pars;
 
-	if( !pars.parseFile( filename ) ) return false;
+	if(!pars.parseFile(filename)) return false;
 
 	// 1) create and compile the shaders
 	string preprocSource = stdSourceCode + extraSource;
-	uint vertGlId = createAndCompileShader( pars.getOutput().getVertShaderSource().c_str(), preprocSource.c_str(),
-	                                        GL_VERTEX_SHADER );
-	if( vertGlId == 0 ) return false;
+	uint vertGlId = createAndCompileShader(pars.getOutput().getVertShaderSource().c_str(), preprocSource.c_str(),
+	                                        GL_VERTEX_SHADER);
+	if(vertGlId == 0) return false;
 
-	uint fragGlId = createAndCompileShader( pars.getOutput().getFragShaderSource().c_str(), preprocSource.c_str(),
-	                                        GL_FRAGMENT_SHADER );
-	if( fragGlId == 0 ) return false;
+	uint fragGlId = createAndCompileShader(pars.getOutput().getFragShaderSource().c_str(), preprocSource.c_str(),
+	                                        GL_FRAGMENT_SHADER);
+	if(fragGlId == 0) return false;
 
 	// 2) create program and attach shaders
 	glId = glCreateProgram();
-	if( glId == 0 )
+	if(glId == 0)
 	{
-		ERROR( "glCreateProgram failed" );
+		ERROR("glCreateProgram failed");
 		return false;
 	}
-	glAttachShader( glId, vertGlId );
-	glAttachShader( glId, fragGlId );
+	glAttachShader(glId, vertGlId);
+	glAttachShader(glId, fragGlId);
 
 	// 3) bind the custom attrib locs
-	if( !bindCustomAttribLocs( pars ) ) return false;
+	if(!bindCustomAttribLocs(pars)) return false;
 
 	// 5) link
-	if( !link() ) return false;
+	if(!link()) return false;
 	
 
 	// init the rest
@@ -320,12 +320,12 @@ bool ShaderProg::customLoad( const char* filename, const char* extraSource )
 //======================================================================================================================
 // findUniVar                                                                                                          =
 //======================================================================================================================
-const ShaderProg::UniVar* ShaderProg::findUniVar( const char* name ) const
+const ShaderProg::UniVar* ShaderProg::findUniVar(const char* name) const
 {
-	NameToUniVarIterator it = uniNameToVar.find( name );
-	if( it == uniNameToVar.end() )
+	NameToUniVarIterator it = uniNameToVar.find(name);
+	if(it == uniNameToVar.end())
 	{
-		SHADER_ERROR( "Cannot get uniform loc \"" << name << '\"' );
+		SHADER_ERROR("Cannot get uniform loc \"" << name << '\"');
 		return NULL;
 	}
 	return it->second;
@@ -335,12 +335,12 @@ const ShaderProg::UniVar* ShaderProg::findUniVar( const char* name ) const
 //======================================================================================================================
 // findAttribVar                                                                                                       =
 //======================================================================================================================
-const ShaderProg::AttribVar* ShaderProg::findAttribVar( const char* name ) const
+const ShaderProg::AttribVar* ShaderProg::findAttribVar(const char* name) const
 {
-	NameToAttribVarIterator it = attribNameToVar.find( name );
-	if( it == attribNameToVar.end() )
+	NameToAttribVarIterator it = attribNameToVar.find(name);
+	if(it == attribNameToVar.end())
 	{
-		SHADER_ERROR( "Cannot get attribute loc \"" << name << '\"' );
+		SHADER_ERROR("Cannot get attribute loc \"" << name << '\"');
 		return NULL;
 	}
 	return it->second;
@@ -350,9 +350,9 @@ const ShaderProg::AttribVar* ShaderProg::findAttribVar( const char* name ) const
 //======================================================================================================================
 // uniVarExists                                                                                                        =
 //======================================================================================================================
-bool ShaderProg::uniVarExists( const char* name ) const
+bool ShaderProg::uniVarExists(const char* name) const
 {
-	NameToUniVarIterator it = uniNameToVar.find( name );
+	NameToUniVarIterator it = uniNameToVar.find(name);
 	return it != uniNameToVar.end();
 }
 
@@ -360,9 +360,9 @@ bool ShaderProg::uniVarExists( const char* name ) const
 //======================================================================================================================
 // attribVarExists                                                                                                     =
 //======================================================================================================================
-bool ShaderProg::attribVarExists( const char* name ) const
+bool ShaderProg::attribVarExists(const char* name) const
 {
-	NameToAttribVarIterator it = attribNameToVar.find( name );
+	NameToAttribVarIterator it = attribNameToVar.find(name);
 	return it != attribNameToVar.end();
 }
 

+ 34 - 34
src/Resources/ShaderProg.h

@@ -37,18 +37,18 @@ class ShaderProg: public Resource
 					SVT_UNIFORM    ///< SVT_UNIFORM
 				};
 
-			PROPERTY_R( GLint, loc, getLoc ) ///< @ref PROPERTY_R : GL location
-			PROPERTY_R( string, name, getName ) ///< @ref PROPERTY_R : The name inside the shader program
-			PROPERTY_R( GLenum, glDataType, getGlDataType ) ///< @ref PROPERTY_R : GL_FLOAT, GL_FLOAT_VEC2 etc. See http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml
-			PROPERTY_R( Type, type, getType ) ///< @ref PROPERTY_R : @ref SVT_ATTRIBUTE or @ref SVT_UNIFORM
+			PROPERTY_R(GLint, loc, getLoc) ///< @ref PROPERTY_R : GL location
+			PROPERTY_R(string, name, getName) ///< @ref PROPERTY_R : The name inside the shader program
+			PROPERTY_R(GLenum, glDataType, getGlDataType) ///< @ref PROPERTY_R : GL_FLOAT, GL_FLOAT_VEC2 etc. See http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml
+			PROPERTY_R(Type, type, getType) ///< @ref PROPERTY_R : @ref SVT_ATTRIBUTE or @ref SVT_UNIFORM
 
 			public:
-				Var( GLint loc_, const char* name_, GLenum glDataType_, Type type_, const ShaderProg* fatherSProg_ ):
+				Var(GLint loc_, const char* name_, GLenum glDataType_, Type type_, const ShaderProg* fatherSProg_):
 					loc(loc_), name(name_), glDataType(glDataType_), type(type_), fatherSProg(fatherSProg_)
 				{}
 
 				/// copy constructor
-				Var( const Var& var ):
+				Var(const Var& var):
 					loc(var.loc), name(var.name), glDataType(var.glDataType), type(var.type), fatherSProg(var.fatherSProg)
 				{}
 
@@ -62,23 +62,23 @@ class ShaderProg: public Resource
 		class UniVar: public Var
 		{
 			public:
-				UniVar( int loc_, const char* name_, GLenum glDataType_, const ShaderProg* fatherSProg_ ):
-					Var( loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_ )
+				UniVar(int loc_, const char* name_, GLenum glDataType_, const ShaderProg* fatherSProg_):
+					Var(loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_)
 				{}
 
 				/// copy constructor
-				UniVar( const UniVar& var ):
-					Var( var )
+				UniVar(const UniVar& var):
+					Var(var)
 				{}
 
-				void setFloat( float f ) const;
-				void setFloatVec( float f[], uint size = 1 ) const;
-				void setVec2( const Vec2 v2[], uint size = 1 ) const;
-				void setVec3( const Vec3 v3[], uint size = 1 ) const;
-				void setVec4( const Vec4 v4[], uint size = 1 ) const;
-				void setMat3( const Mat3 m3[], uint size = 1 ) const;
-				void setMat4( const Mat4 m4[], uint size = 1 ) const;
-				void setTexture( const Texture& tex, uint texUnit ) const;
+				void setFloat(float f) const;
+				void setFloatVec(float f[], uint size = 1) const;
+				void setVec2(const Vec2 v2[], uint size = 1) const;
+				void setVec3(const Vec3 v3[], uint size = 1) const;
+				void setVec4(const Vec4 v4[], uint size = 1) const;
+				void setMat3(const Mat3 m3[], uint size = 1) const;
+				void setMat4(const Mat4 m4[], uint size = 1) const;
+				void setTexture(const Texture& tex, uint texUnit) const;
 		};
 
 		/**
@@ -87,13 +87,13 @@ class ShaderProg: public Resource
 		class AttribVar: public Var
 		{
 			public:
-				AttribVar( int loc_, const char* name_, GLenum glDataType_, const ShaderProg* fatherSProg_ ):
-					Var( loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_ )
+				AttribVar(int loc_, const char* name_, GLenum glDataType_, const ShaderProg* fatherSProg_):
+					Var(loc_, name_, glDataType_, SVT_UNIFORM, fatherSProg_)
 				{}
 
 				/// copy constructor
-				AttribVar( const UniVar& var ):
-					Var( var )
+				AttribVar(const UniVar& var):
+					Var(var)
 				{}
 		};
 		
@@ -101,18 +101,18 @@ class ShaderProg: public Resource
 	// Public                                                                                                            =
 	//====================================================================================================================
 	public:
-		ShaderProg(): glId( numeric_limits<uint>::max() ) {}
+		ShaderProg(): glId(numeric_limits<uint>::max()) {}
 		virtual ~ShaderProg() {}
 
 		/**
 		 * Accessor to glId
 		 */
-		GLuint getGlId() const { DEBUG_ERR( glId==numeric_limits<uint>::max() ); return glId; }
+		GLuint getGlId() const { DEBUG_ERR(glId==numeric_limits<uint>::max()); return glId; }
 
 		/**
 		 * Bind the shader program
 		 */
-		inline void bind() const { DEBUG_ERR( glId==numeric_limits<uint>::max() ); glUseProgram(glId); }
+		inline void bind() const { DEBUG_ERR(glId==numeric_limits<uint>::max()); glUseProgram(glId); }
 		
 		/**
 		 * Unbind all shader programs
@@ -123,12 +123,12 @@ class ShaderProg: public Resource
 		 * Query the GL driver for the current shader program GL ID
 		 * @return Shader program GL id
 		 */
-		static uint getCurrentProgramGlId() { int i; glGetIntegerv( GL_CURRENT_PROGRAM, &i ); return i; }
+		static uint getCurrentProgramGlId() { int i; glGetIntegerv(GL_CURRENT_PROGRAM, &i); return i; }
 
 		/**
 		 * Resource load
 		 */
-		bool load( const char* filename );
+		bool load(const char* filename);
 
 		/**
 		 * Used by the renderer's shader programs
@@ -136,7 +136,7 @@ class ShaderProg: public Resource
 		 * @param extraSource Extra source code on top of the file's source
 		 * @return True on success
 		 */
-		bool customLoad( const char* filename, const char* extraSource = "" );
+		bool customLoad(const char* filename, const char* extraSource = "");
 
 		/**
 		 * Free GL program
@@ -157,15 +157,15 @@ class ShaderProg: public Resource
 		 * @param varName The name of the var
 		 * @return It returns a uniform variable and on failure it throws an error and returns NULL
 		 */
-		const UniVar* findUniVar( const char* varName ) const;
+		const UniVar* findUniVar(const char* varName) const;
 
 		/**
 		 * @see findUniVar
 		 */
-		const AttribVar* findAttribVar( const char* varName ) const;
+		const AttribVar* findAttribVar(const char* varName) const;
 
-		bool uniVarExists( const char* varName ) const;
-		bool attribVarExists( const char* varName ) const;
+		bool uniVarExists(const char* varName) const;
+		bool attribVarExists(const char* varName) const;
 
 	//====================================================================================================================
 	// Private                                                                                                           =
@@ -182,8 +182,8 @@ class ShaderProg: public Resource
 		typedef map<string,AttribVar*>::const_iterator NameToAttribVarIterator; ///< Attribute variable name to variable iterator
 
 		void getUniAndAttribVars(); ///< After the linking of the shader prog is done gather all the vars in custom containers
-		bool bindCustomAttribLocs( const class ShaderPrePreprocessor& pars ) const; ///< Uses glBindAttribLocation for every parser attrib location
-		uint createAndCompileShader( const char* sourceCode, const char* preproc, int type ) const; ///< @return Returns zero on failure
+		bool bindCustomAttribLocs(const class ShaderPrePreprocessor& pars) const; ///< Uses glBindAttribLocation for every parser attrib location
+		uint createAndCompileShader(const char* sourceCode, const char* preproc, int type) const; ///< @return Returns zero on failure
 		bool link(); ///< Link the shader prog
 }; 
 

+ 19 - 19
src/Resources/SkelAnim.cpp

@@ -6,65 +6,65 @@
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool SkelAnim::load( const char* filename )
+bool SkelAnim::load(const char* filename)
 {
 	Scanner scanner;
-	if( !scanner.loadFile( filename ) ) return false;
+	if(!scanner.loadFile(filename)) return false;
 
 	const Scanner::Token* token;
 
 
 	// keyframes
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT  )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	keyframes.resize( token->getValue().getInt() );
+	keyframes.resize(token->getValue().getInt());
 
-	if( !Parser::parseArrOfNumbers( scanner, false, false, keyframes.size(), &keyframes[0] ) ) return false;
+	if(!Parser::parseArrOfNumbers(scanner, false, false, keyframes.size(), &keyframes[0])) return false;
 
 	// bones num
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT  )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	bones.resize( token->getValue().getInt() );
+	bones.resize(token->getValue().getInt());
 
 	// poses
-	for( uint i=0; i<bones.size(); i++ )
+	for(uint i=0; i<bones.size(); i++)
 	{
 		// has anim?
 		token = &scanner.getNextToken();
-		if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT  )
+		if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 		{
-			PARSE_ERR_EXPECTED( "integer" );
+			PARSE_ERR_EXPECTED("integer");
 			return false;
 		}
 
 		// it has
-		if( token->getValue().getInt() == 1 )
+		if(token->getValue().getInt() == 1)
 		{
-			bones[i].keyframes.resize( keyframes.size() );
+			bones[i].keyframes.resize(keyframes.size());
 
-			for( uint j=0; j<keyframes.size(); ++j )
+			for(uint j=0; j<keyframes.size(); ++j)
 			{
 				// parse the quat
 				float tmp[4];
-				if( !Parser::parseArrOfNumbers( scanner, false, true, 4, &tmp[0] ) ) return false;
-				bones[i].keyframes[j].rotation = Quat( tmp[1], tmp[2], tmp[3], tmp[0] );
+				if(!Parser::parseArrOfNumbers(scanner, false, true, 4, &tmp[0])) return false;
+				bones[i].keyframes[j].rotation = Quat(tmp[1], tmp[2], tmp[3], tmp[0]);
 
 				// parse the vec3
-				if( !Parser::parseArrOfNumbers( scanner, false, true, 3, &bones[i].keyframes[j].translation[0] ) ) return false;
+				if(!Parser::parseArrOfNumbers(scanner, false, true, 3, &bones[i].keyframes[j].translation[0])) return false;
 			}
 		}
 	} // end for all bones
 
 
-	framesNum = keyframes[ keyframes.size()-1 ] + 1;
+	framesNum = keyframes[keyframes.size()-1] + 1;
 
 	return true;
 }

+ 1 - 1
src/Resources/SkelAnim.h

@@ -36,7 +36,7 @@ class SkelAnim: public Resource
 
 		SkelAnim() {}
 		~SkelAnim() {}
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload() { keyframes.clear(); bones.clear(); framesNum=0; }
 };
 

+ 25 - 25
src/Resources/Skeleton.cpp

@@ -6,90 +6,90 @@
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool Skeleton::load( const char* filename )
+bool Skeleton::load(const char* filename)
 {
 	Scanner scanner;
-	if( !scanner.loadFile( filename ) ) return false;
+	if(!scanner.loadFile(filename)) return false;
 
 	const Scanner::Token* token;
 
 
 	//** BONES NUM **
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return false;
 	}
-	bones.resize( token->getValue().getInt(), Bone() );
+	bones.resize(token->getValue().getInt(), Bone());
 
-	for( uint i=0; i<bones.size(); i++ )
+	for(uint i=0; i<bones.size(); i++)
 	{
 		Bone& bone = bones[i];
 		bone.id = i;
 
 		// NAME
 		token = &scanner.getNextToken();
-		if( token->getCode() != Scanner::TC_STRING )
+		if(token->getCode() != Scanner::TC_STRING)
 		{
-			PARSE_ERR_EXPECTED( "string" );
+			PARSE_ERR_EXPECTED("string");
 			return false;
 		}
 		bone.name = token->getValue().getString();
 
 		// head
-		if( !Parser::parseArrOfNumbers<float>( scanner, false, true, 3, &bone.head[0] ) ) return false;
+		if(!Parser::parseArrOfNumbers<float>(scanner, false, true, 3, &bone.head[0])) return false;
 
 		// tail
-		if( !Parser::parseArrOfNumbers<float>( scanner, false, true, 3, &bone.tail[0] ) ) return false;
+		if(!Parser::parseArrOfNumbers<float>(scanner, false, true, 3, &bone.tail[0])) return false;
 
 		// matrix
 		Mat4 m4;
-		if( !Parser::parseArrOfNumbers<float>( scanner, false, true, 16, &m4[0] ) ) return false;
+		if(!Parser::parseArrOfNumbers<float>(scanner, false, true, 16, &m4[0])) return false;
 
 		// matrix for real
 		bone.rotSkelSpace = m4.getRotationPart();
 		bone.tslSkelSpace = m4.getTranslationPart();
-		Mat4 MAi( m4.getInverse() );
+		Mat4 MAi(m4.getInverse());
 		bone.rotSkelSpaceInv = MAi.getRotationPart();
 		bone.tslSkelSpaceInv = MAi.getTranslationPart();
 
 		// parent
 		token = &scanner.getNextToken();
-		if( (token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT) &&
-		    (token->getCode() != Scanner::TC_IDENTIFIER || strcmp( token->getValue().getString(), "NULL" )!=0) )
+		if((token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT) &&
+		    (token->getCode() != Scanner::TC_IDENTIFIER || strcmp(token->getValue().getString(), "NULL")!=0))
 		{
-			PARSE_ERR_EXPECTED( "integer or NULL" );
+			PARSE_ERR_EXPECTED("integer or NULL");
 			return false;
 		}
 
-		if( token->getCode() == Scanner::TC_IDENTIFIER )
+		if(token->getCode() == Scanner::TC_IDENTIFIER)
 			bone.parent = NULL;
 		else
-			bone.parent = &bones[ token->getValue().getInt() ];
+			bone.parent = &bones[token->getValue().getInt()];
 
 		// childs
 		token = &scanner.getNextToken();
-		if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+		if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 		{
-			PARSE_ERR_EXPECTED( "integer" );
+			PARSE_ERR_EXPECTED("integer");
 			return false;
 		}
-		if( token->getValue().getInt() > Bone::MAX_CHILDS_PER_BONE )
+		if(token->getValue().getInt() > Bone::MAX_CHILDS_PER_BONE)
 		{
-			ERROR( "Childs for bone \"" << bone.getName() << "\" exceed the max" );
+			ERROR("Childs for bone \"" << bone.getName() << "\" exceed the max");
 			return false;
 		}
 		bone.childsNum = token->getValue().getInt();
-		for( int j=0; j<bone.childsNum; j++ )
+		for(int j=0; j<bone.childsNum; j++)
 		{
 			token = &scanner.getNextToken();
-			if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+			if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 			{
-				PARSE_ERR_EXPECTED( "integer" );
+				PARSE_ERR_EXPECTED("integer");
 				return false;
 			}
-			bone.childs[j] = &bones[ token->getValue().getInt() ];
+			bone.childs[j] = &bones[token->getValue().getInt()];
 		}
 	} // for all bones
 

+ 4 - 4
src/Resources/Skeleton.h

@@ -16,13 +16,13 @@ class Skeleton: public Resource
 		 * Skeleton bone
 		 *
 		 * @note The rotation and translation that transform the bone from bone space to armature space. Meaning that if
-		 * MA = TRS(rotSkelSpace, tslSkelSpace) then head = MA * Vec3(0.0, length, 0.0) and tail = MA * Vec3( 0.0, 0.0, 0.0 )
+		 * MA = TRS(rotSkelSpace, tslSkelSpace) then head = MA * Vec3(0.0, length, 0.0) and tail = MA * Vec3(0.0, 0.0, 0.0)
 		 * We also keep the inverted ones for fast calculations. rotSkelSpaceInv = MA.Inverted().getRotationPart() and NOT
 		 * rotSkelSpaceInv = rotSkelSpace.getInverted()
 		 */
 		class Bone
 		{
-			PROPERTY_R( string, name, getName ) ///< @ref PROPERTY_R : The name of the bone
+			PROPERTY_R(string, name, getName) ///< @ref PROPERTY_R : The name of the bone
 
 			friend class Skeleton;
 
@@ -30,7 +30,7 @@ class Skeleton: public Resource
 				static const uint MAX_CHILDS_PER_BONE = 4; ///< Please dont change this
 				ushort id; ///< Pos inside the @ref Skeleton::bones vector
 				Bone*  parent;
-				Bone*  childs[ MAX_CHILDS_PER_BONE ];
+				Bone*  childs[MAX_CHILDS_PER_BONE];
 				ushort childsNum;
 				Vec3   head;
 				Vec3   tail;
@@ -49,7 +49,7 @@ class Skeleton: public Resource
 
 		 Skeleton() {}
 		~Skeleton() {}
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload() { bones.clear(); }
 };
 

+ 48 - 48
src/Resources/Texture.cpp

@@ -17,8 +17,8 @@ int Texture::anisotropyLevel = 8;
 // Constructor                                                                                                         =
 //======================================================================================================================
 Texture::Texture():
-	glId( numeric_limits<uint>::max() ),
-	target( GL_TEXTURE_2D )
+	glId(numeric_limits<uint>::max()),
+	target(GL_TEXTURE_2D)
 {
 }
 
@@ -26,42 +26,42 @@ Texture::Texture():
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
-bool Texture::load( const char* filename )
+bool Texture::load(const char* filename)
 {
 	target = GL_TEXTURE_2D;
-	if( glId != numeric_limits<uint>::max() )
+	if(glId != numeric_limits<uint>::max())
 	{
-		ERROR( "Texture already loaded" );
+		ERROR("Texture already loaded");
 		return false;
 	}
 
 	Image img;
-	if( !img.load( filename ) ) return false;
+	if(!img.load(filename)) return false;
 
 
 	// bind the texture
-	glGenTextures( 1, &glId );
+	glGenTextures(1, &glId);
 	bind(0);
-	if( mipmappingEnabled )
+	if(mipmappingEnabled)
 	{
-		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+		setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
 	}
 	else
 	{
-		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+		setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 	}
 
-	setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+	setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
-	texParameter( GL_TEXTURE_MAX_ANISOTROPY_EXT, float(anisotropyLevel) );
+	texParameter(GL_TEXTURE_MAX_ANISOTROPY_EXT, float(anisotropyLevel));
 
 	// leave to GL_REPEAT. There is not real performance impact
-	setRepeat( true );
+	setRepeat(true);
 
 	int format = (img.bpp==32) ? GL_RGBA : GL_RGB;
 
 	int intFormat; // the internal format of the image
-	if( compressionEnabled )
+	if(compressionEnabled)
 	{
 		//int_format = (img.bpp==32) ? GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
 		intFormat = (img.bpp==32) ? GL_COMPRESSED_RGBA : GL_COMPRESSED_RGB;
@@ -71,8 +71,8 @@ bool Texture::load( const char* filename )
 		intFormat = (img.bpp==32) ? GL_RGBA : GL_RGB;
 	}
 
-	glTexImage2D( target, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data );
-	if( mipmappingEnabled )
+	glTexImage2D(target, 0, intFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data);
+	if(mipmappingEnabled)
 	{
 		glGenerateMipmap(target);
 	}
@@ -85,38 +85,38 @@ bool Texture::load( const char* filename )
 //======================================================================================================================
 // createEmpty2D                                                                                                       =
 //======================================================================================================================
-bool Texture::createEmpty2D( float width_, float height_, int internalFormat, int format_, GLenum type_,
-                             bool mimapping )
+bool Texture::createEmpty2D(float width_, float height_, int internalFormat, int format_, GLenum type_,
+                             bool mimapping)
 {
-	DEBUG_ERR( glGetError() != GL_NO_ERROR ); // dont enter the func with prev error
+	DEBUG_ERR(glGetError() != GL_NO_ERROR); // dont enter the func with prev error
 
 	target = GL_TEXTURE_2D;
-	DEBUG_ERR( internalFormat>0 && internalFormat<=4 ); // deprecated internal format
-	DEBUG_ERR( glId != numeric_limits<uint>::max() ); // Texture already loaded
+	DEBUG_ERR(internalFormat>0 && internalFormat<=4); // deprecated internal format
+	DEBUG_ERR(glId != numeric_limits<uint>::max()); // Texture already loaded
 
 	// GL stuff
-	glGenTextures( 1, &glId );
+	glGenTextures(1, &glId);
 	bind();
 
-	if( mimapping )
-		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
+	if(mimapping)
+		setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
 	else
-		setTexParameter( GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+		setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 
-	setTexParameter( GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-	setRepeat( true );
+	setTexParameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	setRepeat(true);
 
 
 	// allocate to vram
-	glTexImage2D( target, 0, internalFormat, width_, height_, 0, format_, type_, NULL );
+	glTexImage2D(target, 0, internalFormat, width_, height_, 0, format_, type_, NULL);
 
-	if( mimapping )
-		glGenerateMipmap( target );
+	if(mimapping)
+		glGenerateMipmap(target);
 
 	GLenum errid = glGetError();
-	if( errid != GL_NO_ERROR )
+	if(errid != GL_NO_ERROR)
 	{
-		ERROR( "OpenGL Error: " << gluErrorString( errid ) );
+		ERROR("OpenGL Error: " << gluErrorString(errid));
 		return false;
 	}
 	return true;
@@ -126,17 +126,17 @@ bool Texture::createEmpty2D( float width_, float height_, int internalFormat, in
 //======================================================================================================================
 // createEmpty2DMSAA                                                                                                   =
 //======================================================================================================================
-bool Texture::createEmpty2DMSAA( float width, float height, int samples_num, int internal_format )
+bool Texture::createEmpty2DMSAA(float width, float height, int samples_num, int internal_format)
 {
 	/*type = GL_TEXTURE_2D_MULTISAMPLE;
-	DEBUG_ERR( internal_format>0 && internal_format<=4 ); // deprecated internal format
-	DEBUG_ERR( glId != numeric_limits<uint>::max() ) // Texture already loaded
+	DEBUG_ERR(internal_format>0 && internal_format<=4); // deprecated internal format
+	DEBUG_ERR(glId != numeric_limits<uint>::max()) // Texture already loaded
 
-	glGenTextures( 1, &glId );
+	glGenTextures(1, &glId);
 	bind();
 	
 	// allocate
-	glTexImage2DMultisample( type, samples_num, internal_format, width, height, false );*/
+	glTexImage2DMultisample(type, samples_num, internal_format, width, height, false);*/
 	return true;
 }
 
@@ -146,20 +146,20 @@ bool Texture::createEmpty2DMSAA( float width, float height, int samples_num, int
 //======================================================================================================================
 void Texture::unload()
 {
-	glDeleteTextures( 1, &glId );
+	glDeleteTextures(1, &glId);
 }
 
 
 //======================================================================================================================
 // bind                                                                                                                =
 //======================================================================================================================
-void Texture::bind( uint unit ) const
+void Texture::bind(uint unit) const
 {
-	if( unit >= static_cast<uint>(textureUnitsNum) )
+	if(unit >= static_cast<uint>(textureUnitsNum))
 		WARNING("Max tex units passed");
 
-	glActiveTexture( GL_TEXTURE0+unit );
-	glBindTexture( target, glId );
+	glActiveTexture(GL_TEXTURE0+unit);
+	glBindTexture(target, glId);
 }
 
 
@@ -170,7 +170,7 @@ int Texture::getWidth() const
 {
 	bind();
 	int i;
-	glGetTexLevelParameteriv( target, 0, GL_TEXTURE_WIDTH, &i );
+	glGetTexLevelParameteriv(target, 0, GL_TEXTURE_WIDTH, &i);
 	return i;
 }
 
@@ -182,7 +182,7 @@ int Texture::getHeight() const
 {
 	bind();
 	int i;
-	glGetTexLevelParameteriv( target, 0, GL_TEXTURE_HEIGHT, &i );
+	glGetTexLevelParameteriv(target, 0, GL_TEXTURE_HEIGHT, &i);
 	return i;
 }
 
@@ -190,19 +190,19 @@ int Texture::getHeight() const
 //======================================================================================================================
 // setTexParameter [int]                                                                                                  =
 //======================================================================================================================
-void Texture::setTexParameter( GLenum paramName, GLint value ) const
+void Texture::setTexParameter(GLenum paramName, GLint value) const
 {
 	bind();
-	glTexParameteri( target, paramName, value );
+	glTexParameteri(target, paramName, value);
 }
 
 
 //======================================================================================================================
 // setTexParameter [float]                                                                                                =
 //======================================================================================================================
-void Texture::texParameter( GLenum paramName, GLfloat value ) const
+void Texture::texParameter(GLenum paramName, GLfloat value) const
 {
 	bind();
-	glTexParameterf( target, paramName, value );
+	glTexParameterf(target, paramName, value);
 }
 

+ 13 - 13
src/Resources/Texture.h

@@ -26,15 +26,15 @@ class Texture: public Resource
 		int getWidth() const;
 		int getHeight() const;
 
-		bool load( const char* filename );
+		bool load(const char* filename);
 		void unload();
-		bool createEmpty2D( float width, float height, int internalFormat, int format, GLenum type_, bool mipmapping );
-		bool createEmpty2DMSAA( float width, float height, int samplesNum, int internalFormat );
+		bool createEmpty2D(float width, float height, int internalFormat, int format, GLenum type_, bool mipmapping);
+		bool createEmpty2DMSAA(float width, float height, int samplesNum, int internalFormat);
 
-		void bind( uint texUnit=0 ) const;
-		void setRepeat( bool repeat ) const;
-		void setTexParameter( GLenum paramName, GLint value ) const;
-		void texParameter( GLenum paramName, GLfloat value ) const;
+		void bind(uint texUnit=0) const;
+		void setRepeat(bool repeat) const;
+		void setTexParameter(GLenum paramName, GLint value) const;
+		void texParameter(GLenum paramName, GLfloat value) const;
 
 	protected:
 		GLuint glId; ///< Identification for OGL
@@ -52,17 +52,17 @@ inline GLuint Texture::getGlId() const
 }
 
 
-inline void Texture::setRepeat( bool repeat ) const
+inline void Texture::setRepeat(bool repeat) const
 {
-	if( repeat )
+	if(repeat)
 	{
-		setTexParameter( GL_TEXTURE_WRAP_S, GL_REPEAT );
-		setTexParameter( GL_TEXTURE_WRAP_T, GL_REPEAT );
+		setTexParameter(GL_TEXTURE_WRAP_S, GL_REPEAT);
+		setTexParameter(GL_TEXTURE_WRAP_T, GL_REPEAT);
 	}
 	else
 	{
-		setTexParameter( GL_TEXTURE_WRAP_S, GL_CLAMP );
-		setTexParameter( GL_TEXTURE_WRAP_T, GL_CLAMP );
+		setTexParameter(GL_TEXTURE_WRAP_S, GL_CLAMP);
+		setTexParameter(GL_TEXTURE_WRAP_T, GL_CLAMP);
 	}
 }
 

+ 60 - 60
src/Scene/Camera.cpp

@@ -6,7 +6,7 @@
 //======================================================================================================================
 // setAll                                                                                                              =
 //======================================================================================================================
-void Camera::setAll( float fovx_, float fovy_, float znear_, float zfar_ )
+void Camera::setAll(float fovx_, float fovy_, float znear_, float zfar_)
 {
 	fovX = fovx_;
 	fovY = fovy_;
@@ -22,11 +22,11 @@ void Camera::setAll( float fovx_, float fovy_, float znear_, float zfar_ )
 //======================================================================================================================
 void Camera::render()
 {
-	Renderer::Dbg::setColor( Vec4(1.0, 0.0, 1.0, 1.0) );
-	Renderer::Dbg::setModelMat( Mat4( getWorldTransform() ) );
+	Renderer::Dbg::setColor(Vec4(1.0, 0.0, 1.0, 1.0));
+	Renderer::Dbg::setModelMat(Mat4(getWorldTransform()));
 
 	const float camLen = 1.0;
-	float tmp0 = camLen / tan( (M::PI - fovX)*0.5 ) + 0.001;
+	float tmp0 = camLen / tan((M::PI - fovX)*0.5) + 0.001;
 	float tmp1 = camLen * tan(fovY*0.5) + 0.001;
 
 	float points [][3] = {
@@ -40,23 +40,23 @@ void Camera::render()
 	const ushort indeces [] = { 0, 1, 0, 2, 0, 3, 0, 4, 1, 2, 2, 3, 3, 4, 4, 1 };
 
 
-	glEnableVertexAttribArray( 0 );
-	glVertexAttribPointer( 0, 3, GL_FLOAT, false, 0, points );
-	glDrawElements( GL_LINES, 16, GL_UNSIGNED_SHORT, indeces );
-	glDisableVertexAttribArray( 0 );
+	glEnableVertexAttribArray(0);
+	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, points);
+	glDrawElements(GL_LINES, 16, GL_UNSIGNED_SHORT, indeces);
+	glDisableVertexAttribArray(0);
 }
 
 
 //======================================================================================================================
 // lookAtPoint                                                                                                         =
 //======================================================================================================================
-void Camera::lookAtPoint( const Vec3& point )
+void Camera::lookAtPoint(const Vec3& point)
 {
-	const Vec3& j = Vec3( 0.0, 1.0, 0.0 );
+	const Vec3& j = Vec3(0.0, 1.0, 0.0);
 	Vec3 vdir = (point - getLocalTransform().getOrigin()).getNormalized();
 	Vec3 vup = j - vdir * j.dot(vdir);
-	Vec3 vside = vdir.cross( vup );
-	getLocalTransform().getRotation().setColumns( vside, vup, -vdir );
+	Vec3 vside = vdir.cross(vup);
+	getLocalTransform().getRotation().setColumns(vside, vup, -vdir);
 }
 
 
@@ -67,22 +67,22 @@ void Camera::calcLSpaceFrustumPlanes()
 {
 	float c, s; // cos & sine
 
-	sinCos( PI+fovX/2, s, c );
+	sinCos(PI+fovX/2, s, c);
 	// right
-	lspaceFrustumPlanes[FP_RIGHT] = plane_t( Vec3(c, 0.0, s), 0.0 );
+	lspaceFrustumPlanes[FP_RIGHT] = plane_t(Vec3(c, 0.0, s), 0.0);
 	// left
-	lspaceFrustumPlanes[FP_LEFT] = plane_t( Vec3(-c, 0.0, s), 0.0 );
+	lspaceFrustumPlanes[FP_LEFT] = plane_t(Vec3(-c, 0.0, s), 0.0);
 
-	sinCos( (3*PI-fovY)*0.5, s, c );
+	sinCos((3*PI-fovY)*0.5, s, c);
 	// top
-	lspaceFrustumPlanes[FP_TOP] = plane_t( Vec3(0.0, s, c), 0.0 );
+	lspaceFrustumPlanes[FP_TOP] = plane_t(Vec3(0.0, s, c), 0.0);
 	// bottom
-	lspaceFrustumPlanes[FP_BOTTOM] = plane_t( Vec3(0.0, -s, c), 0.0 );
+	lspaceFrustumPlanes[FP_BOTTOM] = plane_t(Vec3(0.0, -s, c), 0.0);
 
 	// near
-	lspaceFrustumPlanes[FP_NEAR] = plane_t( Vec3( 0.0, 0.0, -1.0 ), zNear );
+	lspaceFrustumPlanes[FP_NEAR] = plane_t(Vec3(0.0, 0.0, -1.0), zNear);
 	// far
-	lspaceFrustumPlanes[FP_FAR] = plane_t( Vec3( 0.0, 0.0, 1.0 ), -zFar );
+	lspaceFrustumPlanes[FP_FAR] = plane_t(Vec3(0.0, 0.0, 1.0), -zFar);
 }
 
 
@@ -91,9 +91,9 @@ void Camera::calcLSpaceFrustumPlanes()
 //======================================================================================================================
 void Camera::updateWSpaceFrustumPlanes()
 {
-	for( uint i=0; i<6; i++ )
+	for(uint i=0; i<6; i++)
 	{
-		wspaceFrustumPlanes[i] = lspaceFrustumPlanes[i].Transformed( getWorldTransform().getOrigin(), getWorldTransform().getRotation(), getWorldTransform().getScale() );
+		wspaceFrustumPlanes[i] = lspaceFrustumPlanes[i].Transformed(getWorldTransform().getOrigin(), getWorldTransform().getRotation(), getWorldTransform().getScale());
 	}
 }
 
@@ -102,10 +102,10 @@ void Camera::updateWSpaceFrustumPlanes()
 // insideFrustum                                                                                                       =
 //======================================================================================================================
 /// Check if the volume is inside the frustum cliping planes
-bool Camera::insideFrustum( const bvolume_t& bvol ) const
+bool Camera::insideFrustum(const bvolume_t& bvol) const
 {
-	for( uint i=0; i<6; i++ )
-		if( bvol.PlaneTest( wspaceFrustumPlanes[i] ) < 0.0 )
+	for(uint i=0; i<6; i++)
+		if(bvol.PlaneTest(wspaceFrustumPlanes[i]) < 0.0)
 			return false;
 
 	return true;
@@ -115,39 +115,39 @@ bool Camera::insideFrustum( const bvolume_t& bvol ) const
 //======================================================================================================================
 // insideFrustum                                                                                                       =
 //======================================================================================================================
-bool Camera::insideFrustum( const Camera& cam ) const
+bool Camera::insideFrustum(const Camera& cam) const
 {
 	//** get five points. These points are the tips of the given camera **
 	Vec3 points[5];
 
 	// get 3 sample floats
-	float x = cam.getZFar() / tan( (PI-cam.getFovX())/2 );
-	float y = tan( cam.getFovY()/2 ) * cam.getZFar();
+	float x = cam.getZFar() / tan((PI-cam.getFovX())/2);
+	float y = tan(cam.getFovY()/2) * cam.getZFar();
 	float z = -cam.getZFar();
 
 	// the actual points in local space
-	points[0] = Vec3( x, y, z ); // top right
-	points[1] = Vec3( -x, y, z ); // top left
-	points[2] = Vec3( -x, -y, z ); // bottom left
-	points[3] = Vec3( x, -y, z ); // bottom right
-	points[4] = Vec3( cam.getWorldTransform().getOrigin() ); // eye (already in world space)
+	points[0] = Vec3(x, y, z); // top right
+	points[1] = Vec3(-x, y, z); // top left
+	points[2] = Vec3(-x, -y, z); // bottom left
+	points[3] = Vec3(x, -y, z); // bottom right
+	points[4] = Vec3(cam.getWorldTransform().getOrigin()); // eye (already in world space)
 
 	// transform them to the given camera's world space (exept the eye)
-	for( uint i=0; i<4; i++ )
-		points[i].transform( getWorldTransform() );
+	for(uint i=0; i<4; i++)
+		points[i].transform(getWorldTransform());
 
 
 	//** the collision code **
-	for( uint i=0; i<6; i++ ) // for the 6 planes
+	for(uint i=0; i<6; i++) // for the 6 planes
 	{
 		int failed = 0;
 
-		for( uint j=0; j<5; j++ ) // for the 5 points
+		for(uint j=0; j<5; j++) // for the 5 points
 		{
-			if( wspaceFrustumPlanes[i].Test( points[j] ) < 0.0 )
+			if(wspaceFrustumPlanes[i].Test(points[j]) < 0.0)
 				++failed;
 		}
-		if( failed == 5 ) return false; // if all points are behind the plane then the cam is not in frustum
+		if(failed == 5) return false; // if all points are behind the plane then the cam is not in frustum
 	}
 
 	return true;
@@ -159,24 +159,24 @@ bool Camera::insideFrustum( const Camera& cam ) const
 //======================================================================================================================
 void Camera::calcProjectionMatrix()
 {
-	float f = 1.0/tan( fovY*0.5f ); // f = cot(fovY/2)
-
-	projectionMat(0,0) = f*fovY/fovX; // = f/aspectRatio;
-	projectionMat(0,1) = 0.0;
-	projectionMat(0,2) = 0.0;
-	projectionMat(0,3) = 0.0;
-	projectionMat(1,0) = 0.0;
-	projectionMat(1,1) = f;
-	projectionMat(1,2) = 0.0;
-	projectionMat(1,3) = 0.0;
-	projectionMat(2,0) = 0.0;
-	projectionMat(2,1) = 0.0;
-	projectionMat(2,2) = (zFar+zNear) / (zNear-zFar);
-	projectionMat(2,3) = (2.0f*zFar*zNear) / (zNear-zFar);
-	projectionMat(3,0) = 0.0;
-	projectionMat(3,1) = 0.0;
-	projectionMat(3,2) = -1.0;
-	projectionMat(3,3) = 0.0;
+	float f = 1.0/tan(fovY*0.5f); // f = cot(fovY/2)
+
+	projectionMat(0, 0) = f*fovY/fovX; // = f/aspectRatio;
+	projectionMat(0, 1) = 0.0;
+	projectionMat(0, 2) = 0.0;
+	projectionMat(0, 3) = 0.0;
+	projectionMat(1, 0) = 0.0;
+	projectionMat(1, 1) = f;
+	projectionMat(1, 2) = 0.0;
+	projectionMat(1, 3) = 0.0;
+	projectionMat(2, 0) = 0.0;
+	projectionMat(2, 1) = 0.0;
+	projectionMat(2, 2) = (zFar+zNear) / (zNear-zFar);
+	projectionMat(2, 3) = (2.0f*zFar*zNear) / (zNear-zFar);
+	projectionMat(3, 0) = 0.0;
+	projectionMat(3, 1) = 0.0;
+	projectionMat(3, 2) = -1.0;
+	projectionMat(3, 3) = 0.0;
 
 	invProjectionMat = projectionMat.getInverse();
 }
@@ -191,13 +191,13 @@ void Camera::updateViewMatrix()
 	 * The point at which the camera looks:
 	 * Vec3 viewpoint = translationLspace + z_axis;
 	 * as we know the up vector, we can easily use gluLookAt:
-	 * gluLookAt( translationLspace.x, translationLspace.x, translationLspace.z, z_axis.x, z_axis.y, z_axis.z, y_axis.x, y_axis.y, y_axis.z );
+	 * gluLookAt(translationLspace.x, translationLspace.x, translationLspace.z, z_axis.x, z_axis.y, z_axis.z, y_axis.x, y_axis.y, y_axis.z);
 	*/
 
 	// The view matrix is: Mview = camera.world_transform.Inverted(). Bus instead of inverting we do the following:
 	Mat3 camInvertedRot = getWorldTransform().getRotation().getTransposed();
-	Vec3 camInvertedTsl = -( camInvertedRot * getWorldTransform().getOrigin() );
-	viewMat = Mat4( camInvertedTsl, camInvertedRot );
+	Vec3 camInvertedTsl = -(camInvertedRot * getWorldTransform().getOrigin());
+	viewMat = Mat4(camInvertedTsl, camInvertedRot);
 }
 
 

+ 11 - 11
src/Scene/Camera.h

@@ -52,22 +52,22 @@ class Camera: public SceneNode
 
 	public:
 		// constructors and destuctors
-		Camera( float fovx_, float fovy_, float znear_, float zfar_ ): SceneNode(NT_CAMERA), fovX(fovx_), fovY(fovy_), zNear(znear_), zFar(zfar_)
+		Camera(float fovx_, float fovy_, float znear_, float zfar_): SceneNode(NT_CAMERA), fovX(fovx_), fovY(fovy_), zNear(znear_), zFar(zfar_)
 		{
 			calcLSpaceFrustumPlanes();
 			updateWSpaceFrustumPlanes();
 			calcProjectionMatrix();
 		}
-		Camera( const Camera& c ): SceneNode(NT_CAMERA) { memcpy( this, &c, sizeof( Camera ) ); }
+		Camera(const Camera& c): SceneNode(NT_CAMERA) { memcpy(this, &c, sizeof(Camera)); }
 		Camera(): SceneNode(NT_CAMERA) {}
 		~Camera() {}
 
 		// Sets & Gets
-		void setFovX ( float fovx_ )  { fovX=fovx_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
-		void setFovY ( float fovy_ )  { fovY=fovy_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
-		void setZNear( float znear_ ) { zNear=znear_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
-		void setZFar ( float zfar_ )  { zFar=zfar_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
-		void setAll( float fovx_, float fovy_, float znear_, float zfar_ );
+		void setFovX (float fovx_)  { fovX=fovx_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
+		void setFovY (float fovy_)  { fovY=fovy_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
+		void setZNear(float znear_) { zNear=znear_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
+		void setZFar (float zfar_)  { zFar=zfar_; calcProjectionMatrix(); calcLSpaceFrustumPlanes(); }
+		void setAll(float fovx_, float fovy_, float znear_, float zfar_);
 		float getFovX () const { return fovX; }
 		float getFovY () const { return fovY; }
 		float getZNear() const { return zNear; }
@@ -77,10 +77,10 @@ class Camera: public SceneNode
 		const Mat4& getInvProjectionMatrix() const { return invProjectionMat; } ///< See the declaration of invProjectionMat for info
 
 		// misc
-		void lookAtPoint( const Vec3& point );
+		void lookAtPoint(const Vec3& point);
 		void updateWorldStuff();
 		void render();
-		void init( const char* ) {}
+		void init(const char*) {}
 		void deinit() {}
 
 		// frustum stuff
@@ -88,12 +88,12 @@ class Camera: public SceneNode
 		/**
 		 * Check if the given camera is inside the frustum clipping planes. This is used mainly to test if the projected lights are visible
 		 */
-		bool insideFrustum( const bvolume_t& vol ) const;
+		bool insideFrustum(const bvolume_t& vol) const;
 
 		/**
 		 * Check if another camera is inside our view (used for projected lights)
 		 */
-		bool insideFrustum( const Camera& cam ) const;
+		bool insideFrustum(const Camera& cam) const;
 };
 
 

+ 5 - 5
src/Scene/Controllers/Controller.cpp

@@ -2,15 +2,15 @@
 #include "Scene.h"
 #include "App.h"
 
-Controller::Controller( Type type_ ): 
+Controller::Controller(Type type_): 
 	type(type_) 
 {
-	DEBUG_ERR( app->getScene() == NULL );
-	app->getScene()->registerController( this );
+	DEBUG_ERR(app->getScene() == NULL);
+	app->getScene()->registerController(this);
 }
 
 Controller::~Controller()
 {
-	DEBUG_ERR( app->getScene() == NULL );
-	app->getScene()->unregisterController( this );
+	DEBUG_ERR(app->getScene() == NULL);
+	app->getScene()->unregisterController(this);
 }

+ 3 - 3
src/Scene/Controllers/Controller.h

@@ -18,12 +18,12 @@ class Controller
 			CT_LIGHT
 		};
 	
-	PROPERTY_R( Type, type, getType ) ///< Once the type is set nothing can change it
+	PROPERTY_R(Type, type, getType) ///< Once the type is set nothing can change it
 
 	public:
-		Controller( Type type_ );
+		Controller(Type type_);
 		virtual ~Controller();
-		virtual void update( float time ) = 0;
+		virtual void update(float time) = 0;
 };
 
 

+ 2 - 2
src/Scene/Controllers/LightPropsScriptCtrl.h

@@ -13,8 +13,8 @@ class LightPropsScriptCtrl: public Controller
 	public:
 		Light* light;
 		
-		LightPropsScriptCtrl( Light* light_ ): controller(CT_LIGHT), light(light_) {}
-		void update( float ) { /* ToDo */ }
+		LightPropsScriptCtrl(Light* light_): controller(CT_LIGHT), light(light_) {}
+		void update(float) { /* ToDo */ }
 }
 
 #endif

+ 5 - 5
src/Scene/Controllers/MeshSkelNodeCtrl.h

@@ -29,17 +29,17 @@ class MeshSkelNodeCtrl: public Controller
 		} vbos;
 
 
-		MeshSkelNodeCtrl( SkelNode* skelNode_, MeshNode* meshNode_ ):
-			Controller( CT_SKEL ),
-			skelNode( skelNode_ ),
-			meshNode( meshNode_ )
+		MeshSkelNodeCtrl(SkelNode* skelNode_, MeshNode* meshNode_):
+			Controller(CT_SKEL),
+			skelNode(skelNode_),
+			meshNode(meshNode_)
 		{}
 
 		/**
 		 * Do nothing! We use HW skinning so its not necessary to update anything in the meshNode. 
 		 * The skelNode's controllers provide us with sufficient data to do the trick.
 		 */
-		void update( float ) {}
+		void update(float) {}
 };
 
 

+ 39 - 39
src/Scene/Controllers/SkelAnimCtrl.cpp

@@ -9,50 +9,50 @@
 //======================================================================================================================
 // SkelAnimCtrl                                                                                              =
 //======================================================================================================================
-SkelAnimCtrl::SkelAnimCtrl( SkelNode* skelNode_ ):
+SkelAnimCtrl::SkelAnimCtrl(SkelNode* skelNode_):
 	Controller(CT_SKEL_ANIM),
-	skelNode( skelNode_ )
+	skelNode(skelNode_)
 {
-	heads.resize( skelNode->skeleton->bones.size() );
-	tails.resize( skelNode->skeleton->bones.size() );
-	boneRotations.resize( skelNode->skeleton->bones.size() );
-	boneTranslations.resize( skelNode->skeleton->bones.size() );
+	heads.resize(skelNode->skeleton->bones.size());
+	tails.resize(skelNode->skeleton->bones.size());
+	boneRotations.resize(skelNode->skeleton->bones.size());
+	boneTranslations.resize(skelNode->skeleton->bones.size());
 }
 
 
 //======================================================================================================================
 // interpolate                                                                                                         =
 //======================================================================================================================
-void SkelAnimCtrl::interpolate( SkelAnim* animation, float frame )
+void SkelAnimCtrl::interpolate(SkelAnim* animation, float frame)
 {
-	DEBUG_ERR( frame >= animation->framesNum );
+	DEBUG_ERR(frame >= animation->framesNum);
 
 	// calculate the t (used in slerp and lerp) using the keyframs and the frame and
 	// calc the lPose and rPose witch indicate the pose ids in witch the frame lies between
 	const Vec<uint>& keyframes = animation->keyframes;
 	float t = 0.0;
 	uint lPose = 0, rPose = 0;
-	for( uint j=0; j<keyframes.size(); j++ )
+	for(uint j=0; j<keyframes.size(); j++)
 	{
-		if( (float)keyframes[j] == frame )
+		if((float)keyframes[j] == frame)
 		{
 			lPose = rPose = j;
 			t = 0.0;
 			break;
 		}
-		else if( (float)keyframes[j] > frame )
+		else if((float)keyframes[j] > frame)
 		{
 			lPose = j-1;
 			rPose = j;
-			t = ( frame - (float)keyframes[lPose] ) / float( keyframes[rPose] - keyframes[lPose] );
+			t = (frame - (float)keyframes[lPose]) / float(keyframes[rPose] - keyframes[lPose]);
 			break;
 		}
 	}
 
 
 	// now for all bones update bone's poses
-	DEBUG_ERR( boneRotations.size()<1 );
-	for( uint i=0; i<boneRotations.size(); i++ )
+	DEBUG_ERR(boneRotations.size()<1);
+	for(uint i=0; i<boneRotations.size(); i++)
 	{
 		const SkelAnim::BoneAnim& banim = animation->bones[i];
 
@@ -60,7 +60,7 @@ void SkelAnimCtrl::interpolate( SkelAnim* animation, float frame )
 		Vec3& localTransl = boneTranslations[i];
 
 		// if the bone has animations then slerp and lerp to find the rotation and translation
-		if( banim.keyframes.size() != 0 )
+		if(banim.keyframes.size() != 0)
 		{
 			const SkelAnim::BonePose& lBpose = banim.keyframes[lPose];
 			const SkelAnim::BonePose& rBpose = banim.keyframes[rPose];
@@ -68,18 +68,18 @@ void SkelAnimCtrl::interpolate( SkelAnim* animation, float frame )
 			// rotation
 			const Quat& q0 = lBpose.rotation;
 			const Quat& q1 = rBpose.rotation;
-			localRot = Mat3( q0.slerp(q1, t) );
+			localRot = Mat3(q0.slerp(q1, t));
 
 			// translation
 			const Vec3& v0 = lBpose.translation;
 			const Vec3& v1 = rBpose.translation;
-			localTransl = v0.lerp( v1, t );
+			localTransl = v0.lerp(v1, t);
 		}
 		// else put the idents
 		else
 		{
 			localRot = Mat3::getIdentity();
-			localTransl = Vec3( 0.0, 0.0, 0.0 );
+			localTransl = Vec3(0.0, 0.0, 0.0);
 		}
 	}
 }
@@ -90,41 +90,41 @@ void SkelAnimCtrl::interpolate( SkelAnim* animation, float frame )
 //======================================================================================================================
 void SkelAnimCtrl::updateBoneTransforms()
 {
-	uint queue[ 128 ];
+	uint queue[128];
 	uint head = 0, tail = 0;
 
 	// put the roots
-	for( uint i=0; i<skelNode->skeleton->bones.size(); i++ )
-		if( skelNode->skeleton->bones[i].parent == NULL )
+	for(uint i=0; i<skelNode->skeleton->bones.size(); i++)
+		if(skelNode->skeleton->bones[i].parent == NULL)
 			queue[tail++] = i; // queue push
 
 	// loop
-	while( head != tail ) // while queue not empty
+	while(head != tail) // while queue not empty
 	{
 		uint boneId = queue[head++]; // queue pop
 		const Skeleton::Bone& boned = skelNode->skeleton->bones[boneId];
 
 		// bone.final_transform = MA * ANIM * MAi
 		// where MA is bone matrix at armature space and ANIM the interpolated transformation.
-		combineTransformations( boneTranslations[boneId], boneRotations[boneId],
+		combineTransformations(boneTranslations[boneId], boneRotations[boneId],
 		                        boned.tslSkelSpaceInv, boned.rotSkelSpaceInv,
-		                        boneTranslations[boneId], boneRotations[boneId] );
+		                        boneTranslations[boneId], boneRotations[boneId]);
 
-		combineTransformations( boned.tslSkelSpace, boned.rotSkelSpace,
+		combineTransformations(boned.tslSkelSpace, boned.rotSkelSpace,
 		                        boneTranslations[boneId], boneRotations[boneId],
-		                        boneTranslations[boneId], boneRotations[boneId] );
+		                        boneTranslations[boneId], boneRotations[boneId]);
 
 		// and finaly add the parent's transform
-		if( boned.parent )
+		if(boned.parent)
 		{
 			// bone.final_final_transform = parent.transf * bone.final_transform
-			combineTransformations( boneTranslations[boned.parent->id], boneRotations[boned.parent->id],
+			combineTransformations(boneTranslations[boned.parent->id], boneRotations[boned.parent->id],
 		                          boneTranslations[boneId], boneRotations[boneId],
-		                          boneTranslations[boneId], boneRotations[boneId] );
+		                          boneTranslations[boneId], boneRotations[boneId]);
 		}
 
 		// now add the bone's childes
-		for( uint i=0; i<boned.childsNum; i++ )
+		for(uint i=0; i<boned.childsNum; i++)
 			queue[tail++] = boned.childs[i]->id;
 	}
 }
@@ -137,13 +137,13 @@ void SkelAnimCtrl::deform()
 {
 	Skeleton* skeleton = skelNode->skeleton;
 
-	for( uint i=0; i<skeleton->bones.size(); i++ )
+	for(uint i=0; i<skeleton->bones.size(); i++)
 	{
-		const Mat3& rot = boneRotations[ i ];
-		const Vec3& transl = boneTranslations[ i ];
+		const Mat3& rot = boneRotations[i];
+		const Vec3& transl = boneTranslations[i];
 
-		heads[i] = skeleton->bones[i].head.getTransformed( transl, rot );
-		tails[i] = skeleton->bones[i].tail.getTransformed( transl, rot );
+		heads[i] = skeleton->bones[i].head.getTransformed(transl, rot);
+		tails[i] = skeleton->bones[i].tail.getTransformed(transl, rot);
 	}
 }
 
@@ -151,17 +151,17 @@ void SkelAnimCtrl::deform()
 //======================================================================================================================
 // update                                                                                                              =
 //======================================================================================================================
-void SkelAnimCtrl::update( float )
+void SkelAnimCtrl::update(float)
 {
 	frame += step;
-	if( frame > skelAnim->framesNum ) // if the crnt is finished then play the next or loop the crnt
+	if(frame > skelAnim->framesNum) // if the crnt is finished then play the next or loop the crnt
 	{
 		frame = 0.0;
 	}
 
-	interpolate( skelAnim, frame );
+	interpolate(skelAnim, frame);
 	updateBoneTransforms();
-	if( app->getMainRenderer()->dbg.isShowSkeletonsEnabled() )
+	if(app->getMainRenderer()->dbg.isShowSkeletonsEnabled())
 	{
 		deform();
 	}

+ 3 - 3
src/Scene/Controllers/SkelAnimCtrl.h

@@ -15,7 +15,7 @@ class SkelAnimCtrl: public Controller
 {
 	private:
 		// The 3 steps of skeletal animation
-		void interpolate( SkelAnim* animation, float frame );
+		void interpolate(SkelAnim* animation, float frame);
 		void updateBoneTransforms();
 		void deform();  ///< Now with HW skinning it deforms only the debug skeleton
 
@@ -29,8 +29,8 @@ class SkelAnimCtrl: public Controller
 		float step;
 		float frame;
 
-		SkelAnimCtrl( SkelNode* skelNode_ );
-		void update( float time );
+		SkelAnimCtrl(SkelNode* skelNode_);
+		void update(float time);
 };
 
 

+ 2 - 2
src/Scene/Controllers/TrfScriptCtrl.h

@@ -11,8 +11,8 @@ class TrfScriptCtrl: public Controller
 	public:
 		SceneNode* node;
 	
-		TrfScriptCtrl( SceneNode* node_ ): Controller( CT_TRF ), node(node_) {}
-		void Update( float ) { /* ToDo */ }
+		TrfScriptCtrl(SceneNode* node_): Controller(CT_TRF), node(node_) {}
+		void Update(float) { /* ToDo */ }
 };
 
 #endif

+ 1 - 1
src/Scene/GhostNode.h

@@ -11,7 +11,7 @@ class GhostNode: public SceneNode
 {
 	public:
 		GhostNode(): SceneNode(NT_GHOST) { }
-		void init( const char* ) {}
+		void init(const char*) {}
 		void render() {}
 		void deinit() {}
 };

+ 11 - 11
src/Scene/Light.cpp

@@ -8,9 +8,9 @@
 //======================================================================================================================
 // init [PointLight]                                                                                                  =
 //======================================================================================================================
-void PointLight::init( const char* filename )
+void PointLight::init(const char* filename)
 {
-	lightProps = Rsrc::lightProps.load( filename );
+	lightProps = Rsrc::lightProps.load(filename);
 	radius = lightProps->getRadius();
 }
 
@@ -18,14 +18,14 @@ void PointLight::init( const char* filename )
 //======================================================================================================================
 // init [SpotLight]                                                                                                    =
 //======================================================================================================================
-void SpotLight::init( const char* filename )
+void SpotLight::init(const char* filename)
 {
-	lightProps = Rsrc::lightProps.load( filename );
-	camera.setAll( lightProps->getFovX(), lightProps->getFovY(), 0.2, lightProps->getDistance() );
+	lightProps = Rsrc::lightProps.load(filename);
+	camera.setAll(lightProps->getFovX(), lightProps->getFovY(), 0.2, lightProps->getDistance());
 	castsShadow = lightProps->castsShadow();
-	if( lightProps->getTexture() == NULL )
+	if(lightProps->getTexture() == NULL)
 	{
-		ERROR( "Light properties \"" << lightProps->getRsrcName() << "\" do not have a texture" );
+		ERROR("Light properties \"" << lightProps->getRsrcName() << "\" do not have a texture");
 		return;
 	}
 }
@@ -36,7 +36,7 @@ void SpotLight::init( const char* filename )
 //======================================================================================================================
 void Light::deinit()
 {
-	Rsrc::lightProps.unload( lightProps );
+	Rsrc::lightProps.unload(lightProps);
 }
 
 
@@ -45,8 +45,8 @@ void Light::deinit()
 //======================================================================================================================
 void Light::render()
 {
-	Renderer::Dbg::setColor( Vec4( lightProps->getDiffuseColor(), 1.0 ) );
-	Renderer::Dbg::setModelMat( Mat4( getWorldTransform() ) );
-	Renderer::Dbg::renderSphere( 8, 0.1 );
+	Renderer::Dbg::setColor(Vec4(lightProps->getDiffuseColor(), 1.0));
+	Renderer::Dbg::setModelMat(Mat4(getWorldTransform()));
+	Renderer::Dbg::renderSphere(8, 0.1);
 }
 

+ 8 - 8
src/Scene/Light.h

@@ -8,8 +8,8 @@ Ambient intensity of material:  Am
 Defuse intensity:               Id = Dl * Dm * LambertTerm
 Defuse intensity of light:      Dl
 Defuse intensity of material:   Dm
-LambertTerm:                    max( Normal dot Light, 0.0 )
-Specular intensity:             Is = Sm x Sl x pow( max(R dot E, 0.0), f )
+LambertTerm:                    max(Normal dot Light, 0.0)
+Specular intensity:             Is = Sm x Sl x pow(max(R dot E, 0.0), f)
 Specular intensity of light:    Sl
 Specular intensity of material: Sm
 */
@@ -34,8 +34,8 @@ class Light: public SceneNode
 		Type type;
 		LightProps* lightProps; ///< Later we will add a controller
 	
-		Light( Type type_ ): SceneNode(NT_LIGHT), type(type_) {}
-		//void init( const char* );
+		Light(Type type_): SceneNode(NT_LIGHT), type(type_) {}
+		//void init(const char*);
 		void deinit();
 		void render();
 };
@@ -48,7 +48,7 @@ class PointLight: public Light
 		float radius;
 
 		PointLight(): Light(LT_POINT) {}
-		void init( const char* );
+		void init(const char*);
 };
 
 
@@ -59,10 +59,10 @@ class SpotLight: public Light
 		Camera camera;
 		bool castsShadow;
 
-		SpotLight(): Light(LT_SPOT), castsShadow(false) { addChild( &camera ); }
+		SpotLight(): Light(LT_SPOT), castsShadow(false) { addChild(&camera); }
 		float getDistance() const { return camera.getZFar(); }
-		void setDistance( float d ) { camera.setZFar(d); }
-		void init( const char* );
+		void setDistance(float d) { camera.setZFar(d); }
+		void init(const char*);
 };
 
 

+ 51 - 51
src/Scene/MeshNode.cpp

@@ -13,17 +13,17 @@
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
-void MeshNode::init( const char* filename )
+void MeshNode::init(const char* filename)
 {
-	mesh = Rsrc::meshes.load( filename );
-	material = Rsrc::materials.load( mesh->materialName.c_str() );
+	mesh = Rsrc::meshes.load(filename);
+	material = Rsrc::materials.load(mesh->materialName.c_str());
 
 	// sanity checks
-	if( material->stdAttribVars[Material::SAV_TEX_COORDS]!=NULL && mesh->vbos.texCoords.getGlId()==0 )
+	if(material->stdAttribVars[Material::SAV_TEX_COORDS]!=NULL && mesh->vbos.texCoords.getGlId()==0)
 	{
-		ERROR( "The shader program (\"" << material->shaderProg->getRsrcName() <<
+		ERROR("The shader program (\"" << material->shaderProg->getRsrcName() <<
 		       "\") needs texture coord information that the mesh (\"" <<
-		       mesh->getRsrcName() << "\") doesn't have" );
+		       mesh->getRsrcName() << "\") doesn't have");
 	}
 }
 
@@ -33,95 +33,95 @@ void MeshNode::init( const char* filename )
 //======================================================================================================================
 void MeshNode::deinit()
 {
-	Rsrc::meshes.unload( mesh );
-	Rsrc::materials.unload( material );
+	Rsrc::meshes.unload(mesh);
+	Rsrc::materials.unload(material);
 }
 
 
 //======================================================================================================================
 // render                                                                                                              =
 //======================================================================================================================
-void MeshNode::render( Material* mtl ) const
+void MeshNode::render(Material* mtl) const
 {
 	GLint loc;
-	GLint locs[ 64 ];
+	GLint locs[64];
 	int locsNum = 0;
 
 	// if we have skeleton controller
-	if( meshSkelCtrl )
+	if(meshSkelCtrl)
 	{
-		DEBUG_ERR( !mtl->hasHWSkinning() ); // it has skel controller but no skinning
+		DEBUG_ERR(!mtl->hasHWSkinning()); // it has skel controller but no skinning
 
 		// first the uniforms
-		mtl->stdUniVars[ Material::SUV_SKINNING_ROTATIONS ]->setMat3( &meshSkelCtrl->skelNode->skelAnimCtrl->boneRotations[0],
-		                                                              meshSkelCtrl->skelNode->skeleton->bones.size() );
+		mtl->stdUniVars[Material::SUV_SKINNING_ROTATIONS]->setMat3(&meshSkelCtrl->skelNode->skelAnimCtrl->boneRotations[0],
+		                                                              meshSkelCtrl->skelNode->skeleton->bones.size());
 
-		mtl->stdUniVars[ Material::SUV_SKINNING_TRANSLATIONS ]->setVec3( &meshSkelCtrl->skelNode->skelAnimCtrl->boneTranslations[0],
-		                                                                 meshSkelCtrl->skelNode->skeleton->bones.size() );
+		mtl->stdUniVars[Material::SUV_SKINNING_TRANSLATIONS]->setVec3(&meshSkelCtrl->skelNode->skelAnimCtrl->boneTranslations[0],
+		                                                                 meshSkelCtrl->skelNode->skeleton->bones.size());
 
 		// then the attributes
 		mesh->vbos.vertWeights.bind();
 
-		loc = mtl->stdAttribVars[ Material::SAV_VERT_WEIGHT_BONES_NUM ]->getLoc();
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
-		glVertexAttribPointer( loc, 1, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(0) );
+		loc = mtl->stdAttribVars[Material::SAV_VERT_WEIGHT_BONES_NUM]->getLoc();
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
+		glVertexAttribPointer(loc, 1, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(0));
 
-		loc = mtl->stdAttribVars[ Material::SAV_VERT_WEIGHT_BONE_IDS ]->getLoc();
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
-		glVertexAttribPointer( loc, 4, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(4) );
+		loc = mtl->stdAttribVars[Material::SAV_VERT_WEIGHT_BONE_IDS]->getLoc();
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
+		glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(4));
 
-		loc = mtl->stdAttribVars[ Material::SAV_VERT_WEIGHT_WEIGHTS ]->getLoc();
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
-		glVertexAttribPointer( loc, 4, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(20) );
+		loc = mtl->stdAttribVars[Material::SAV_VERT_WEIGHT_WEIGHTS]->getLoc();
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
+		glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, sizeof(Mesh::VertexWeight), BUFFER_OFFSET(20));
 	}
 
-	if( mtl->stdAttribVars[ Material::SAV_POSITION ] != NULL )
+	if(mtl->stdAttribVars[Material::SAV_POSITION] != NULL)
 	{
 		mesh->vbos.vertCoords.bind();
-		loc = mtl->stdAttribVars[ Material::SAV_POSITION ]->getLoc();
-		glVertexAttribPointer( loc, 3, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
+		loc = mtl->stdAttribVars[Material::SAV_POSITION]->getLoc();
+		glVertexAttribPointer(loc, 3, GL_FLOAT, false, 0, NULL);
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
 	}
 
-	if( mtl->stdAttribVars[ Material::SAV_NORMAL ] != NULL )
+	if(mtl->stdAttribVars[Material::SAV_NORMAL] != NULL)
 	{
 		mesh->vbos.vertNormals.bind();
-		loc = mtl->stdAttribVars[ Material::SAV_NORMAL ]->getLoc();
-		glVertexAttribPointer( loc, 3, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
+		loc = mtl->stdAttribVars[Material::SAV_NORMAL]->getLoc();
+		glVertexAttribPointer(loc, 3, GL_FLOAT, false, 0, NULL);
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
 	}
 
-	if( mtl->stdAttribVars[ Material::SAV_TEX_COORDS ] != NULL )
+	if(mtl->stdAttribVars[Material::SAV_TEX_COORDS] != NULL)
 	{
 		mesh->vbos.texCoords.bind();
-		loc = mtl->stdAttribVars[ Material::SAV_TEX_COORDS ]->getLoc();
-		glVertexAttribPointer( loc, 2, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
+		loc = mtl->stdAttribVars[Material::SAV_TEX_COORDS]->getLoc();
+		glVertexAttribPointer(loc, 2, GL_FLOAT, false, 0, NULL);
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
 	}
 
-	if( mtl->stdAttribVars[ Material::SAV_TANGENT ] != NULL )
+	if(mtl->stdAttribVars[Material::SAV_TANGENT] != NULL)
 	{
 		mesh->vbos.vertTangents.bind();
-		loc = mtl->stdAttribVars[ Material::SAV_TANGENT ]->getLoc();
-		glVertexAttribPointer( loc, 4, GL_FLOAT, false, 0, NULL );
-		glEnableVertexAttribArray( loc );
-		locs[ locsNum++ ] = loc;
+		loc = mtl->stdAttribVars[Material::SAV_TANGENT]->getLoc();
+		glVertexAttribPointer(loc, 4, GL_FLOAT, false, 0, NULL);
+		glEnableVertexAttribArray(loc);
+		locs[locsNum++] = loc;
 	}
 
 	mesh->vbos.vertIndeces.bind();
 
-	glDrawElements( GL_TRIANGLES, mesh->vertIndeces.size(), GL_UNSIGNED_SHORT, 0 );
+	glDrawElements(GL_TRIANGLES, mesh->vertIndeces.size(), GL_UNSIGNED_SHORT, 0);
 
 	// disable
-	for( int i=0; i<locsNum; i++ )
+	for(int i=0; i<locsNum; i++)
 	{
-		glDisableVertexAttribArray( locs[i] );
+		glDisableVertexAttribArray(locs[i]);
 	}
 
 	Vbo::unbindAllTargets();

+ 3 - 3
src/Scene/MeshNode.h

@@ -13,7 +13,7 @@ class Mesh;
 class MeshNode: public SceneNode
 {
 	private:
-		void render( Material* mtl ) const; ///< Common code for render() and renderDepth()
+		void render(Material* mtl) const; ///< Common code for render() and renderDepth()
 
 	public:
 		// resources
@@ -25,8 +25,8 @@ class MeshNode: public SceneNode
 		// funcs
 		MeshNode(): SceneNode(NT_MESH), material(NULL), dpMaterial(NULL), meshSkelCtrl(NULL) {}
 		virtual void render() { render(material); }
-		virtual void renderDepth() { render( material->dpMtl ); }
-		void init( const char* filename );
+		virtual void renderDepth() { render(material->dpMtl); }
+		void init(const char* filename);
 		void deinit();
 };
 

+ 49 - 49
src/Scene/ParticleEmitter.cpp

@@ -10,13 +10,13 @@
 //======================================================================================================================
 void ParticleEmitter::Particle::render()
 {
-	if( lifeTillDeath < 0 ) return;
+	if(lifeTillDeath < 0) return;
 
 	glPushMatrix();
-	app->getMainRenderer()->multMatrix( getWorldTransform() );
+	app->getMainRenderer()->multMatrix(getWorldTransform());
 
-	glBegin( GL_POINTS );
-		glVertex3fv( &(Vec3(0.0))[0] );
+	glBegin(GL_POINTS);
+		glVertex3fv(&(Vec3(0.0))[0]);
 	glEnd();
 
 	glPopMatrix();
@@ -26,39 +26,39 @@ void ParticleEmitter::Particle::render()
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
-void ParticleEmitter::init( const char* filename )
+void ParticleEmitter::init(const char* filename)
 {
 	// dummy props init
 	maxParticleLife = 400;
 	minParticleLife = 100;
-	minDirection = Vec3( -0.1, 1.0, 0.0 );
-	maxDirection = Vec3( 0.1, 1.0, 0.0 );
+	minDirection = Vec3(-0.1, 1.0, 0.0);
+	maxDirection = Vec3(0.1, 1.0, 0.0);
 	minForceMagnitude = 1.0;
 	maxForceMagnitude = 2.0;
 	minParticleMass = 1.0;
 	maxParticleMass = 2.0;
-	minGravity = Vec3( 0.0, 0.0, 0.0 );
-	minGravity = Vec3( 0.0, -1.0, 0.0 );
-	minStartingPos = Vec3( -1.0, -1.0, -1.0 );
-	maxStartingPos = Vec3( 1.0, 1.0, 1.0 );
+	minGravity = Vec3(0.0, 0.0, 0.0);
+	minGravity = Vec3(0.0, -1.0, 0.0);
+	minStartingPos = Vec3(-1.0, -1.0, -1.0);
+	maxStartingPos = Vec3(1.0, 1.0, 1.0);
 	maxNumOfParticles = 5;
 	emittionPeriod = 1000;
 
 	// init the particles
-	btCollisionShape* colShape = new btSphereShape( 0.1 );
+	btCollisionShape* colShape = new btSphereShape(0.1);
 
-	particles.resize( maxNumOfParticles );
-	for( uint i=0; i<maxNumOfParticles; i++ )
+	particles.resize(maxNumOfParticles);
+	for(uint i=0; i<maxNumOfParticles; i++)
 	{
 		particles[i] = new Particle;
-		float mass = Util::randRange( minParticleMass, maxParticleMass );
-		btRigidBody* body = app->getScene()->getPhyWorld()->createNewRigidBody( mass, Transform::getIdentity(), colShape, particles[i],
-		                                                                        PhyWorld::CG_PARTICLE, PhyWorld::CG_MAP );
-		//body->forceActivationState( DISABLE_SIMULATION );
+		float mass = Util::randRange(minParticleMass, maxParticleMass);
+		btRigidBody* body = app->getScene()->getPhyWorld()->createNewRigidBody(mass, Transform::getIdentity(), colShape, particles[i],
+		                                                                        PhyWorld::CG_PARTICLE, PhyWorld::CG_MAP);
+		//body->forceActivationState(DISABLE_SIMULATION);
 	}
 
 	/*btDiscreteDynamicsWorld* btWorld = app->getScene()->getPhyWorld()->getDynamicsWorld();
-	btWorld->getBroadphase()->resetPool( btWorld->getDispatcher() );
+	btWorld->getBroadphase()->resetPool(btWorld->getDispatcher());
 	btWorld->getConstraintSolver()->reset();*/
 }
 
@@ -71,47 +71,47 @@ void ParticleEmitter::update()
 	uint crntTime = app->getTicks();
 
 	// decrease particle life and deactivate the dead particles
-	for( Vec<Particle*>::iterator it=particles.begin(); it!=particles.end(); ++it )
+	for(Vec<Particle*>::iterator it=particles.begin(); it!=particles.end(); ++it)
 	{
 		Particle* part = *it;
-		if( part->lifeTillDeath < 0 ) continue; // its already dead so dont deactivate it again
+		if(part->lifeTillDeath < 0) continue; // its already dead so dont deactivate it again
 
 		part->lifeTillDeath -= crntTime-timeOfPrevUpdate;
-		if( part->lifeTillDeath < 1 )
+		if(part->lifeTillDeath < 1)
 		{
-			part->body->setActivationState( DISABLE_SIMULATION );
+			part->body->setActivationState(DISABLE_SIMULATION);
 		}
 	}
 
 	// emit new particles
-	DEBUG_ERR( particlesPerEmittion == 0 );
-	if( (crntTime - timeOfPrevEmittion) > emittionPeriod )
+	DEBUG_ERR(particlesPerEmittion == 0);
+	if((crntTime - timeOfPrevEmittion) > emittionPeriod)
 	{
 		uint partNum = 0;
-		for( Vec<Particle*>::iterator it=particles.begin(); it!=particles.end(); ++it )
+		for(Vec<Particle*>::iterator it=particles.begin(); it!=particles.end(); ++it)
 		{
 			Particle* part = *it;
-			if( part->lifeTillDeath > 0 ) continue; // its alive so skip it
+			if(part->lifeTillDeath > 0) continue; // its alive so skip it
 
 			// reinit a dead particle
 			//
 
 			// activate it (Bullet stuff)
-			part->body->forceActivationState( ACTIVE_TAG );
+			part->body->forceActivationState(ACTIVE_TAG);
 			part->body->clearForces();
 
 			// life
-			if( minParticleLife != maxParticleLife )
-				part->lifeTillDeath = Util::randRange( minParticleLife, maxParticleLife );
+			if(minParticleLife != maxParticleLife)
+				part->lifeTillDeath = Util::randRange(minParticleLife, maxParticleLife);
 			else
 				part->lifeTillDeath = minParticleLife;
 
 			// force
 			Vec3 forceDir;
-			if( minDirection != maxDirection )
+			if(minDirection != maxDirection)
 			{
-				forceDir = Vec3( Util::randRange( minDirection.x , maxDirection.x ), Util::randRange( minDirection.y , maxDirection.y ),
-			                                    Util::randRange( minDirection.z , maxDirection.z ) );
+				forceDir = Vec3(Util::randRange(minDirection.x , maxDirection.x), Util::randRange(minDirection.y , maxDirection.y),
+			                                    Util::randRange(minDirection.z , maxDirection.z));
 			}
 			else
 			{
@@ -119,41 +119,41 @@ void ParticleEmitter::update()
 			}
 			forceDir.normalize();
 
-			if( minForceMagnitude != maxForceMagnitude )
-				part->body->applyCentralForce( toBt( forceDir * Util::randRange( minForceMagnitude, maxForceMagnitude ) ) );
+			if(minForceMagnitude != maxForceMagnitude)
+				part->body->applyCentralForce(toBt(forceDir * Util::randRange(minForceMagnitude, maxForceMagnitude)));
 			else
-				part->body->applyCentralForce( toBt( forceDir * minForceMagnitude ) );
+				part->body->applyCentralForce(toBt(forceDir * minForceMagnitude));
 
 			// gravity
 			Vec3 grav;
-			if( minGravity != maxGravity )
+			if(minGravity != maxGravity)
 			{
-				grav = Vec3( Util::randRange(minGravity.x,maxGravity.x), Util::randRange(minGravity.y,maxGravity.y),
-			               Util::randRange(minGravity.z,maxGravity.z) );
+				grav = Vec3(Util::randRange(minGravity.x,maxGravity.x), Util::randRange(minGravity.y,maxGravity.y),
+			               Util::randRange(minGravity.z,maxGravity.z));
 			}
 			else
 			{
 				grav = minGravity;
 			}
-			part->body->setGravity( toBt( grav ) );
+			part->body->setGravity(toBt(grav));
 
 			// starting pos
 			Vec3 pos;
-			if( minStartingPos != maxStartingPos )
+			if(minStartingPos != maxStartingPos)
 			{
-				pos = Vec3( Util::randRange(minStartingPos.x,maxStartingPos.x), Util::randRange(minStartingPos.y,maxStartingPos.y),
-			              Util::randRange(minStartingPos.z,maxStartingPos.z) );
+				pos = Vec3(Util::randRange(minStartingPos.x,maxStartingPos.x), Util::randRange(minStartingPos.y,maxStartingPos.y),
+			              Util::randRange(minStartingPos.z,maxStartingPos.z));
 			}
 			else
 			{
 				pos = minStartingPos;
 			}
 			pos += getWorldTransform().getOrigin();
-			part->body->setWorldTransform( toBt( Mat4( pos, Mat3::getIdentity(), 1.0 ) ) );
+			part->body->setWorldTransform(toBt(Mat4(pos, Mat3::getIdentity(), 1.0)));
 
 			// do the rest
 			++partNum;
-			if( partNum >= particlesPerEmittion ) break;
+			if(partNum >= particlesPerEmittion) break;
 		} // end for all particles
 
 		timeOfPrevEmittion = crntTime;
@@ -168,10 +168,10 @@ void ParticleEmitter::update()
 //======================================================================================================================
 void ParticleEmitter::render()
 {
-	glPolygonMode( GL_FRONT, GL_LINE );
-	Renderer::Dbg::setColor( Vec4(1.0) );
-	Renderer::Dbg::setModelMat( Mat4( getWorldTransform() ) );
+	glPolygonMode(GL_FRONT, GL_LINE);
+	Renderer::Dbg::setColor(Vec4(1.0));
+	Renderer::Dbg::setModelMat(Mat4(getWorldTransform()));
 	Renderer::Dbg::renderCube();
-	glPolygonMode( GL_FRONT, GL_FILL );
+	glPolygonMode(GL_FRONT, GL_FILL);
 
 }

+ 2 - 2
src/Scene/ParticleEmitter.h

@@ -57,10 +57,10 @@ class ParticleEmitter: public SceneNode
 		uint timeOfPrevEmittion;
 
 		// funcs
-		ParticleEmitter(): SceneNode( NT_PARTICLE_EMITTER ) {}
+		ParticleEmitter(): SceneNode(NT_PARTICLE_EMITTER) {}
 		void render();
 		void renderDepth() {}
-		void init( const char* filename );
+		void init(const char* filename);
 		void deinit() {}
 		void update();
 };

+ 31 - 31
src/Scene/Scene.cpp

@@ -13,8 +13,8 @@
 //======================================================================================================================
 Scene::Scene()
 {
-	ambientCol = Vec3( 0.1, 0.05, 0.05 )*1;
-	sunPos = Vec3( 0.0, 1.0, -1.0 ) * 50.0;
+	ambientCol = Vec3(0.1, 0.05, 0.05)*1;
+	sunPos = Vec3(0.0, 1.0, -1.0) * 50.0;
 
 	phyWorld = new PhyWorld;
 }
@@ -23,23 +23,23 @@ Scene::Scene()
 //======================================================================================================================
 // registerNode                                                                                                        =
 //======================================================================================================================
-void Scene::registerNode( SceneNode* node )
+void Scene::registerNode(SceneNode* node)
 {
-	putBackNode( nodes, node );
+	putBackNode(nodes, node);
 	
-	switch( node->type )
+	switch(node->type)
 	{
 		case SceneNode::NT_LIGHT:
-			putBackNode( lights, static_cast<Light*>(node) );
+			putBackNode(lights, static_cast<Light*>(node));
 			break;
 		case SceneNode::NT_CAMERA:
-			putBackNode( cameras, static_cast<Camera*>(node) );
+			putBackNode(cameras, static_cast<Camera*>(node));
 			break;
 		case SceneNode::NT_MESH:
-			putBackNode( meshNodes, static_cast<MeshNode*>(node) );
+			putBackNode(meshNodes, static_cast<MeshNode*>(node));
 			break;
 		case SceneNode::NT_SKELETON:
-			putBackNode( skelNodes, static_cast<SkelNode*>(node) );
+			putBackNode(skelNodes, static_cast<SkelNode*>(node));
 			break;
 		case SceneNode::NT_SKEL_MODEL:
 			// ToDo
@@ -51,23 +51,23 @@ void Scene::registerNode( SceneNode* node )
 //======================================================================================================================
 // unregisterNode                                                                                                      =
 //======================================================================================================================
-void Scene::unregisterNode( SceneNode* node )
+void Scene::unregisterNode(SceneNode* node)
 {
-	eraseNode( nodes, node );
+	eraseNode(nodes, node);
 	
-	switch( node->type )
+	switch(node->type)
 	{
 		case SceneNode::NT_LIGHT:
-			eraseNode( lights, static_cast<Light*>(node) );
+			eraseNode(lights, static_cast<Light*>(node));
 			break;
 		case SceneNode::NT_CAMERA:
-			eraseNode( cameras, static_cast<Camera*>(node) );
+			eraseNode(cameras, static_cast<Camera*>(node));
 			break;
 		case SceneNode::NT_MESH:
-			eraseNode( meshNodes, static_cast<MeshNode*>(node) );
+			eraseNode(meshNodes, static_cast<MeshNode*>(node));
 			break;
 		case SceneNode::NT_SKELETON:
-			eraseNode( skelNodes, static_cast<SkelNode*>(node) );
+			eraseNode(skelNodes, static_cast<SkelNode*>(node));
 			break;
 		case SceneNode::NT_SKEL_MODEL:
 			// ToDo
@@ -79,17 +79,17 @@ void Scene::unregisterNode( SceneNode* node )
 //======================================================================================================================
 // Register and Unregister controllers                                                                                 =
 //======================================================================================================================
-void Scene::registerController( Controller* controller )
+void Scene::registerController(Controller* controller)
 {
-	DEBUG_ERR( std::find( controllers.begin(), controllers.end(), controller ) != controllers.end() );
-	controllers.push_back( controller );
+	DEBUG_ERR(std::find(controllers.begin(), controllers.end(), controller) != controllers.end());
+	controllers.push_back(controller);
 }
 
-void Scene::unregisterController( Controller* controller )
+void Scene::unregisterController(Controller* controller)
 {
-	Vec<Controller*>::iterator it = std::find( controllers.begin(), controllers.end(), controller );
-	DEBUG_ERR( it == controllers.end() );
-	controllers.erase( it );
+	Vec<Controller*>::iterator it = std::find(controllers.begin(), controllers.end(), controller);
+	DEBUG_ERR(it == controllers.end());
+	controllers.erase(it);
 }
 
 
@@ -98,30 +98,30 @@ void Scene::unregisterController( Controller* controller )
 //======================================================================================================================
 void Scene::updateAllWorldStuff()
 {
-	DEBUG_ERR( nodes.size() > 1024 );
+	DEBUG_ERR(nodes.size() > 1024);
 	SceneNode* queue [1024];
 	uint head = 0, tail = 0;
 	uint num = 0;
 
 
 	// put the roots
-	for( uint i=0; i<nodes.size(); i++ )
-		if( nodes[i]->parent == NULL )
+	for(uint i=0; i<nodes.size(); i++)
+		if(nodes[i]->parent == NULL)
 			queue[tail++] = nodes[i]; // queue push
 
 	// loop
-	while( head != tail ) // while queue not empty
+	while(head != tail) // while queue not empty
 	{
 		SceneNode* obj = queue[head++]; // queue pop
 
 		obj->updateWorldStuff();
 		++num;
 
-		for( uint i=0; i<obj->childs.size(); i++ )
+		for(uint i=0; i<obj->childs.size(); i++)
 			queue[tail++] = obj->childs[i];
 	}
 
-	DEBUG_ERR( num != nodes.size() );
+	DEBUG_ERR(num != nodes.size());
 }
 
 
@@ -130,8 +130,8 @@ void Scene::updateAllWorldStuff()
 //======================================================================================================================
 void Scene::updateAllControllers()
 {
-	for( Vec<Controller*>::iterator it=controllers.begin(); it!=controllers.end(); it++ )
+	for(Vec<Controller*>::iterator it=controllers.begin(); it!=controllers.end(); it++)
 	{
-		(*it)->update( 0.0 );
+		(*it)->update(0.0);
 	}
 }

+ 14 - 14
src/Scene/Scene.h

@@ -19,28 +19,28 @@ class Controller;
  */
 class Scene
 {
-	PROPERTY_RW( Vec3, ambientCol, setAmbientCol, getAmbientCol ) ///< The global ambient color
-	PROPERTY_RW( Vec3, sunPos, setSunPos, getSunPos )
-	PROPERTY_RW( PhyWorld*, phyWorld, setPhyWorld, getPhyWorld ) ///< Connection with bullet
+	PROPERTY_RW(Vec3, ambientCol, setAmbientCol, getAmbientCol) ///< The global ambient color
+	PROPERTY_RW(Vec3, sunPos, setSunPos, getSunPos)
+	PROPERTY_RW(PhyWorld*, phyWorld, setPhyWorld, getPhyWorld) ///< Connection with bullet
 
 	private:
 		/**
 		 * @brief Adds a node in a container
 		 */
-		template<typename ContainerType, typename Type> void putBackNode( ContainerType& container, Type* x )
+		template<typename ContainerType, typename Type> void putBackNode(ContainerType& container, Type* x)
 		{
-			DEBUG_ERR( std::find( container.begin(), container.end(), x ) != container.end() );
-			container.push_back( x );
+			DEBUG_ERR(std::find(container.begin(), container.end(), x) != container.end());
+			container.push_back(x);
 		}
 
 		/**
 		 * @brief Removes a node from a container
 		 */
-		template<typename ContainerType, typename Type> void eraseNode( ContainerType& container, Type* x )
+		template<typename ContainerType, typename Type> void eraseNode(ContainerType& container, Type* x)
 		{
-			typename ContainerType::iterator it = std::find( container.begin(), container.end(), x );
-			DEBUG_ERR( it == container.end() );
-			container.erase( it );
+			typename ContainerType::iterator it = std::find(container.begin(), container.end(), x);
+			DEBUG_ERR(it == container.end());
+			container.erase(it);
 		}
 
 	public:
@@ -62,10 +62,10 @@ class Scene
 		// The funcs
 		Scene();
 
-		void registerNode( SceneNode* node ); ///< Put a node in the appropriate containers
-		void unregisterNode( SceneNode* node );
-		void registerController( Controller* controller );
-		void unregisterController( Controller* controller );
+		void registerNode(SceneNode* node); ///< Put a node in the appropriate containers
+		void unregisterNode(SceneNode* node);
+		void registerController(Controller* controller);
+		void unregisterController(Controller* controller);
 
 		void updateAllWorldStuff();
 		void updateAllControllers();

+ 25 - 25
src/Scene/SceneNode.cpp

@@ -18,8 +18,8 @@ void SceneNode::commonConstructorCode()
 	getWorldTransform().setIdentity();
 	getLocalTransform().setIdentity();
 
-	DEBUG_ERR( app->getScene() == NULL );
-	app->getScene()->registerNode( this );
+	DEBUG_ERR(app->getScene() == NULL);
+	app->getScene()->registerNode(this);
 }
 
 
@@ -28,8 +28,8 @@ void SceneNode::commonConstructorCode()
 //======================================================================================================================
 SceneNode::~SceneNode()
 {
-	DEBUG_ERR( app->getScene() == NULL );
-	app->getScene()->unregisterNode( this );
+	DEBUG_ERR(app->getScene() == NULL);
+	app->getScene()->unregisterNode(this);
 }
 
 
@@ -38,9 +38,9 @@ SceneNode::~SceneNode()
 //======================================================================================================================
 void SceneNode::updateWorldTransform()
 {
-	if( parent )
+	if(parent)
 	{
-		worldTransform = Transform::combineTransformations( parent->getWorldTransform(), localTransform );
+		worldTransform = Transform::combineTransformations(parent->getWorldTransform(), localTransform);
 	}
 	else // else copy
 	{
@@ -49,35 +49,35 @@ void SceneNode::updateWorldTransform()
 
 
 	// transform the bvolume
-	/*if( bvolumeLspace != NULL )
+	/*if(bvolumeLspace != NULL)
 	{
-		DEBUG_ERR( bvolumeLspace->type!=bvolume_t::BSPHERE && bvolumeLspace->type!=bvolume_t::AABB && bvolumeLspace->type!=bvolume_t::OBB );
+		DEBUG_ERR(bvolumeLspace->type!=bvolume_t::BSPHERE && bvolumeLspace->type!=bvolume_t::AABB && bvolumeLspace->type!=bvolume_t::OBB);
 
-		switch( bvolumeLspace->type )
+		switch(bvolumeLspace->type)
 		{
 			case bvolume_t::BSPHERE:
 			{
-				bsphere_t sphere = static_cast<bsphere_t*>(bvolumeLspace)->Transformed( translationWspace, rotationWspace, scaleWspace );
+				bsphere_t sphere = static_cast<bsphere_t*>(bvolumeLspace)->Transformed(translationWspace, rotationWspace, scaleWspace);
 				*static_cast<bsphere_t*>(bvolumeLspace) = sphere;
 				break;
 			}
 
 			case bvolume_t::AABB:
 			{
-				aabb_t aabb = static_cast<aabb_t*>(bvolumeLspace)->Transformed( translationWspace, rotationWspace, scaleWspace );
+				aabb_t aabb = static_cast<aabb_t*>(bvolumeLspace)->Transformed(translationWspace, rotationWspace, scaleWspace);
 				*static_cast<aabb_t*>(bvolumeLspace) = aabb;
 				break;
 			}
 
 			case bvolume_t::OBB:
 			{
-				obb_t obb = static_cast<obb_t*>(bvolumeLspace)->Transformed( translationWspace, rotationWspace, scaleWspace );
+				obb_t obb = static_cast<obb_t*>(bvolumeLspace)->Transformed(translationWspace, rotationWspace, scaleWspace);
 				*static_cast<obb_t*>(bvolumeLspace) = obb;
 				break;
 			}
 
 			default:
-				FATAL( "What the fuck" );
+				FATAL("What the fuck");
 		}
 	}*/
 }
@@ -87,19 +87,19 @@ void SceneNode::updateWorldTransform()
 // Move(s)                                                                                                             =
 // Move the object according to it's local axis                                                                        =
 //======================================================================================================================
-void SceneNode::moveLocalX( float distance )
+void SceneNode::moveLocalX(float distance)
 {
 	Vec3 x_axis = localTransform.getRotation().getColumn(0);
 	getLocalTransform().getOrigin() += x_axis * distance;
 }
 
-void SceneNode::moveLocalY( float distance )
+void SceneNode::moveLocalY(float distance)
 {
 	Vec3 y_axis = localTransform.getRotation().getColumn(1);
 	getLocalTransform().getOrigin() += y_axis * distance;
 }
 
-void SceneNode::moveLocalZ( float distance )
+void SceneNode::moveLocalZ(float distance)
 {
 	Vec3 z_axis = localTransform.getRotation().getColumn(2);
 	getLocalTransform().getOrigin() += z_axis * distance;
@@ -109,31 +109,31 @@ void SceneNode::moveLocalZ( float distance )
 //======================================================================================================================
 // addChild                                                                                                            =
 //======================================================================================================================
-void SceneNode::addChild( SceneNode* node )
+void SceneNode::addChild(SceneNode* node)
 {
-	if( node->parent != NULL )
+	if(node->parent != NULL)
 	{
-		ERROR( "Node already has parent" );
+		ERROR("Node already has parent");
 		return;
 	}
 
 	node->parent = this;
-	childs.push_back( node );
+	childs.push_back(node);
 }
 
 
 //======================================================================================================================
 // removeChild                                                                                                         =
 //======================================================================================================================
-void SceneNode::removeChild( SceneNode* node )
+void SceneNode::removeChild(SceneNode* node)
 {
-	Vec<SceneNode*>::iterator it = find( childs.begin(), childs.end(), node );
-	if( it == childs.end() )
+	Vec<SceneNode*>::iterator it = find(childs.begin(), childs.end(), node);
+	if(it == childs.end())
 	{
-		ERROR( "Child not found" );
+		ERROR("Child not found");
 		return;
 	}
 
 	node->parent = NULL;
-	childs.erase( it );
+	childs.erase(it);
 }

+ 13 - 13
src/Scene/SceneNode.h

@@ -14,8 +14,8 @@ class Controller;
 /// Scene node
 class SceneNode
 {
-	PROPERTY_RW( Transform, localTransform, setLocalTransform, getLocalTransform ); ///< The transformation in local space
-	PROPERTY_RW( Transform, worldTransform, setWorldTransform, getWorldTransform ); ///< The transformation in world space (local combined with parent transformation)
+	PROPERTY_RW(Transform, localTransform, setLocalTransform, getLocalTransform); ///< The transformation in local space
+	PROPERTY_RW(Transform, worldTransform, setWorldTransform, getWorldTransform); ///< The transformation in world space (local combined with parent transformation)
 
 	// data
 	public:
@@ -55,22 +55,22 @@ class SceneNode
 		void commonConstructorCode(); ///< Cause we cannot call constructor from other constructor
 		
 	public:
-		SceneNode( Type type_ ): type(type_) { commonConstructorCode(); }
-		SceneNode( Type type_, SceneNode* parent ): type(type_) { commonConstructorCode(); parent->addChild(this); }
+		SceneNode(Type type_): type(type_) { commonConstructorCode(); }
+		SceneNode(Type type_, SceneNode* parent): type(type_) { commonConstructorCode(); parent->addChild(this); }
 		virtual ~SceneNode();
 		virtual void render() = 0;
-		virtual void init( const char* ) = 0; ///< init using a script
+		virtual void init(const char*) = 0; ///< init using a script
 		virtual void deinit() = 0;
 		virtual void updateWorldStuff() { updateWorldTransform(); } ///< This update happens only when the object gets moved. Override it if you want more
 		void updateWorldTransform();
-		void rotateLocalX( float angDegrees ) { localTransform.getRotation().rotateXAxis( angDegrees ); }
-		void rotateLocalY( float angDegrees ) { localTransform.getRotation().rotateYAxis( angDegrees ); }
-		void rotateLocalZ( float angDegrees ) { localTransform.getRotation().rotateZAxis( angDegrees ); }
-		void moveLocalX( float distance );
-		void moveLocalY( float distance );
-		void moveLocalZ( float distance );
-		void addChild( SceneNode* node );
-		void removeChild( SceneNode* node );
+		void rotateLocalX(float angDegrees) { localTransform.getRotation().rotateXAxis(angDegrees); }
+		void rotateLocalY(float angDegrees) { localTransform.getRotation().rotateYAxis(angDegrees); }
+		void rotateLocalZ(float angDegrees) { localTransform.getRotation().rotateZAxis(angDegrees); }
+		void moveLocalX(float distance);
+		void moveLocalY(float distance);
+		void moveLocalZ(float distance);
+		void addChild(SceneNode* node);
+		void removeChild(SceneNode* node);
 };
 
 

+ 19 - 19
src/Scene/SkelModelNode.cpp

@@ -4,61 +4,61 @@
 #include "MeshSkelNodeCtrl.h"
 
 /// Create a skelNode and N meshNodes that have a meshSkelCtrl
-void SkelModelNode::init( const char* filename )
+void SkelModelNode::init(const char* filename)
 {
 	Scanner scanner;
-	if( !scanner.loadFile( filename ) ) return;
+	if(!scanner.loadFile(filename)) return;
 	const Scanner::Token* token;
 
 
 	//** SKELETON **
 	token = &scanner.getNextToken();
-	if( !(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "SKELETON" )) )
+	if(!(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "SKELETON")))
 	{
-		PARSE_ERR_EXPECTED( "identifier SKELETON" );
+		PARSE_ERR_EXPECTED("identifier SKELETON");
 		return;
 	}
 	
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_STRING )
+	if(token->getCode() != Scanner::TC_STRING)
 	{
-		PARSE_ERR_EXPECTED( "string" );
+		PARSE_ERR_EXPECTED("string");
 		return;
 	}
 	
 	skelNode = new SkelNode;
-	skelNode->init( token->getValue().getString() );
-	addChild( skelNode );
+	skelNode->init(token->getValue().getString());
+	addChild(skelNode);
 	
 	//** MESHES **
 	token = &scanner.getNextToken();
-	if( !(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp( token->getValue().getString(), "MESHES_NUM" )) )
+	if(!(token->getCode() == Scanner::TC_IDENTIFIER && !strcmp(token->getValue().getString(), "MESHES_NUM")))
 	{
-		PARSE_ERR_EXPECTED( "identifier MESHES_NUM" );
+		PARSE_ERR_EXPECTED("identifier MESHES_NUM");
 		return;
 	}
 		
 	token = &scanner.getNextToken();
-	if( token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT )
+	if(token->getCode() != Scanner::TC_NUMBER || token->getDataType() != Scanner::DT_INT)
 	{
-		PARSE_ERR_EXPECTED( "integer" );
+		PARSE_ERR_EXPECTED("integer");
 		return;
 	}
 			
-	meshNodes.resize( token->getValue().getInt() );
+	meshNodes.resize(token->getValue().getInt());
 			
-	for( uint i=0; i<meshNodes.size(); ++i )
+	for(uint i=0; i<meshNodes.size(); ++i)
 	{
 		token = &scanner.getNextToken();
-		if( token->getCode() != Scanner::TC_STRING )
+		if(token->getCode() != Scanner::TC_STRING)
 		{
-			PARSE_ERR_EXPECTED( "string" );
+			PARSE_ERR_EXPECTED("string");
 			return;
 		}
 				
 		meshNodes[i] = new MeshNode;
-		meshNodes[i]->init( token->getValue().getString() );
-		skelNode->addChild( meshNodes[i] );
-		meshNodes[i]->meshSkelCtrl = new MeshSkelNodeCtrl( skelNode, meshNodes[i] );
+		meshNodes[i]->init(token->getValue().getString());
+		skelNode->addChild(meshNodes[i]);
+		meshNodes[i]->meshSkelCtrl = new MeshSkelNodeCtrl(skelNode, meshNodes[i]);
 	}
 }

+ 1 - 1
src/Scene/SkelModelNode.h

@@ -20,7 +20,7 @@ class SkelModelNode: public SceneNode
 		SkelNode*   skelNode;
 		
 		SkelModelNode(): SceneNode(NT_SKEL_MODEL), skelNode(NULL) { isCompound = true; }
-		void init( const char* filename );
+		void init(const char* filename);
 		void deinit() {} ///< Do nothing because it loads no resources
 		void render() {} ///< Do nothing
 };

+ 15 - 15
src/Scene/SkelNode.cpp

@@ -10,8 +10,8 @@
 // SkelNode                                                                                                         =
 //======================================================================================================================
 SkelNode::SkelNode(): 
-	SceneNode( NT_SKELETON ),
-	skelAnimCtrl( NULL )
+	SceneNode(NT_SKELETON),
+	skelAnimCtrl(NULL)
 {
 }
 
@@ -19,10 +19,10 @@ SkelNode::SkelNode():
 //======================================================================================================================
 // init                                                                                                                =
 //======================================================================================================================
-void SkelNode::init( const char* filename )
+void SkelNode::init(const char* filename)
 {
-	skeleton = Rsrc::skeletons.load( filename );
-	skelAnimCtrl = new SkelAnimCtrl( this );
+	skeleton = Rsrc::skeletons.load(filename);
+	skelAnimCtrl = new SkelAnimCtrl(this);
 }
 
 
@@ -31,7 +31,7 @@ void SkelNode::init( const char* filename )
 //======================================================================================================================
 void SkelNode::deinit()
 {
-	Rsrc::skeletons.unload( skeleton );
+	Rsrc::skeletons.unload(skeleton);
 }
 
 
@@ -40,19 +40,19 @@ void SkelNode::deinit()
 //======================================================================================================================
 void SkelNode::render()
 {
-	Renderer::Dbg::setModelMat( Mat4(getWorldTransform()) );
-	Renderer::Dbg::setColor( Vec4(1.0, 0.0, 0.0, 1.0) );
+	Renderer::Dbg::setModelMat(Mat4(getWorldTransform()));
+	Renderer::Dbg::setColor(Vec4(1.0, 0.0, 0.0, 1.0));
 
 	Vec<Vec3> positions;
 
-	for( uint i=0; i<skeleton->bones.size(); i++ )
+	for(uint i=0; i<skeleton->bones.size(); i++)
 	{
-		positions.push_back( skelAnimCtrl->heads[i] );
-		positions.push_back( skelAnimCtrl->tails[i] );
+		positions.push_back(skelAnimCtrl->heads[i]);
+		positions.push_back(skelAnimCtrl->tails[i]);
 	}
 
-	glEnableVertexAttribArray( 0 );
-	glVertexAttribPointer( 0, 3, GL_FLOAT, false, 0, &(positions[0][0]) );
-	glDrawArrays( GL_TRIANGLES, 0, positions.size() );
-	glDisableVertexAttribArray( 0 );
+	glEnableVertexAttribArray(0);
+	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, &(positions[0][0]));
+	glDrawArrays(GL_TRIANGLES, 0, positions.size());
+	glDisableVertexAttribArray(0);
 }

+ 2 - 2
src/Scene/SkelNode.h

@@ -8,7 +8,7 @@
 
 
 /**
- * @brief Scene node that extends the @ref Skeleton resource
+ * Scene node that extends the @ref Skeleton resource
  */
 class SkelNode: public SceneNode
 {
@@ -18,7 +18,7 @@ class SkelNode: public SceneNode
 
 		SkelNode();
 		void render();
-		void init( const char* filename );
+		void init(const char* filename);
 		void deinit();
 };
 

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio