Browse Source

Refactoringy

Panagiotis Christopoulos Charitos 15 years ago
parent
commit
4e550370f0

File diff suppressed because it is too large
+ 0 - 0
build/debug/Makefile


+ 3 - 3
src/Collision/Sphere.cpp

@@ -8,8 +8,8 @@
 Sphere Sphere::getTransformed(const Transform& transform) const
 {
 	Sphere newSphere;
-	newSphere.center = center.getTransformed(transform.origin, transform.rotation, transform.scale);
-	newSphere.radius = radius * transform.scale;
+	newSphere.center = center.getTransformed(transform.getOrigin(), transform.getRotation(), transform.getScale());
+	newSphere.radius = radius * transform.getScale();
 	return newSphere;
 }
 
@@ -21,7 +21,7 @@ Sphere Sphere::getCompoundSphere(const Sphere& b) const
 {
 	const Sphere& a = *this;
 
-	Vec3 c = b.getCenter() - a.getCenter();
+	Vec3 c = b.getCenter() - a.getCenter(); // vector from one center to the other
 	float cLen = c.getLength();
 
 	if(cLen + b.getRadius() < a.getRadius())

+ 2 - 1
src/Collision/Sphere.h

@@ -30,7 +30,8 @@ class Sphere: public CollisionShape
 
 		Sphere getTransformed(const Transform& transform) const;
 
-		/// Get the sphere that includes this sphere and the given
+		/// Get the sphere that includes this sphere and the given. See a drawing in the docs dir for more info about the
+		/// algorithm
 		Sphere getCompoundSphere(const Sphere& b) const;
 
 		/// @see CollisionShape::testPlane

+ 6 - 6
src/Main.cpp

@@ -66,7 +66,7 @@ void initPhysics()
 
 	Transform groundTransform;
 	groundTransform.setIdentity();
-	groundTransform.origin = Vec3(0,-50, 0);
+	groundTransform.setOrigin(Vec3(0,-50, 0));
 
 	RigidBody::Initializer init;
 	init.mass = 0.0;
@@ -209,7 +209,7 @@ void init()
 	// particle emitter
 	partEmitter = new ParticleEmitter;
 	partEmitter->init("asdf");
-	partEmitter->getLocalTransform().origin = Vec3(3.0, 0.0, 0.0);
+	partEmitter->getLocalTransform().setOrigin(Vec3(3.0, 0.0, 0.0));
 
 	// character
 	/*PhyCharacter::Initializer init;
@@ -283,10 +283,10 @@ void mainLoop()
 		}
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_Q)) mover->rotateLocalZ(ang);
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_E)) mover->rotateLocalZ(-ang);
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEUP)) mover->getLocalTransform().scale += scale ;
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEDOWN)) mover->getLocalTransform().scale -= scale ;
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEUP)) mover->getLocalTransform().getScale() += scale ;
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_PAGEDOWN)) mover->getLocalTransform().getScale() -= scale ;
 
-		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_K)) AppSingleton::getInstance().getActiveCam()->lookAtPoint(point_lights[0]->getWorldTransform().origin);
+		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_K)) AppSingleton::getInstance().getActiveCam()->lookAtPoint(point_lights[0]->getWorldTransform().getOrigin());
 
 		if(InputSingleton::getInstance().getKey(SDL_SCANCODE_I))
 			character->moveForward(0.1);
@@ -307,7 +307,7 @@ void mainLoop()
 			ScriptingEngineSingleton::getInstance().execScript(Util::readFile("test.py").c_str());
 		}
 
-		mover->getLocalTransform().rotation.reorthogonalize();
+		mover->getLocalTransform().getRotation().reorthogonalize();
 
 		AppSingleton::getInstance().execStdinScpripts();
 		SceneSingleton::getInstance().getPhysics().update(crntTime);

+ 21 - 3
src/Math/Axisang.h

@@ -11,14 +11,32 @@ namespace M {
 class Axisang
 {
 	public:
-		float ang;
-		Vec3 axis;
-
+		/// @name Constructors
+		/// @{
 		explicit Axisang();
 		         Axisang(const Axisang& b);
 		explicit Axisang(float rad, const Vec3& axis_);
 		explicit Axisang(const Quat& q);
 		explicit Axisang(const Mat3& m3);
+		/// @}
+		
+		/// @name Accessors
+		/// @{
+		float getAngle() const;
+		float& getAngle();
+		void setAngle(float a);
+		
+		const Vec3& getAxis() const;
+		Vec3& getAxis();
+		void setAxis(const Vec3& a);
+		/// @}
+		
+	private:
+		/// @name Data
+		/// @{
+		float ang;
+		Vec3 axis;
+		/// @}
 };
 
 

+ 106 - 31
src/Math/Axisang.inl.h

@@ -4,39 +4,48 @@
 namespace M {
 
 
-// constructor []
-inline Axisang::Axisang()
-	: ang(0.0), axis()
+//======================================================================================================================
+// Constructors                                                                                                        =
+//======================================================================================================================
+
+// Default
+inline Axisang::Axisang():
+	ang(0.0),
+	axis(0.0)
 {}
 
-// constructor [Axisang]
-inline Axisang::Axisang(const Axisang& b)
-	: ang(b.ang), axis(b.axis)
+// Axisang
+inline Axisang::Axisang(const Axisang& b):
+	ang(b.ang),
+	axis(b.axis)
 {}
 
-// constructor [float, axis]
-inline Axisang::Axisang(float rad, const Vec3& axis_)
-	: ang(rad), axis(axis_)
+// float, axis
+inline Axisang::Axisang(float rad, const Vec3& axis_):
+	ang(rad),
+	axis(axis_)
 {}
 
-// constructor [quat]
+// Quat
 inline Axisang::Axisang(const Quat& q)
 {
-	ang = 2.0*acos(q.w);
-	float length = M::sqrt(1.0 - q.w*q.w);
+	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);
+		length = 1.0 / length;
+		axis = Vec3(q.x() * length, q.y() * length, q.z() * length);
 	}
 }
 
 // constructor [mat3]
 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) &&
@@ -48,47 +57,113 @@ inline Axisang::Axisang(const Mat3& m3)
 		}
 
 		ang = PI;
-		axis.x() = (m3(0, 0)+1)/2;
+		axis.x() = (m3(0, 0)+1) / 2.0;
 		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() = M::sqrt(axis.y());
+		}
 		else
+		{
 			axis.y() = 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 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(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();
+			}
 		}
 
 		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;
+	}
+
+	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;
+}
+
+
+//======================================================================================================================
+// Accessors                                                                                                           =
+//======================================================================================================================
 
-	if(fabs(s) < 0.001) s = 1;
+inline float Axisang::getAngle() const
+{
+	return ang;
+}
+
+inline float& Axisang::getAngle()
+{
+	return ang;
+}
 
-	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;
+inline void Axisang::setAngle(float a)
+{
+	ang = a;
+}
+
+inline const Vec3& Axisang::getAxis() const
+{
+	return axis;
+}
+
+inline Vec3& Axisang::getAxis()
+{
+	return axis;
+}
+
+inline void Axisang::setAxis(const Vec3& a)
+{
+	axis = a;
 }
 
 

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

@@ -63,28 +63,28 @@ inline Euler::Euler(const Euler& b)
 // constructor [quat]
 inline Euler::Euler(const Quat& q)
 {
-	float test = q.x*q.y + q.z*q.w;
+	float test = q.x() * q.y() + q.z() * q.w();
 	if(test > 0.499)
 	{
-		getHeading() = 2.0 * atan2(q.x, q.w);
-		getAttitude() = PI/2.0;
+		getHeading() = 2.0 * atan2(q.x(), q.w());
+		getAttitude() = PI / 2.0;
 		getBank() = 0.0;
 		return;
 	}
 	if(test < -0.499)
 	{
-		getHeading() = -2.0 * atan2(q.x, q.w);
-		getAttitude() = -PI/2.0;
+		getHeading() = -2.0 * atan2(q.x(), q.w());
+		getAttitude() = -PI / 2.0;
 		getBank() = 0.0;
 		return;
 	}
 
-	float sqx = q.x*q.x;
-	float sqy = q.y*q.y;
-	float sqz = q.z*q.z;
-	getHeading() = atan2(2.0*q.y*q.w-2.0*q.x*q.z, 1.0-2.0*sqy-2.0*sqz);
-	getAttitude() = asin(2.0f*test);
-	getBank() = atan2(2.0*q.x*q.w-2.0*q.y*q.z, 1.0-2.0*sqx-2.0*sqz);
+	float sqx = q.x() * q.x();
+	float sqy = q.y() * q.y();
+	float sqz = q.z() * q.z();
+	getHeading() = atan2(2.0 * q.y() * q.w() - 2.0 * q.x() * q.z(), 1.0 - 2.0 * sqy - 2.0 * sqz);
+	getAttitude() = asin(2.0f * test);
+	getBank() = atan2(2.0 * q.x() * q.w() - 2.0 * q.y() * q.z(), 1.0 - 2.0 * sqx - 2.0 * sqz);
 }
 
 // constructor [mat3]

+ 40 - 39
src/Math/Mat3.inl.h

@@ -6,30 +6,6 @@
 
 namespace M {
 
-//======================================================================================================================
-// Accessor                                                                                                            =
-//======================================================================================================================
-
-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
-{
-	return arr2[i][j]; 
-}
-
-inline float& Mat3::operator[](const uint i)
-{
-	return arr1[i];
-}
-
-inline const float& Mat3::operator[](const uint i) const
-{
-	return arr1[i];
-}
-
 
 //======================================================================================================================
 // Constructors                                                                                                        =
@@ -83,18 +59,18 @@ inline Mat3::Mat3(const Quat& q)
 
 	float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
-	xs = q.x + q.x;
-	ys = q.y + q.y;
-	zs = q.z + q.z;
-	wx = q.w * xs;
-	wy = q.w * ys;
-	wz = q.w * zs;
-	xx = q.x * xs;
-	xy = q.x * ys;
-	xz = q.x * zs;
-	yy = q.y * ys;
-	yz = q.y * zs;
-	zz = q.z * zs;
+	xs = q.x() + q.x();
+	ys = q.y() + q.y();
+	zs = q.z() + q.z();
+	wx = q.w() * xs;
+	wy = q.w() * ys;
+	wz = q.w() * zs;
+	xx = q.x() * xs;
+	xy = q.x() * ys;
+	xz = q.x() * zs;
+	yy = q.y() * ys;
+	yz = q.y() * zs;
+	zz = q.z() * zs;
 
 	SELF(0, 0) = 1.0 - (yy + zz);
 	SELF(0, 1) = xy - wz;
@@ -131,13 +107,13 @@ inline Mat3::Mat3(const Euler& e)
 // Axisang
 inline Mat3::Mat3(const Axisang& axisang)
 {
-	RASSERT_THROW_EXCEPTION(!isZero(1.0 - axisang.axis.getLength())); // Not normalized axis
+	RASSERT_THROW_EXCEPTION(!isZero(1.0 - axisang.getAxis().getLength())); // Not normalized axis
 
 	float c, s;
-	sinCos(axisang.ang, s, c);
+	sinCos(axisang.getAngle(), s, c);
 	float t = 1.0 - c;
 
-	const Vec3& axis = axisang.axis;
+	const Vec3& axis = axisang.getAxis();
 	SELF(0, 0) = c + axis.x() * axis.x() * t;
 	SELF(1, 1) = c + axis.y() * axis.y() * t;
 	SELF(2, 2) = c + axis.z() * axis.z() * t;
@@ -156,6 +132,31 @@ inline Mat3::Mat3(const Axisang& axisang)
 }
 
 
+//======================================================================================================================
+// Accessors                                                                                                            =
+//======================================================================================================================
+
+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
+{
+	return arr2[i][j];
+}
+
+inline float& Mat3::operator[](const uint i)
+{
+	return arr1[i];
+}
+
+inline const float& Mat3::operator[](const uint i) const
+{
+	return arr1[i];
+}
+
+
 //======================================================================================================================
 // Operators with same                                                                                                 =
 //======================================================================================================================

+ 1 - 1
src/Math/Mat4.inl.h

@@ -162,7 +162,7 @@ inline Mat4::Mat4(const Vec3& translate, const Mat3& rotate, float scale)
 // Transform
 inline Mat4::Mat4(const Transform& t)
 {
-	SELF = Mat4(t.origin, t.rotation, t.scale);
+	SELF = Mat4(t.getOrigin(), t.getRotation(), t.getScale());
 }
 
 

+ 22 - 6
src/Math/Quat.h

@@ -11,11 +11,6 @@ namespace M {
 class Quat
 {
 	public:
-		/// @name Data
-		/// @{
-		float x, y, z, w;
-		/// @}
-
 		/// @name Constructors & destructors
 		/// @{
 		explicit Quat();
@@ -30,7 +25,19 @@ class Quat
 		explicit Quat(const Axisang& axisang);
 		/// @}
 
-		/// Operatorswith same
+		/// @name Accessors
+		/// @{
+		float x() const;
+		float& x();
+		float y() const;
+		float& y();
+		float z() const;
+		float& z();
+		float w() const;
+		float& w();
+		/// @}
+
+		/// Operators with same
 		/// @{
 		Quat operator *(const Quat& b) const; ///< 16 muls, 12 adds
 		Quat& operator *=(const Quat& b);
@@ -55,6 +62,15 @@ class Quat
 		void  setIdentity();
 		static const Quat& getIdentity();
 		/// @}
+
+	private:
+		/// @name Data
+		/// @{
+		struct
+		{
+			float x, y, z, w;
+		} vec;
+		/// @}
 };
 
 

+ 162 - 80
src/Math/Quat.inl.h

@@ -6,133 +6,210 @@
 namespace M {
 
 
-// constructor []
-inline Quat::Quat():
-	x(0.0), y(0.0), z(0.0), w(1.0)
-{}
+//======================================================================================================================
+// Constructors                                                                                                        =
+//======================================================================================================================
 
-// constructor [float]
-inline Quat::Quat(float f):
-	x(f), y(f), z(f), w(f)
-{}
+// Default
+inline Quat::Quat()
+{
+	x() = y() = z() = w() = 0.0;
+}
+
+// float
+inline Quat::Quat(float f)
+{
+	x() = y() = z() = w() = f;
+}
 
-// constructor [float, float, float, float]
-inline Quat::Quat(float x_, float y_, float z_, float w_):
-	x(x_), y(y_), z(z_), w(w_)
-{}
+// float, float, float, float
+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_):
-	x(v2.x()), y(v2.y()), z(z_), w(w_)
-{}
+inline Quat::Quat(const Vec2& v, float z_, float w_)
+{
+	x() = v.x();
+	y() = v.y();
+	z() = z_;
+	w() = w_;
+}
 
 // constructor [vec3, float]
-inline Quat::Quat(const Vec3& v3, float w_):
-	x(v3.x()), y(v3.y()), z(v3.z()), w(w_)
-{}
+inline Quat::Quat(const Vec3& v, float w_)
+{
+	x() = v.x();
+	y() = v.y();
+	z() = v.z();
+	w() = w_;
+}
 
 // constructor [vec4]
-inline Quat::Quat(const Vec4& v4):
-	x(v4.x()), y(v4.y()), z(v4.z()), w(v4.w())
-{}
+inline Quat::Quat(const Vec4& v)
+{
+	x() = v.x();
+	y() = v.y();
+	z() = v.z();
+	w() = v.w();
+}
 
-// constructor [quat]
-inline Quat::Quat(const Quat& b):
-	x(b.x), y(b.y), z(b.z), w(b.w)
-{}
+// Copy
+inline Quat::Quat(const Quat& b)
+{
+	x() = b.x();
+	y() = b.y();
+	z() = b.z();
+	w() = b.w();
+}
 
-// constructor [mat3]
+// mat3
 inline Quat::Quat(const Mat3& m3)
 {
 	float trace = m3(0, 0) + m3(1, 1) + m3(2, 2) + 1.0;
 	if(trace > EPSILON)
 	{
 		float s = 0.5 / sqrt(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;
+		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;
 	}
 	else
 	{
 		if(m3(0, 0) > m3(1, 1) && m3(0, 0) > m3(2, 2))
 		{
 			float s = 0.5 / sqrt(1.0 + m3(0, 0) - m3(1, 1) - m3(2, 2));
-			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;
+			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;
 		}
 		else if(m3(1, 1) > m3(2, 2))
 		{
 			float s = 0.5 / sqrt(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;
+			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;
 		}
 		else
 		{
 			float s = 0.5 / sqrt(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;
+			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]
+// euler
 inline Quat::Quat(const Euler& eu)
 {
 	float cx, sx;
-	sinCos(eu.getHeading()*0.5, sx, cx);
+	sinCos(eu.getHeading() * 0.5, sx, cx);
 
 	float cy, sy;
-	sinCos(eu.getAttitude()*0.5, sy, cy);
+	sinCos(eu.getAttitude() * 0.5, sy, cy);
 
 	float cz, sz;
-	sinCos(eu.getBank()*0.5, sz, cz);
-
-	float cxcy = cx*cy;
-	float sxsy = sx*sy;
-	x = cxcy*sz + sxsy*cz;
-	y = sx*cy*cz + cx*sy*sz;
-	z = cx*sy*cz - sx*cy*sz;
-	w = cxcy*cz - sxsy*sz;
+	sinCos(eu.getBank() * 0.5, sz, cz);
+
+	float cxcy = cx * cy;
+	float sxsy = sx * sy;
+	x() = cxcy * sz + sxsy * cz;
+	y() = sx * cy * cz + cx * sy * sz;
+	z() = cx * sy * cz - sx * cy * sz;
+	w() = cxcy * cz - sxsy * sz;
 }
 
-// constructor [euler]
+// euler
 inline Quat::Quat(const Axisang& axisang)
 {
-	float lengthsq = axisang.axis.getLengthSquared();
+	float lengthsq = axisang.getAxis().getLengthSquared();
 	if(isZero(lengthsq))
 	{
 		ME = getIdentity();
 		return;
 	}
 
-	float rad = axisang.ang * 0.5;
+	float rad = axisang.getAngle() * 0.5;
 
 	float sintheta, costheta;
 	sinCos(rad, sintheta, costheta);
 
 	float scalefactor = sintheta / sqrt(lengthsq);
 
-	x = scalefactor * axisang.axis.x();
-	y = scalefactor * axisang.axis.y();
-	z = scalefactor * axisang.axis.z();
-	w = costheta;
+	x() = scalefactor * axisang.getAxis().x();
+	y() = scalefactor * axisang.getAxis().y();
+	z() = scalefactor * axisang.getAxis().z();
+	w() = costheta;
+}
+
+
+//======================================================================================================================
+// Accessors                                                                                                           =
+//======================================================================================================================
+
+inline float Quat::x() const
+{
+	return vec.x;
 }
 
+
+inline float& Quat::x()
+{
+	return vec.x;
+}
+
+inline float Quat::y() const
+{
+	return vec.y;
+}
+
+inline float& Quat::y()
+{
+	return vec.y;
+}
+
+inline float Quat::z() const
+{
+	return vec.z;
+}
+
+inline float& Quat::z()
+{
+	return vec.z;
+}
+
+inline float Quat::w() const
+{
+	return vec.w;
+}
+
+inline float& Quat::w()
+{
+	return vec.w;
+}
+
+
+//======================================================================================================================
+// Operators with same                                                                                                 =
+//======================================================================================================================
+
 // *
 inline Quat Quat::operator *(const Quat& b) const
 {
 	return Quat(
-		 x * b.w + y * b.z - z * b.y + w * b.x,
-		-x * b.z + y * b.w + z * b.x + w * b.y,
-		 x * b.y - y * b.x + z * b.w + w * b.z,
-		-x * b.x - y * b.y - z * b.z + w * b.w
+		 x() * b.w() + y() * b.z() - z() * b.y() + w() * b.x(),
+		-x() * b.z() + y() * b.w() + z() * b.x() + w() * b.y(),
+		 x() * b.y() - y() * b.x() + z() * b.w() + w() * b.z(),
+		-x() * b.x() - y() * b.y() - z() * b.z() + w() * b.w()
 	);
 }
 
@@ -146,27 +223,32 @@ inline Quat& Quat::operator *=(const Quat& b)
 // ==
 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());
 }
 
 // !=
 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()));
 }
 
+
+//======================================================================================================================
+// Other                                                                                                               =
+//======================================================================================================================
+
 // conjugate
 inline void Quat::conjugate()
 {
-	x = -x;
-	y = -y;
-	z = -z;
+	x() = -x();
+	y() = -y();
+	z() = -z();
 }
 
 // getConjugated
 inline Quat Quat::getConjugated() const
 {
-	return Quat(-x, -y, -z, w);
+	return Quat(-x(), -y(), -z(), w());
 }
 
 // Normalized
@@ -184,19 +266,19 @@ 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());
 }
 
 
 // getInverted
 inline Quat Quat::getInverted() const
 {
-	float norm = w*w + x*x + y*y + z*z;
+	float norm = w() * w() + x() * x() + y() * y() + z() * z();
 
 	RASSERT_THROW_EXCEPTION(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
@@ -211,9 +293,9 @@ 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));
 	normalize();
-	w += 1.0;
+	w() += 1.0;
 
-	if(w <= EPSILON)
+	if(w() <= EPSILON)
 	{
 		if(from.z() * from.z() > from.x() * from.x())
 		{
@@ -242,7 +324,7 @@ inline void Quat::rotate(const Quat& b)
 // dot
 inline float Quat::dot(const Quat& b) const
 {
-	return w*b.w + x*b.x + y*b.y + z*b.z;
+	return w() * b.w() + x() * b.x() + y() * b.y() + z() * b.z();
 }
 
 // SLERP
@@ -250,7 +332,7 @@ inline Quat Quat::slerp(const Quat& q1_, float t) const
 {
 	const Quat& q0 = ME;
 	Quat q1(q1_);
-	float cosHalfTheta = q0.w*q1.w + q0.x*q1.x + q0.y*q1.y + q0.z*q1.z;
+	float cosHalfTheta = q0.w() * q1.w() + q0.x() * q1.x() + q0.y() * q1.y() + q0.z() * q1.z();
 	if(cosHalfTheta < 0.0)
 	{
 		q1 = Quat(-Vec4(q1)); // quat changes
@@ -281,8 +363,8 @@ inline Quat Quat::slerp(const Quat& q1_, float t) const
 // setIdentity
 inline void Quat::setIdentity()
 {
-	x = y = z = 0.0;
-	w = 1.0;
+	x() = y() = z() = 0.0;
+	w() = 1.0;
 }
 
 // getIdentity
@@ -295,7 +377,7 @@ inline const Quat& Quat::getIdentity()
 // print
 inline std::ostream& operator<<(std::ostream& s, const Quat& q)
 {
-	s << q.w << ' ' << q.x << ' ' << q.y << ' ' << q.z;
+	s << q.w() << ' ' << q.x() << ' ' << q.y() << ' ' << q.z();
 	return s;
 }
 

+ 23 - 7
src/Math/Transform.h

@@ -11,13 +11,6 @@ namespace M {
 class Transform
 {
 	public:
-		/// @name Data
-		/// @{
-		Vec3 origin; ///< The rotation
-		Mat3 rotation; ///< The translation
-		float scale; ///< The uniform scaling
-		/// @}
-
 		/// @name Constructors
 		/// @{
 		explicit Transform();
@@ -26,12 +19,35 @@ class Transform
 		explicit Transform(const Vec3& origin, const Mat3& rotation_, float scale_);
 		/// @}
 
+		/// @name Accessors
+		/// @{
+		const Vec3& getOrigin() const;
+		Vec3& getOrigin();
+		void setOrigin(const Vec3 o);
+		
+		const Mat3& getRotation() const;
+		Mat3& getRotation();
+		void setRotation(const Mat3& r);
+		
+		float getScale() const;
+		float& getScale();
+		void setScale(float s);
+		/// @}
+
 		/// @name Other
 		/// @{
 		void setIdentity();
 		static const Transform& getIdentity();
 		static Transform combineTransformations(const Transform& a, const Transform& b); ///< @see M::combineTransformations
 		/// @}
+		
+	private:
+		/// @name Data
+		/// @{
+		Vec3 origin; ///< The rotation
+		Mat3 rotation; ///< The translation
+		float scale; ///< The uniform scaling
+		/// @}
 };
 
 

+ 65 - 5
src/Math/Transform.inl.h

@@ -7,18 +7,22 @@
 namespace M {
 
 
-// constructor []
+//======================================================================================================================
+// Constructors                                                                                                        =
+//======================================================================================================================
+
+// Default
 inline Transform::Transform()
 {}
 
-// constructor [Transform]
+// Copy
 inline Transform::Transform(const Transform& b):
 	origin(b.origin),
 	rotation(b.rotation),
 	scale(b.scale)
 {}
 
-// constructor [Mat4]
+// Mat4
 inline Transform::Transform(const Mat4& m4)
 {
 	rotation = m4.getRotationPart();
@@ -26,13 +30,68 @@ inline Transform::Transform(const Mat4& m4)
 	scale = 1.0;
 }
 
-// constructor [Vec3, Quat, float]
+// Vec3, Quat, float
 inline Transform::Transform(const Vec3& origin, const Mat3& rotation_, float scale_):
 	origin(origin),
 	rotation(rotation_),
 	scale(scale_)
 {}
 
+
+//======================================================================================================================
+// Accessors                                                                                                           =
+//======================================================================================================================
+
+inline const Vec3& Transform::getOrigin() const
+{
+	return origin;
+}
+
+inline Vec3& Transform::getOrigin()
+{
+	return origin;
+}
+
+inline void Transform::setOrigin(const Vec3 o)
+{
+	origin = o;
+}
+
+inline const Mat3& Transform::getRotation() const
+{
+	return rotation;
+}
+
+inline Mat3& Transform::getRotation()
+{
+	return rotation;
+}
+
+inline void Transform::setRotation(const Mat3& r)
+{
+	rotation = r;
+}
+
+inline float Transform::getScale() const
+{
+	return scale;
+}
+
+inline float& Transform::getScale()
+{
+	return scale;
+}
+
+inline void Transform::setScale(float s)
+{
+	scale = s;
+}
+
+
+//======================================================================================================================
+// Other                                                                                                               =
+//======================================================================================================================
+
 // setIdentity
 inline void Transform::setIdentity()
 {
@@ -50,7 +109,8 @@ inline const Transform& Transform::getIdentity()
 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;
 }
 

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

@@ -8,7 +8,7 @@ namespace M {
 
 
 //======================================================================================================================
-// Constructors                                                                                                                    =
+// Constructors                                                                                                        =
 //======================================================================================================================
 
 // default

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

@@ -66,9 +66,9 @@ inline Vec3::Vec3(const Vec4& v4)
 // Quat
 inline Vec3::Vec3(const Quat& q)
 {
-	x() = q.x;
-	y() = q.y;
-	z() = q.z;
+	x() = q.x();
+	y() = q.y();
+	z() = q.z();
 }
 
 //======================================================================================================================
@@ -345,7 +345,7 @@ inline Vec3 Vec3::getRotated(const Quat& q) const
 							   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 SELF + qXyz.cross(qXyz.cross(SELF) + SELF * q.w) * 2.0;
+	return SELF + qXyz.cross(qXyz.cross(SELF) + SELF * q.w()) * 2.0;
 }
 
 // rotate
@@ -420,7 +420,7 @@ inline void Vec3::transform(const Mat4& transform)
 // Transform
 inline Vec3 Vec3::getTransformed(const Transform& transform) const
 {
-	return (transform.rotation * (SELF * transform.scale)) + transform.origin;
+	return (transform.getRotation() * (SELF * transform.getScale())) + transform.getOrigin();
 }
 
 // Transform

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

@@ -91,10 +91,10 @@ inline Vec4::Vec4(const Vec4& b)
 // quat
 inline Vec4::Vec4(const Quat& q)
 {
-	x() = q.x;
-	y() = q.y;
-	z() = q.z;
-	w() = q.w;
+	x() = q.x();
+	y() = q.y();
+	z() = q.z();
+	w() = q.w();
 }
 
 // __m128

+ 6 - 6
src/Physics/BtAndAnkiConvertors.h

@@ -35,9 +35,9 @@ inline Quat toAnki(const btQuaternion& q)
 inline Transform toAnki(const btTransform& t)
 {
 	Transform out;
-	out.rotation = toAnki(t.getBasis());
-	out.origin = toAnki(t.getOrigin());
-	out.scale = 1.0;
+	out.setRotation(toAnki(t.getBasis()));
+	out.setOrigin(toAnki(t.getOrigin()));
+	out.setScale(1.0);
 	return out;
 }
 
@@ -74,15 +74,15 @@ inline btTransform toBt(const Mat4& m)
 
 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)
 {
 	btTransform r;
-	r.setOrigin(toBt(trf.origin));
-	r.setRotation(toBt(Quat(trf.rotation)));
+	r.setOrigin(toBt(trf.getOrigin()));
+	r.setRotation(toBt(Quat(trf.getRotation())));
 	return r;
 }
 

+ 2 - 2
src/Physics/MotionState.h

@@ -56,9 +56,9 @@ inline void MotionState::setWorldTransform(const btTransform& worldTrans)
 	if(node)
 	{
 		Transform& nodeTrf = node->getLocalTransform();
-		float originalScale = nodeTrf.scale;
+		float originalScale = nodeTrf.getScale();
 		nodeTrf = toAnki(worldTrans);
-		nodeTrf.scale = originalScale;
+		nodeTrf.setScale(originalScale);
 	}
 }
 

+ 2 - 2
src/Renderer/Is.cpp

@@ -218,7 +218,7 @@ void Is::pointLightPass(const PointLight& light)
 	shader.findUniVar("msSpecularFai")->setTexture(r.getMs().getSpecularFai(), 2);
 	shader.findUniVar("msDepthFai")->setTexture(r.getMs().getDepthFai(), 3);
 	shader.findUniVar("planes")->setVec2(&planes);
-	Vec3 lightPosEyeSpace = light.getWorldTransform().origin.getTransformed(cam.getViewMatrix());
+	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
 	shader.findUniVar("lightPos")->setVec3(&lightPosEyeSpace);
 	shader.findUniVar("lightRadius")->setFloat(light.getRadius());
 	shader.findUniVar("lightDiffuseCol")->setVec3(&light.lightData->getDiffuseCol());
@@ -281,7 +281,7 @@ void Is::spotLightPass(const SpotLight& light)
 	shdr->findUniVar("planes")->setVec2(&planes);
 
 	// the light params
-	Vec3 lightPosEyeSpace = light.getWorldTransform().origin.getTransformed(cam.getViewMatrix());
+	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
 	shdr->findUniVar("lightPos")->setVec3(&lightPosEyeSpace);
 	shdr->findUniVar("lightRadius")->setFloat(light.getDistance());
 	shdr->findUniVar("lightDiffuseCol")->setVec3(&light.lightData->getDiffuseCol());

+ 1 - 1
src/Renderer/Smo.cpp

@@ -73,7 +73,7 @@ void Smo::run(const PointLight& light)
 	// set shared prog
 	const float scale = 1.2; // we scale the sphere a little
 	sProg->bind();
-	Mat4 modelMat = Mat4(light.getWorldTransform().origin, Mat3::getIdentity(), light.getRadius() * scale);
+	Mat4 modelMat = Mat4(light.getWorldTransform().getOrigin(), Mat3::getIdentity(), light.getRadius() * scale);
 	Mat4 trf = r.getViewProjectionMat() * modelMat;
 	sProg->findUniVar("modelViewProjectionMat")->setMat4(&trf);
 

+ 11 - 1
src/Resources/Core/RsrcAsyncLoadingReqsHandler.cpp

@@ -1,6 +1,7 @@
 #include "RsrcAsyncLoadingReqsHandler.h"
 #include "Texture.h"
 #include "Logger.h"
+#include "HighRezTimer.h"
 
 
 //======================================================================================================================
@@ -18,8 +19,11 @@ void RsrcAsyncLoadingReqsHandler::sendNewLoadingRequest<Texture>(const char* fil
 //======================================================================================================================
 // serveFinishedRequests                                                                                               =
 //======================================================================================================================
-void RsrcAsyncLoadingReqsHandler::serveFinishedRequests(uint /*maxTime*/)
+void RsrcAsyncLoadingReqsHandler::serveFinishedRequests(uint maxTime)
 {
+	HighRezTimer t;
+	t.start();
+
 	while(1)
 	{
 		std::string filename;
@@ -51,6 +55,12 @@ void RsrcAsyncLoadingReqsHandler::serveFinishedRequests(uint /*maxTime*/)
 		}
 		
 		requests.pop_front();
+
+		// Leave if you passed the max time
+		if(t.getElapsedTime() >= maxTime)
+		{
+			break;
+		}
 	}
 }
 

