Panagiotis Christopoulos Charitos 14 лет назад
Родитель
Сommit
8ab282602c

+ 6 - 3
src/CMakeLists.txt

@@ -2,13 +2,16 @@ PROJECT(ANKI_PROJ)
 
 INCLUDE_DIRECTORIES(${ANKI_PROJ_SOURCE_DIR})
 
-SET(ANKI_LIBS Core GfxApi Misc Renderer Scene Ui Collision Events Input Math 
-	Physics Resources Scripting Util)
+SET(ANKI_DIRS Scripting Misc Renderer Scene Ui Events 
+	Input Physics Resources GfxApi Collision Math Core Util)
 
-SUBDIRS(${ANKI_LIBS})
+SUBDIRS(${ANKI_DIRS})
 
 ADD_EXECUTABLE(anki Main.cpp)
 
+SET(ANKI_LIBS Scripting Core Renderer Scene Ui Events 
+	Input Physics Resources Misc GfxApi Collision Math Core Util)
+
 TARGET_LINK_LIBRARIES(anki ${ANKI_LIBS} BulletSoftBody BulletDynamics 
 	BulletCollision LinearMath GLEW GLU GL jpeg SDL png python2.6
 	boost_system boost_python boost_filesystem boost_thread freetype) 

+ 3 - 3
src/Main.cpp

@@ -20,12 +20,12 @@
 #include "Resources/LightRsrc.h"
 #include "Misc/Parser.h"
 #include "Scene/ParticleEmitter.h"
-#include "Physics/PhysCharacter.h"
+#include "Physics/Character.h"
 #include "Renderer/Renderer.h"
 #include "Renderer/RendererInitializer.h"
 #include "Renderer/MainRenderer.h"
-#include "Physics/PhysCharacter.h"
-#include "Physics/PhysRigidBody.h"
+#include "Physics/Character.h"
+#include "Physics/RigidBody.h"
 #include "Scripting/ScriptingEngine.h"
 #include "Core/StdinListener.h"
 #include "Scene/ModelNode.h"

+ 2 - 2
src/Math/Axisang.h

@@ -1,5 +1,5 @@
-#ifndef AXISANG_H
-#define AXISANG_H
+#ifndef M_AXISANG_H
+#define M_AXISANG_H
 
 #include "Common.h"
 

+ 17 - 12
src/Math/Axisang.inl.h

@@ -9,20 +9,20 @@ namespace M {
 //==============================================================================
 
 // Default
-inline Axisang::Axisang():
-	ang(0.0),
+inline Axisang::Axisang()
+:	ang(0.0),
 	axis(0.0)
 {}
 
-// Axisang
-inline Axisang::Axisang(const Axisang& b):
-	ang(b.ang),
+// Copy
+inline Axisang::Axisang(const Axisang& b)
+:	ang(b.ang),
 	axis(b.axis)
 {}
 
 // float, axis
-inline Axisang::Axisang(float rad, const Vec3& axis_):
-	ang(rad),
+inline Axisang::Axisang(float rad, const Vec3& axis_)
+:	ang(rad),
 	axis(axis_)
 {}
 
@@ -45,11 +45,15 @@ inline Axisang::Axisang(const Quat& q)
 // 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) &&
-		   (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);
 			ang = 0.0;
@@ -117,8 +121,9 @@ inline Axisang::Axisang(const Mat3& m3)
 		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)
 	{

+ 2 - 2
src/Math/Euler.h

@@ -1,5 +1,5 @@
-#ifndef EULER_H
-#define EULER_H
+#ifndef M_EULER_H
+#define M_EULER_H
 
 #include "Common.h"
 

+ 4 - 2
src/Math/Euler.inl.h

@@ -52,9 +52,11 @@ inline Euler::Euler(const Quat& q)
 	float sqx = q.x() * q.x();
 	float sqy = q.y() * q.y();
 	float sqz = q.z() * q.z();
-	y() = atan2(2.0 * q.y() * q.w() - 2.0 * q.x() * q.z(), 1.0 - 2.0 * sqy - 2.0 * sqz);
+	y() = atan2(2.0 * q.y() * q.w() - 2.0 * q.x() * q.z(),
+		1.0 - 2.0 * sqy - 2.0 * sqz);
 	z() = asin(2.0 * test);
-	x() = atan2(2.0 * q.x() * q.w() - 2.0 * q.y() * q.z(), 1.0 - 2.0 * sqx - 2.0 * sqz);
+	x() = atan2(2.0 * q.x() * q.w() - 2.0 * q.y() * q.z(),
+	    1.0 - 2.0 * sqx - 2.0 * sqz);
 }
 
 // mat3

+ 18 - 15
src/Math/Funcs.h

@@ -1,5 +1,5 @@
-#ifndef MATH_FUNCS_H
-#define MATH_FUNCS_H
+#ifndef M_FUNCS_H
+#define M_FUNCS_H
 
 #include "Common.h"
 
@@ -10,23 +10,26 @@ namespace M {
 const float PI = 3.14159265358979323846;
 const float EPSILON = 1.0e-6;
 
-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 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
+/// A fast func that given the angle in rads it returns the sin and cos
+void  sinCos(float rad, float& sin_, float& cos_);
+float sqrt(float f); ///< Square root
+float toRad(float degrees);
+float toDegrees(float rad);
+float sin(float rad);
+float cos(float rad);
+bool  isZero(float f); ///< 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
-                                   const Vec3& t1, const Mat3& r1, float s1, // in 1
-                                   Vec3& tf, Mat3& rf, float& sf); // out
+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
 
 /// 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