+ 7 - 6
src/Resources/Core/RsrcAsyncLoadingReqsHandler.h

@@ -9,7 +9,7 @@
 #include "MeshData.h"
 
 
-// Dont even think to include the files those:
+// Dont even think to include these files:
 class Texture;
 class Mesh;
 
@@ -19,16 +19,17 @@ class Mesh;
 class RsrcAsyncLoadingReqsHandler
 {
 	public:
-		/// Send a loading requst to an AsyncLoader
+		/// Send a loading request to an AsyncLoader
 		/// @tparam Type It should be Texture or Mesh
 		/// @param filename The file to load
-		/// @param objToLoad Pointer to a pointer to the object to load asynchronusly
+		/// @param objToLoad Pointer to a pointer to the object to load asynchronously
 		template<typename Type>
 		void sendNewLoadingRequest(const char* filename, Type** objToLoad);
 		
-		/// Serve the finished requests. This should be called periodicaly in the main loop
-		/// @param maxTime The max time to spend serving finished requests in a single call. If for example there are many
-		/// requests it wont serve them all at one time, it will leave some for later
+		/// Serve the finished requests. This should be called once every loop of the main loop
+		/// @param maxTime The max time to spend serving finished requests. If for example there are many that need more
+		/// time than the max the method will return. The pending requests will be served when it will be called again.
+		/// In ms
 		void serveFinishedRequests(uint maxTime);
 		
 	

+ 8 - 8
src/Scene/Camera.cpp

@@ -21,10 +21,10 @@ void Camera::setAll(float fovx_, float fovy_, float znear_, float zfar_)
 void Camera::lookAtPoint(const Vec3& point)
 {
 	const Vec3& j = Vec3(0.0, 1.0, 0.0);
-	Vec3 vdir = (point - getLocalTransform().origin).getNormalized();
+	Vec3 vdir = (point - getLocalTransform().getOrigin()).getNormalized();
 	Vec3 vup = j - vdir * j.dot(vdir);
 	Vec3 vside = vdir.cross(vup);
-	getLocalTransform().rotation.setColumns(vside, vup, -vdir);
+	getLocalTransform().getRotation().setColumns(vside, vup, -vdir);
 }
 
 
@@ -61,9 +61,9 @@ void Camera::updateWSpaceFrustumPlanes()
 {
 	for(uint i=0; i<6; i++)
 	{
-		wspaceFrustumPlanes[i] = lspaceFrustumPlanes[i].getTransformed(getWorldTransform().origin,
-		                                                               getWorldTransform().rotation,
-		                                                               getWorldTransform().scale);
+		wspaceFrustumPlanes[i] = lspaceFrustumPlanes[i].getTransformed(getWorldTransform().getOrigin(),
+		                                                               getWorldTransform().getRotation(),
+		                                                               getWorldTransform().getScale());
 	}
 }
 
@@ -104,7 +104,7 @@ bool Camera::insideFrustum(const Camera& cam) const
 	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().origin); // eye (already in world space)