-                                   const Vec3& t1, const Mat3& r1, // in 1
-                                   Vec3& tf, Mat3& rf); // out
+void combineTransformations(
+	const Vec3& t0, const Mat3& r0, // in 0
+	const Vec3& t1, const Mat3& r1, // in 1
+	Vec3& tf, Mat3& rf); // out
 
 
 } // end namespace

+ 4 - 3
src/Math/Funcs.inl.h

@@ -54,8 +54,8 @@ inline bool isZero(float f)
 //  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)
+	const Vec3& t1, const Mat3& r1, float s1,
+	Vec3& tf, Mat3& rf, float& sf)
 {
 	tf = t1.getTransformed(t0, r0, s0);
 	rf = r0 * r1;
@@ -64,7 +64,8 @@ inline void combineTransformations(const Vec3& t0, const Mat3& r0, float s0,
 
 
 //  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);
 	rf = r0 * r1;

+ 9 - 5
src/Math/Mat3.h

@@ -1,5 +1,5 @@
-#ifndef MAT3_H
-#define MAT3_H
+#ifndef M_MAT3_H
+#define M_MAT3_H
 
 #include "Common.h"
 
@@ -7,7 +7,8 @@
 namespace M {
 
 
-/// Mainly used for rotations. It includes many helpful member functions. Its row major
+/// Mainly used for rotations. It includes many helpful member functions.
+/// Its row major
 class Mat3
 {
 	public:
@@ -15,7 +16,8 @@ class Mat3
 		/// @{
 		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 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); ///< Quat to Mat3. 12 muls, 12 adds
@@ -82,7 +84,9 @@ class Mat3
 		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
+		/// It rotates "this" in the axis defined by the rotation AND not the
+		/// world axis
+		void rotateXAxis(float rad);
 		void rotateYAxis(float rad);
 		void rotateZAxis(float rad);
 		void transpose();

+ 47 - 25
src/Math/Mat3.inl.h

@@ -30,7 +30,8 @@ inline Mat3::Mat3(float arr [])
 }
 
 // many floats
-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)
 {
 	SELF(0, 0) = m00;
 	SELF(0, 1) = m01;
@@ -55,7 +56,8 @@ inline Mat3::Mat3(const Mat3& b)
 // Quat
 inline Mat3::Mat3(const Quat& q)
 {
-	ASSERT(fabs(1.0 - q.getLength()) <= 0.002); // If length is > 1 + 0.002 or < 1 - 0.002 then not normalized quat
+	// If length is > 1 + 0.002 or < 1 - 0.002 then not normalized quat
+	ASSERT(fabs(1.0 - q.getLength()) <= 0.002);
 
 	float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 
@@ -133,7 +135,7 @@ inline Mat3::Mat3(const Axisang& axisang)
 
 
 //==============================================================================
-// Accessors                                                                    =
+// Accessors                                                                   =
 //==============================================================================
 
 inline float& Mat3::operator()(const uint i, const uint j)
@@ -217,15 +219,24 @@ inline Mat3& Mat3::operator-=(const Mat3& b)
 inline Mat3 Mat3::operator*(const Mat3& b) const
 {
 	Mat3 c;
-	c(0, 0) = SELF(0, 0) * b(0, 0) + SELF(0, 1) * b(1, 0) + SELF(0, 2) * b(2, 0);
-	c(0, 1) = SELF(0, 0) * b(0, 1) + SELF(0, 1) * b(1, 1) + SELF(0, 2) * b(2, 1);
-	c(0, 2) = SELF(0, 0) * b(0, 2) + SELF(0, 1) * b(1, 2) + SELF(0, 2) * b(2, 2);
-	c(1, 0) = SELF(1, 0) * b(0, 0) + SELF(1, 1) * b(1, 0) + SELF(1, 2) * b(2, 0);
-	c(1, 1) = SELF(1, 0) * b(0, 1) + SELF(1, 1) * b(1, 1) + SELF(1, 2) * b(2, 1);
-	c(1, 2) = SELF(1, 0) * b(0, 2) + SELF(1, 1) * b(1, 2) + SELF(1, 2) * b(2, 2);
-	c(2, 0) = SELF(2, 0) * b(0, 0) + SELF(2, 1) * b(1, 0) + SELF(2, 2) * b(2, 0);
-	c(2, 1) = SELF(2, 0) * b(0, 1) + SELF(2, 1) * b(1, 1) + SELF(2, 2) * b(2, 1);
-	c(2, 2) = SELF(2, 0) * b(0, 2) + SELF(2, 1) * b(1, 2) + SELF(2, 2) * b(2, 2);
+	c(0, 0) = SELF(0, 0) * b(0, 0) + SELF(0, 1) * b(1, 0) +
+		SELF(0, 2) * b(2, 0);
+	c(0, 1) = SELF(0, 0) * b(0, 1) + SELF(0, 1) * b(1, 1) +
+		SELF(0, 2) * b(2, 1);
+	c(0, 2) = SELF(0, 0) * b(0, 2) + SELF(0, 1) * b(1, 2) +
+		SELF(0, 2) * b(2, 2);
+	c(1, 0) = SELF(1, 0) * b(0, 0) + SELF(1, 1) * b(1, 0) +
+		SELF(1, 2) * b(2, 0);
+	c(1, 1) = SELF(1, 0) * b(0, 1) + SELF(1, 1) * b(1, 1) +
+		SELF(1, 2) * b(2, 1);
+	c(1, 2) = SELF(1, 0) * b(0, 2) + SELF(1, 1) * b(1, 2) +
+		SELF(1, 2) * b(2, 2);
+	c(2, 0) = SELF(2, 0) * b(0, 0) + SELF(2, 1) * b(1, 0) +
+		SELF(2, 2) * b(2, 0);
+	c(2, 1) = SELF(2, 0) * b(0, 1) + SELF(2, 1) * b(1, 1) +
+		SELF(2, 2) * b(2, 1);
+	c(2, 2) = SELF(2, 0) * b(0, 2) + SELF(2, 1) * b(1, 2) +
+		SELF(2, 2) * b(2, 2);
 	return c;
 }
 
@@ -584,9 +595,10 @@ inline void Mat3::setRotationZ(float rad)
 // rotateXAxis
 /*
  * the slow code is in comments and above the comments the optimized one
- * If we analize the mat3 we can extract the 3 unit vectors rotated by the mat3. The 3 rotated vectors are in mat's
- * columns. This means that: mat3.colomn[0] == i*mat3. rotateXAxis() rotates rad angle not from i vector (aka x axis)
- * but from the vector from colomn 0
+ * If we analize the mat3 we can extract the 3 unit vectors rotated by the mat3.
+ * The 3 rotated vectors are in mat's columns. This means that:
+ * mat3.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)
 {
@@ -602,7 +614,8 @@ inline void Mat3::rotateXAxis(float rad)
 	SELF(2, 2) = SELF(2, 2) * cosa - SELF(2, 1) * sina;
 
 	// zAxis.normalize();
-	float len = sqrt(SELF(0, 2) * SELF(0, 2) + SELF(1, 2) * SELF(1, 2) + SELF(2, 2) * SELF(2, 2));
+	float len = sqrt(SELF(0, 2) * SELF(0, 2) + SELF(1, 2) * SELF(1, 2) +
+		SELF(2, 2) * SELF(2, 2));
 	SELF(0, 2) /= len;
 	SELF(1, 2) /= len;
 	SELF(2, 2) /= len;
@@ -613,7 +626,8 @@ inline void Mat3::rotateXAxis(float rad)
 	SELF(2, 1) = SELF(0, 2) * SELF(1, 0) - SELF(1, 2) * SELF(0, 0);
 
 	// yAxis.normalize();
-	/*len = invSqrt(SELF(0, 1) * SELF(0, 1) + SELF(1, 1) * SELF(1, 1) + SELF(2, 1) * SELF(2, 1));
+	/*len = invSqrt(SELF(0, 1) * SELF(0, 1) + SELF(1, 1) * SELF(1, 1) +
+		SELF(2, 1) * SELF(2, 1));
 	SELF(0, 1) *= len;
 	SELF(1, 1) *= len;
 	SELF(2, 1) *= len;*/
@@ -637,7 +651,8 @@ inline void Mat3::rotateYAxis(float rad)
 	SELF(2, 2) = SELF(2, 2)*cosa + SELF(2, 0)*sina;
 
 	// zAxis.normalize();
-	float len = sqrt(SELF(0, 2) * SELF(0, 2) + SELF(1, 2) * SELF(1, 2) + SELF(2, 2) * SELF(2, 2));
+	float len = sqrt(SELF(0, 2) * SELF(0, 2) + SELF(1, 2) * SELF(1, 2) +
+		SELF(2, 2) * SELF(2, 2));
 	SELF(0, 2) /= len;
 	SELF(1, 2) /= len;
 	SELF(2, 2) /= len;
@@ -648,7 +663,8 @@ inline void Mat3::rotateYAxis(float rad)
 	SELF(2, 0) = SELF(1, 2) * SELF(0, 1) - SELF(0, 2) * SELF(1, 1);
 
 	// xAxis.normalize();
-	/*len = invSqrt(SELF(0, 0) * SELF(0, 0) + SELF(1, 0) * SELF(1, 0) + SELF(2, 0) * SELF(2, 0));
+	/*len = invSqrt(SELF(0, 0) * SELF(0, 0) + SELF(1, 0) * SELF(1, 0) +
+		SELF(2, 0) * SELF(2, 0));
 	SELF(0, 0) *= len;
 	SELF(1, 0) *= len;
 	SELF(2, 0) *= len;*/
@@ -672,7 +688,8 @@ inline void Mat3::rotateZAxis(float rad)
 	SELF(2, 0) = SELF(2, 0)*cosa + SELF(2, 1)*sina;
 
 	// xAxis.normalize();
-	float len = sqrt(SELF(0, 0) * SELF(0, 0) + SELF(1, 0) * SELF(1, 0) + SELF(2, 0) * SELF(2, 0));
+	float len = sqrt(SELF(0, 0) * SELF(0, 0) + SELF(1, 0) * SELF(1, 0) +
+		SELF(2, 0) * SELF(2, 0));
 	SELF(0, 0) /= len;
 	SELF(1, 0) /= len;
 	SELF(2, 0) /= len;
@@ -683,7 +700,8 @@ inline void Mat3::rotateZAxis(float rad)
 	SELF(2, 1) = SELF(0, 2) * SELF(1, 0) - SELF(1, 2) * SELF(0, 0);
 
 	// yAxis.normalize();
-	/*len = invSqrt(SELF(0, 1) * SELF(0, 1) + SELF(1, 1) * SELF(1, 1) + SELF(2, 1) * SELF(2, 1));
+	/*len = invSqrt(SELF(0, 1) * SELF(0, 1) + SELF(1, 1) * SELF(1, 1) +
+		SELF(2, 1) * SELF(2, 1));
 	SELF(0, 1) *= len;
 	SELF(1, 1) *= len;
 	SELF(2, 1) *= len;*/
@@ -750,9 +768,11 @@ inline void Mat3::reorthogonalize()
 // Determinant
 inline float Mat3::getDet() const
 {
-	/* accurate method:
-	return SELF(0, 0) * SELF(1, 1) * SELF(2, 2) + SELF(0, 1) * SELF(1, 2) * SELF(2, 0) + SELF(0, 2) * SELF(1, 0) * SELF(2, 1)
-	- SELF(0, 0) * SELF(1, 2) * SELF(2, 1) - SELF(0, 1) * SELF(1, 0) * SELF(2, 2) - SELF(0, 2) * SELF(1, 1) * SELF(2, 0);*/
+	/* Accurate method:
+	return SELF(0, 0) * SELF(1, 1) * SELF(2, 2) + SELF(0, 1) * SELF(1, 2) *
+		SELF(2, 0) + SELF(0, 2) * SELF(1, 0) * SELF(2, 1) -
+		SELF(0, 0) * SELF(1, 2) * SELF(2, 1) - SELF(0, 1) * SELF(1, 0) *
+		SELF(2, 2) - SELF(0, 2) * SELF(1, 1) * SELF(2, 0); */
 	return SELF(0, 0)*(SELF(1, 1) * SELF(2, 2) - SELF(1, 2) * SELF(2, 1)) -
 	SELF(0, 1)*(SELF(1, 0) * SELF(2, 2) - SELF(1, 2) * SELF(2, 0)) +
 	SELF(0, 2)*(SELF(0, 1) * SELF(2, 1) - SELF(1, 1) * SELF(2, 0));
@@ -768,7 +788,8 @@ inline Mat3 Mat3::getInverse() const
 	float cofactor0 = SELF(1, 1) * SELF(2, 2) - SELF(1, 2) * SELF(2, 1);
 	float cofactor3 = SELF(0, 2) * SELF(2, 1) - SELF(0, 1) * SELF(2, 2);
 	float cofactor6 = SELF(0, 1) * SELF(1, 2) - SELF(0, 2) * SELF(1, 1);
-	float det = SELF(0, 0) * cofactor0 + SELF(1, 0) * cofactor3 + SELF(2, 0) * cofactor6;
+	float det = SELF(0, 0) * cofactor0 + SELF(1, 0) * cofactor3 + SELF(2, 0) *
+		cofactor6;
 
 	ASSERT(!isZero(det)); // Cannot invert det == 0
 
@@ -830,4 +851,5 @@ inline std::ostream& operator<<(std::ostream& s, const Mat3& m)
 	return s;
 }
 
+
 } // end namespace

+ 0 - 222
src/Misc/map.cpp

@@ -1,222 +0,0 @@
-/*
-#include <limits>
-#include "map.h"
-#include "Resources/Mesh.h"
-#include "Scanner.h"
-#include "Parser.h"
-#include "Resource.h"
-#include "Scene/Camera.h"
-
-
-
-=======================================================================================================================================
-CreateRoot                                                                     =
-=======================================================================================================================================
-
-void octree_t::CreateRoot(const Vec<Mesh*>& meshes)
-{
-	DEBUG_ERR(root); // root should be NULL
-
-	/// get the root's aabb size
-	Vec3 min(numeric_limits<float>::max()), max(numeric_limits<float>::min());
-
-	for(uint m=0; m<meshes.size(); m++)
-	{
-		Mesh* cmesh = meshes[m];
-		for(uint v=0; v<cmesh->vertCoords.size(); v++)
-		{
-			const Vec3& vertCoords = cmesh->vertCoords[v];
-			for(int i=0; i<3; i++)
-			{
-				if(vertCoords[i] > max[i])
-					max[i] = vertCoords[i];
-				else if(vertCoords[i] < min[i])
-					min[i] = vertCoords[i];
-			} // end for 3 times
-		} // end for all mesh verts
-	} // end for all meshes
-
-
-	/// create a new node
-	node_t* node = new node_t;
-	node->bounding_box.min = min;
-	node->bounding_box.max = max;
-
-
-	/// 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
-
-	node->face_ids.resize(meshes.size());
-	node->vertIds.resize(meshes.size());
-	node->meshes.resize(meshes.size());
-
-	for(uint m=0; m<meshes.size(); m++)
-	{
-		Mesh* cmesh = meshes[m];
-
-		// first set the mesh
-		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][f] = f; // simple as taking a shit
-
-		// and last the verts
-	}
-
-	/// set root
-	root = node;
-}
-
-
-
-
-=======================================================================================================================================
-GetFacesNum                                                                    =
-=======================================================================================================================================
-
-uint octree_t::node_t::GetFacesNum() const
-{
-	int count = 0;
-	for(uint i=0; i<meshes.size(); i++)
-	{
-		count += meshes[i]->tris.size();
-	}
-	return count;
-}
-
-
-
-=======================================================================================================================================
-IsSubdivHeuristicMet                                                           =
-returns true when the used difined heuristic is met that sais that we can subdivide the node. Long story short it returns true when   =
-we can subdivide the node further                                              =
-=======================================================================================================================================
-
-bool octree_t::IsSubdivHeuristicMet(node_t* node) const
-{
-	if(node->GetFacesNum() < 100) return false;
-
-	return true;
-}
-
-
-
-
-=======================================================================================================================================
-SubdivideNode                                                                  =
-subdivides the node and creates max 8 children and then subdivides the children=
-=======================================================================================================================================
-
-void octree_t::SubdivideNode(node_t* node)
-{
-	if(!IsSubdivHeuristicMet(node)) return;
-
-	// subdivide the children
-	for(int i=0; i<8; i++)
-	{
-		if(node->childs[i] == NULL) continue;
-
-		SubdivideNode(node->childs[i]);
-	}
-}
-
-
-
-=======================================================================================================================================
-CreateTree                                                                     =
-=======================================================================================================================================
-
-void octree_t::CreateTree(const Vec<Mesh*>& meshes)
-{
-	CreateRoot(meshes);
-	SubdivideNode(root);
-}
-
-
-
-=======================================================================================================================================
-CheckNodeAgainstFrustum                                                        =
-the func checks the node and returns if its inside the cameras fruntum. It returns 0 if the cube is not inside, 1 if partialy         =
-inside and 2 if totaly inside                                                  =
-=======================================================================================================================================
-
-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 j=0; j<6; j++)
-		{
-			const plane_t& plane = cam.wspaceFrustumPlanes[j];
-
-			if(plane.Test(box_points[i]) < 0.0)
-			{
-				++points_outside_frustum_num;
-				continue;
-			}
-		}
-	}
-
-	if(points_outside_frustum_num == 8) return 0;
-	if(points_outside_frustum_num < 8) return 1;
-	return 2;
-}
-
-
-
-
-=======================================================================================================================================
-map                                                                            =
-=======================================================================================================================================
-
-
-
-
-=======================================================================================================================================
-load                                                                           =
-=======================================================================================================================================
-
-bool map_t::load(const char* filename)
-{
-	DEBUG_ERR(meshes.size() != 0); // meshes vector should be empty
-
-	Scanner scanner;
-	const Scanner::Token* token;
-	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)
-		{
-			RsrcPtr<Mesh> mesh = RsrcMngr::meshes.load(token->getValue().getString());
-			if(!mesh.get()) return false;
-
-			meshes.push_back(mesh);
-		}
-		// end of file
-		else if(token->getCode() == Scanner::TC_EOF)
-		{
-			break;
-		}
-		// other crap
-		else
-		{
-			PARSE_ERR_UNEXPECTED();
-			return false;
-		}
-
-	}while(true);
-
-	return true;
-}
-
-*/

+ 0 - 74
src/Misc/map.h

@@ -1,74 +0,0 @@
-/*
-#ifndef _MAP_H_
-#define _MAP_H_
-
-#include "collision.h"
-#include "Util/Vec.h"
-#include "Resources/RsrcPtr.h"
-
-class Mesh;
-class Camera;
-
-
-
-=======================================================================================================================================
-octree_t                                                                       =
-=======================================================================================================================================
-
-class octree_t
-{
-	public:
-		/// SceneNode class
-		// the class does not contain complicated functions. It mainly holds the data
-		class node_t
-		{
-			public:
-				node_t* childs[8];
-				aabb_t  bounding_box;
-
-				Vec<RsrcPtr<Mesh> >   meshes;
-				Vec< Vec<uint> > vertIds;
-				Vec< Vec<uint> > face_ids;
-
-				node_t() {}
-				~node_t() { ToDo: when class is finalized add code }
-
-				uint GetMeshesNum() const { return meshes.size(); }
-				uint GetFacesNum() const;
-		};
-		/// end SceneNode class
-
-	protected:
-		// funcs for the tree creation
-		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;
-
-	public:
-		node_t* root;
-
-		void CreateTree(const Vec<Mesh*>& meshes);
-};
-
-
-
-=======================================================================================================================================
-map_t                                                                          =
-=======================================================================================================================================
-
-class map_t
-{
-	public:
-		Vec<Mesh*> meshes;
-		octree_t             octree;
-
-		bool load(const char* filename);
-		void CreateOctree() { DEBUG_ERR(meshes.size() < 1); octree.CreateTree(meshes); };
-};
-
-
-#endif
-*/

+ 0 - 96
src/Misc/skybox.cpp

@@ -1,96 +0,0 @@
-#include "skybox.h"
-#include "Renderer/Renderer.h"
-#include "Math/Math.h"
-#include "Scene/Camera.h"
-#include "Scene/Scene.h"
-#include "Core/App.h"
-#include "Renderer/MainRenderer.h"
-
-
-/*static float coords [][4][3] =
-{
-	// front
-	{ { 1,  1, -1}, {-1,  1, -1}, {-1, -1, -1}, { 1, -1, -1} },
-	// back
-	{ {-1,  1,  1}, { 1,  1,  1}, { 1, -1,  1}, {-1, -1,  1} },
-	// left
-	{ {-1,  1, -1}, {-1,  1,  1}, {-1, -1,  1}, {-1, -1, -1} },
-	// right
-	{ { 1,  1,  1}, { 1,  1, -1}, { 1, -1, -1}, { 1, -1,  1} },
-	// up
-	{ { 1,  1,  1}, {-1,  1,  1}, {-1,  1, -1}, { 1,  1, -1} },
-	//
-	{ { 1, -1, -1}, {-1, -1, -1}, {-1, -1,  1}, { 1, -1,  1} }
-};*/
-
-
-
-/*
-=======================================================================================================================================
-load                                                                           =
-=======================================================================================================================================
-*/
-bool Skybox::load(const char* filenames[6])
-{
-	for(int i=0; i<6; i++)
-	{
-		textures[i].loadRsrc(filenames[i]);
-	}
-
-	noise.loadRsrc("gfx/noise2.tga");
-	noise->setRepeat(true);
-
-	shader.loadRsrc("shaders/ms_mp_skybox.glsl");
-
-	return true;
-}
-
-
-/*
-=======================================================================================================================================
-render                                                                         =
-=======================================================================================================================================
-*/
-void Skybox::Render(const Mat3& /*rotation*/)
-{
-	/*GlStateMachineSingleton::getInstance().enable(GL_DEPTH_TEST, false);
-	GlStateMachineSingleton::getInstance().enable(GL_BLEND, false);
-
-	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]);
-
-	// set the rotation matrix
-	Mat3 tmp(rotation);
-	tmp.rotateYAxis(rotation_ang);
-	app->getMainRenderer().loadMatrix(Mat4(tmp));
-
-	rotation_ang += 0.0001;
-	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} };
-
-	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]);
-		glEnd();
-	}
-
-	glPopMatrix();*/
-}

+ 0 - 36
src/Misc/skybox.h

@@ -1,36 +0,0 @@
-#ifndef _SKYBOX_H_
-#define _SKYBOX_H_
-
-#include "Resources/Texture.h"
-#include "Math/Math.h"
-#include "Resources/RsrcPtr.h"
-#include "Resources/ShaderProg.h"
-
-class Skybox
-{
-	protected:
-		enum textures_e
-		{
-			FRONT,
-			BACK,
-			LEFT,
-			RIGHT,
-			UP,
-			DOWN
-		};
-
-		RsrcPtr<Texture> textures[6];
-		RsrcPtr<Texture> noise;
-		RsrcPtr<ShaderProg> shader;
-
-		float rotation_ang;
-
-	public:
-		Skybox() { rotation_ang=0.0; }
-
-		bool load(const char* filenames[6]);
-		void Render(const Mat3& rotation);
-};
-
-
-#endif

+ 23 - 14
src/Physics/PhysCharacter.cpp → src/Physics/Character.cpp

@@ -3,10 +3,10 @@
 #include <btBulletDynamicsCommon.h>
 #include <BulletCollision/CollisionDispatch/btGhostObject.h>
 #include <BulletDynamics/Character/btKinematicCharacterController.h>
-#include "PhysCharacter.h"
-#include "PhysMasterContainer.h"
-#include "PhysMotionState.h"
-#include "PhysRigidBody.h"
+#include "Character.h"
+#include "MasterContainer.h"
+#include "MotionState.h"
+#include "RigidBody.h"
 
 
 namespace Phys {
@@ -29,32 +29,39 @@ inline Character::Initializer::Initializer():
 //==============================================================================
 // Contructor                                                                  =
 //==============================================================================
-Character::Character(MasterContainer& masterContainer_, const Initializer& init):
-	masterContainer(masterContainer_)
+Character::Character(MasterContainer& masterContainer_,
+	const Initializer& init)
+:	masterContainer(masterContainer_)
 {
 	ghostObject = new btPairCachingGhostObject();
 
 	motionState = new MotionState(init.startTrf, init.sceneNode);
 
-	btAxisSweep3* sweepBp = dynamic_cast<btAxisSweep3*>(masterContainer.broadphase);
+	btAxisSweep3* sweepBp =
+		dynamic_cast<btAxisSweep3*>(masterContainer.broadphase);
 	ASSERT(sweepBp != NULL);
 
 	ghostPairCallback = new btGhostPairCallback();
-	sweepBp->getOverlappingPairCache()->setInternalGhostPairCallback(ghostPairCallback);
-	//collisionShape = new btCapsuleShape(init.characterWidth, init.characterHeight);
-	convexShape = new btCylinderShape(btVector3(init.characterWidth, init.characterHeight, init.characterWidth));
+	sweepBp->getOverlappingPairCache()->setInternalGhostPairCallback(
+		ghostPairCallback);
+	//collisionShape = new btCapsuleShape(init.characterWidth,
+	//	init.characterHeight);
+	convexShape = new btCylinderShape(btVector3(init.characterWidth,
+		init.characterHeight, init.characterWidth));
 
 	ghostObject->setCollisionShape(convexShape);
 	//ghostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
 	ghostObject->setWorldTransform(toBt(init.startTrf));
 
-	character = new btKinematicCharacterController(ghostObject, convexShape, init.stepHeight);
+	character = new btKinematicCharacterController(ghostObject, convexShape,
+		init.stepHeight);
 
 	character->setJumpSpeed(init.jumpSpeed);
 	character->setMaxJumpHeight(init.maxJumpHeight);
 
 	// register
-	masterContainer.dynamicsWorld->addCollisionObject(ghostObject, btBroadphaseProxy::CharacterFilter,
+	masterContainer.dynamicsWorld->addCollisionObject(ghostObject,
+		btBroadphaseProxy::CharacterFilter,
 		btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
 
 	masterContainer.dynamicsWorld->addAction(character);
@@ -68,7 +75,8 @@ Character::Character(MasterContainer& masterContainer_, const Initializer& init)
 //==============================================================================
 Character::~Character()
 {
-	masterContainer.characters.erase(std::find(masterContainer.characters.begin(),
+	masterContainer.characters.erase(std::find(
+		masterContainer.characters.begin(),
 		masterContainer.characters.end(), this));
 	masterContainer.dynamicsWorld->removeAction(character);
 	masterContainer.dynamicsWorld->removeCollisionObject(ghostObject);
@@ -96,7 +104,8 @@ void Character::rotate(float angle)
 //==============================================================================
 void Character::moveForward(float distance)
 {
-	btVector3 forward = -ghostObject->getWorldTransform().getBasis().getColumn(2);
+	btVector3 forward =
+		-ghostObject->getWorldTransform().getBasis().getColumn(2);
 	character->setWalkDirection(forward * distance);
 }
 

+ 1 - 1
src/Physics/PhysCharacter.h → src/Physics/Character.h

@@ -1,7 +1,7 @@
 #ifndef PHYS_CHARACTER_H
 #define PHYS_CHARACTER_H
 
-#include "PhysMasterContainer.h"
+#include "MasterContainer.h"
 #include "Math/Math.h"
 #include "Core/Object.h"
 

+ 0 - 0
src/Physics/PhysConvertors.h → src/Physics/Convertors.h


+ 9 - 6
src/Physics/PhysMasterContainer.cpp → src/Physics/MasterContainer.cpp

@@ -1,7 +1,7 @@
 #include <BulletCollision/CollisionDispatch/btGhostObject.h>
-#include "PhysMasterContainer.h"
-#include "PhysCharacter.h"
-#include "PhysMotionState.h"
+#include "MasterContainer.h"
+#include "Character.h"
+#include "MotionState.h"
 
 
 namespace Phys {
@@ -15,9 +15,11 @@ MasterContainer::MasterContainer():
 {
 	collisionConfiguration = new btDefaultCollisionConfiguration();
 	dispatcher = new btCollisionDispatcher(collisionConfiguration);
-	broadphase = new btAxisSweep3(btVector3(-1000, -1000, -1000), btVector3(1000, 1000, 1000));
+	broadphase = new btAxisSweep3(btVector3(-1000, -1000, -1000),
+		btVector3(1000, 1000, 1000));
 	sol = new btSequentialImpulseConstraintSolver;
-	dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, sol, collisionConfiguration);
+	dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, sol,
+		collisionConfiguration);
 	dynamicsWorld->setGravity(btVector3(0,-10, 0));
 }
 
@@ -52,7 +54,8 @@ void MasterContainer::update(float prevUpdateTime, float crntTime)
 	// updateNonRigidBodiesMotionStates
 	for(uint i = 0; i < characters.size(); i++)
 	{
-		characters[i]->motionState->setWorldTransform(characters[i]->ghostObject->getWorldTransform());
+		characters[i]->motionState->setWorldTransform(
+			characters[i]->ghostObject->getWorldTransform());
 	}
 }
 

+ 7 - 4
src/Physics/PhysMasterContainer.h → src/Physics/MasterContainer.h

@@ -1,7 +1,7 @@
 #ifndef PHYS_MASTER_CONTAINER_H
 #define PHYS_MASTER_CONTAINER_H
 
-#include "PhysConvertors.h"
+#include "Convertors.h"
 #include "Util/Vec.h"
 #include <boost/scoped_ptr.hpp>
 #include <btBulletCollisionCommon.h>
@@ -48,12 +48,15 @@ class MasterContainer
 		void update(float prevUpdateTime, float crntTime);
 
 	private:
-		btDiscreteDynamicsWorld* dynamicsWorld; ///< Container for rigid bodied and constraints
+		/// Container for rigid bodied and constraints
+		btDiscreteDynamicsWorld* dynamicsWorld;
 		btDefaultCollisionConfiguration* collisionConfiguration;
-		btCollisionDispatcher* dispatcher; ///< Contains the algorithms of collision
+		/// Contains the algorithms of collision
+		btCollisionDispatcher* dispatcher;
 		btBroadphaseInterface* broadphase;
 		btSequentialImpulseConstraintSolver* sol;
-		boost::scoped_ptr<btIDebugDraw> debugDrawer; ///< Keep here for garbage collection
+		/// Keep here for garbage collection
+		boost::scoped_ptr<btIDebugDraw> debugDrawer;
 		float defaultContactProcessingThreshold;
 		Vec<Character*> characters;
 };

+ 3 - 2
src/Physics/PhysMotionState.h → src/Physics/MotionState.h

@@ -28,8 +28,9 @@ class MotionState: public btMotionState
 };
 
 
-inline MotionState::MotionState(const Transform& initialTransform, SceneNode* node_):
-	worldTransform(toBt(initialTransform)),
+inline MotionState::MotionState(const Transform& initialTransform,
+	SceneNode* node_)
+:	worldTransform(toBt(initialTransform)),
 	node(node_)
 {}
 

+ 0 - 0
src/Physics/PhysRagdoll.h → src/Physics/Ragdoll.h


+ 16 - 10
src/Physics/PhysRigidBody.cpp → src/Physics/RigidBody.cpp

@@ -1,7 +1,7 @@
-#include "PhysRigidBody.h"
-#include "PhysMasterContainer.h"
+#include "RigidBody.h"
+#include "MasterContainer.h"
 #include "Scene/Scene.h"
-#include "PhysMotionState.h"
+#include "MotionState.h"
 
 
 namespace Phys {
@@ -23,11 +23,14 @@ RigidBody::Initializer::Initializer():
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-RigidBody::RigidBody(MasterContainer& masterContainer_, const Initializer& init):
-  btRigidBody(btRigidBody::btRigidBodyConstructionInfo(0.0, NULL, NULL, btVector3(0.0, 0.0, 0.0))), // dummy init
-  masterContainer(masterContainer_)
+RigidBody::RigidBody(MasterContainer& masterContainer_,
+	const Initializer& init)
+:	btRigidBody(btRigidBody::btRigidBodyConstructionInfo(0.0, NULL, NULL,
+		btVector3(0.0, 0.0, 0.0))), // dummy init
+	masterContainer(masterContainer_)
 {
-	ASSERT(init.shape != NULL && init.shape->getShapeType() != INVALID_SHAPE_PROXYTYPE);
+	ASSERT(init.shape != NULL &&
+		init.shape->getShapeType() != INVALID_SHAPE_PROXYTYPE);
 
 	bool isDynamic = (init.mass != 0.0);
 
@@ -43,11 +46,13 @@ RigidBody::RigidBody(MasterContainer& masterContainer_, const Initializer& init)
 
 	motionState.reset(new MotionState(init.startTrf, init.sceneNode));
 
-	btRigidBody::btRigidBodyConstructionInfo cInfo(init.mass, motionState.get(), init.shape, localInertia);
+	btRigidBody::btRigidBodyConstructionInfo cInfo(init.mass,
+		motionState.get(), init.shape, localInertia);
 
 	setupRigidBody(cInfo);
 
-	setContactProcessingThreshold(masterContainer.defaultContactProcessingThreshold);
+	setContactProcessingThreshold(
+		masterContainer.defaultContactProcessingThreshold);
 
 	forceActivationState(ISLAND_SLEEPING);
 
@@ -58,7 +63,8 @@ RigidBody::RigidBody(MasterContainer& masterContainer_, const Initializer& init)
 	}
 	else
 	{
-		masterContainer.dynamicsWorld->addRigidBody(this, init.group, init.mask);
+		masterContainer.dynamicsWorld->addRigidBody(this, init.group,
+			init.mask);
 	}
 }
 

+ 2 - 1
src/Physics/PhysRigidBody.h → src/Physics/RigidBody.h

@@ -42,7 +42,8 @@ class RigidBody: public btRigidBody
 
 	private:
 		MasterContainer& masterContainer; ///< Know your father
-		boost::scoped_ptr<MotionState> motionState; ///< Keep it here for garbage collection
+		/// Keep it here for garbage collection
+		boost::scoped_ptr<MotionState> motionState;
 };
 
 

+ 1 - 1
src/Renderer/Drawers/PhyDbgDrawer.cpp

@@ -1,6 +1,6 @@
 #include "PhyDbgDrawer.h"
 #include "../MainRenderer.h"
-#include "Physics/PhysConvertors.h"
+#include "Physics/Convertors.h"
 #include "Core/Logger.h"
 #include "Core/Globals.h"
 

+ 1 - 1
src/Scene/Particle.cpp

@@ -1,5 +1,5 @@
 #include "Particle.h"
-#include "Physics/PhysRigidBody.h"
+#include "Physics/RigidBody.h"
 
 
 //==============================================================================

+ 1 - 1
src/Scene/ParticleEmitter.cpp

@@ -3,7 +3,7 @@
 #include <btBulletDynamicsCommon.h>
 #include "ParticleEmitter.h"
 #include "Particle.h"
-#include "Physics/PhysRigidBody.h"
+#include "Physics/RigidBody.h"
 #include "Core/App.h"
 #include "Scene.h"
 #include "Util/Util.h"

+ 1 - 1
src/Scene/Scene.h

@@ -2,7 +2,7 @@
 #define SCENE_H
 
 #include <boost/scoped_ptr.hpp>
-#include "Physics/PhysMasterContainer.h"
+#include "Physics/MasterContainer.h"
 #include "Util/Assert.h"
 #include "Util/Accessors.h"
 #include "VisibilityTester.h"