+	points[4] = 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++)
@@ -176,8 +176,8 @@ void Camera::updateViewMatrix()
 	*/
 
 	// The view matrix is: Mview = camera.world_transform.Inverted(). Bus instead of inverting we do the following:
-	Mat3 camInvertedRot = getWorldTransform().rotation.getTransposed();
-	Vec3 camInvertedTsl = -(camInvertedRot * getWorldTransform().origin);
+	Mat3 camInvertedRot = getWorldTransform().getRotation().getTransposed();
+	Vec3 camInvertedTsl = -(camInvertedRot * getWorldTransform().getOrigin());
 	viewMat = Mat4(camInvertedTsl, camInvertedRot);
 }
 

+ 3 - 3
src/Scene/ParticleEmitter.cpp

@@ -75,7 +75,7 @@ void ParticleEmitter::update()
 	float crntTime = AppSingleton::getInstance().getTicks() / 1000.0;
 
 	// Opt: We dont have to make extra calculations if the ParticleEmitter's rotation is the identity
-	bool identRot = getWorldTransform().rotation == Mat3::getIdentity();
+	bool identRot = getWorldTransform().getRotation() == Mat3::getIdentity();
 
 	// deactivate the dead particles
 	for(uint i=0; i<particles.size(); i++)
@@ -143,7 +143,7 @@ void ParticleEmitter::update()
 
 				if(!identRot)
 				{
-					forceDir = getWorldTransform().rotation * forceDir; // the forceDir depends on the particle emitter rotation
+					forceDir = getWorldTransform().getRotation() * forceDir; // the forceDir depends on the particle emitter rotation
 				}
 
 				Vec3 force;
@@ -189,7 +189,7 @@ void ParticleEmitter::update()
 			}
 
 			if(identRot)
-				pos += getWorldTransform().origin;
+				pos += getWorldTransform().getOrigin();
 			else
 				pos.transform(getWorldTransform());
 

+ 6 - 6
src/Scene/SceneNode.cpp

@@ -90,19 +90,19 @@ void SceneNode::updateWorldTransform()
 //======================================================================================================================
 void SceneNode::moveLocalX(float distance)
 {
-	Vec3 x_axis = localTransform.rotation.getColumn(0);
-	getLocalTransform().origin += x_axis * distance;
+	Vec3 x_axis = localTransform.getRotation().getColumn(0);
+	getLocalTransform().getOrigin() += x_axis * distance;
 }
 
 void SceneNode::moveLocalY(float distance)
 {
-	Vec3 y_axis = localTransform.rotation.getColumn(1);
-	getLocalTransform().origin += y_axis * distance;
+	Vec3 y_axis = localTransform.getRotation().getColumn(1);
+	getLocalTransform().getOrigin() += y_axis * distance;
 }
 
 void SceneNode::moveLocalZ(float distance)
 {
-	Vec3 z_axis = localTransform.rotation.getColumn(2);
-	getLocalTransform().origin += z_axis * distance;
+	Vec3 z_axis = localTransform.getRotation().getColumn(2);
+	getLocalTransform().getOrigin() += z_axis * distance;
 }
 

+ 3 - 3
src/Scene/SceneNode.h

@@ -49,9 +49,9 @@ class SceneNode: private Object
 
 		/// @name Mess with the local transform
 		/// @{
-		void rotateLocalX(float angDegrees) {localTransform.rotation.rotateXAxis(angDegrees);}
-		void rotateLocalY(float angDegrees) {localTransform.rotation.rotateYAxis(angDegrees);}
-		void rotateLocalZ(float angDegrees) {localTransform.rotation.rotateZAxis(angDegrees);}
+		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);

+ 5 - 5
src/Scene/VisibilityTester.cpp

@@ -14,8 +14,8 @@
 //======================================================================================================================
 bool VisibilityTester::CmpDistanceFromOrigin::operator()(const RenderableNode* a, const RenderableNode* b) const
 {
-	return (a->getWorldTransform().origin - o).getLengthSquared() <
-	       (b->getWorldTransform().origin - o).getLengthSquared();
+	return (a->getWorldTransform().getOrigin() - o).getLengthSquared() <
+	       (b->getWorldTransform().getOrigin() - o).getLengthSquared();
 }
 
 
@@ -47,7 +47,7 @@ void VisibilityTester::test(Camera& cam)
 			{
 				PointLight* pointl = static_cast<PointLight*>(light);
 
-				Sphere sphere(pointl->getWorldTransform().origin, pointl->getRadius());
+				Sphere sphere(pointl->getWorldTransform().getOrigin(), pointl->getRadius());
 				if(cam.insideFrustum(sphere))
 				{
 					cam.getVisiblePointLights().push_back(pointl);
@@ -137,8 +137,8 @@ void VisibilityTester::getRenderableNodes(bool skipShadowless, Camera& cam)
 	// Sort the renderables from closest to the camera to the farthest
 	//
 	std::sort(cam.getVisibleMsRenderableNodes().begin(), cam.getVisibleMsRenderableNodes().end(),
-	          CmpDistanceFromOrigin(cam.getWorldTransform().origin));
+	          CmpDistanceFromOrigin(cam.getWorldTransform().getOrigin()));
 	std::sort(cam.getVisibleBsRenderableNodes().begin(), cam.getVisibleBsRenderableNodes().end(),
-	          CmpDistanceFromOrigin(cam.getWorldTransform().origin));
+	          CmpDistanceFromOrigin(cam.getWorldTransform().getOrigin()));
 }
 

+ 61 - 0
src/Util/HighRezTimer.cpp

@@ -0,0 +1,61 @@
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include "HighRezTimer.h"
+#include "Exception.h"
+
+
+//======================================================================================================================
+// Constructor                                                                                                         =
+//======================================================================================================================
+HighRezTimer::HighRezTimer():
+	startTime(0),
+	stopTime(0)
+{}
+
+
+//======================================================================================================================
+// start                                                                                                               =
+//======================================================================================================================
+void HighRezTimer::start()
+{
+	RASSERT_THROW_EXCEPTION(startTime != 0);
+	RASSERT_THROW_EXCEPTION(stopTime != 0);
+	startTime = getCrntTime();
+	stopTime = 0;
+}
+
+
+//======================================================================================================================
+// stop                                                                                                                =
+//======================================================================================================================
+void HighRezTimer::stop()
+{
+	RASSERT_THROW_EXCEPTION(startTime == 0);
+	RASSERT_THROW_EXCEPTION(stopTime != 0);
+	stopTime = getCrntTime();
+}
+
+
+//======================================================================================================================
+// getElapsedTime                                                                                                      =
+//======================================================================================================================
+uint HighRezTimer::getElapsedTime() const
+{
+	if(stopTime == 0)
+	{
+		return getCrntTime() - startTime;
+	}
+	else
+	{
+		return stopTime - startTime;
+	}
+}
+
+
+//======================================================================================================================
+// getCrntTime                                                                                                        =
+//======================================================================================================================
+uint HighRezTimer::getCrntTime()
+{
+	using namespace boost::posix_time;
+	return ptime(microsec_clock::local_time()).time_of_day().total_milliseconds();
+}

+ 31 - 0
src/Util/HighRezTimer.h

@@ -0,0 +1,31 @@
+#ifndef HIGH_REZ_TIMER_H
+#define HIGH_REZ_TIMER_H
+
+#include "StdTypes.h"
+
+
+/// High resoluton timer. All time in milliseconds
+class HighRezTimer
+{
+	public:
+		HighRezTimer();
+
+		/// Start the timer
+		void start();
+
+		/// Stop the timer
+		void stop();
+
+		/// Get the time elapsed between start and stop (if its stopped) or between start and the current time
+		uint getElapsedTime() const;
+
+		/// Get the current date's millisecond
+		static uint getCrntTime();
+
+	private:
+		uint startTime;
+		uint stopTime;
+};
+
+
+#endif

+ 23 - 0
unit-tests/Util/HighRezTimer.ut.cpp

@@ -0,0 +1,23 @@
+#include <gtest/gtest.h>
+#include "HighRezTimer.h"
+
+
+TEST(HighRezTimer, Test)
+{
+	HighRezTimer t;
+	t.start();
+	
+	sleep(2);
+	
+	EXPECT_EQ(t.getElapsedTime(), 2000);	
+	
+	sleep(1);
+	
+	EXPECT_EQ(t.getElapsedTime(), 3000);	
+	
+	sleep(1);
+	t.stop();
+	sleep(1);
+	
+	EXPECT_EQ(t.getElapsedTime(), 4000);	
+}

File diff suppressed because it is too large
+ 0 - 1
unit-tests/build/Makefile


Some files were not shown because too many files changed in this diff