Kaynağa Gözat

- Removing Resource::unload
- Cleaning .cfg.py
- Making a few other classes derivatives of Object as well
- Fixing a warning in Mat3.inl.h and release
- Changing the default defined

Panagiotis Christopoulos Charitos 15 yıl önce
ebeveyn
işleme
1e0e8bd2f4

+ 1 - 8
build/debug/gen.cfg.py

@@ -5,17 +5,10 @@ includePaths.append("./")
 includePaths.extend(list(sourcePaths))
 includePaths.extend(["../../extern/include", "../../extern/include/bullet", "/usr/include/python2.6"])
 
-#precompiledHeaders = ["../../src/Util/Common.h", "/usr/include/boost/filesystem.hpp", "/usr/include/boost/ptr_container/ptr_vector.hpp"]
-precompiledHeaders = []
-
 executableName = "anki"
 
 compiler = "g++"
 
-defines__ = "-DDEBUG_ENABLED -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\""
-
-precompiledHeadersFlags = defines__ + " -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -O0 -g3 -pg"
-
-compilerFlags = precompiledHeadersFlags + " -fsingle-precision-constant"
+compilerFlags = "-DDEBUG_ENABLED=1 -DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -O0 -g3 -pg -fsingle-precision-constant"
 
 linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -lboost_system -lboost_python -lboost_filesystem -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -pg"

Dosya farkı çok büyük olduğundan ihmal edildi
+ 237 - 213
build/release/Makefile


+ 4 - 11
build/release/gen.cfg.py

@@ -1,21 +1,14 @@
-sourcePaths = ["../../src/Math/", "../../src/Util/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Scene/Controllers/", "../../src/Physics/", "../../src/Renderer/BufferObjects/", "../../src/Resources/Helpers/", "../../src/Resources/Core/"]
+sourcePaths = ["../../src/Math/", "../../src/Util/Tokenizer/", "../../src/Misc/", "../../src/", "../../src/Renderer/", "../../src/Scene/", "../../src/Ui/", "../../src/Resources/", "../../src/Util/", "../../src/Scene/Controllers/", "../../src/Physics/", "../../src/Renderer/BufferObjects/", "../../src/Resources/Helpers/", "../../src/Resources/Core/", "../../src/Core/", "../../src/Scripting/", "../../src/Scripting/Math", "../../src/Scripting/Util", "../../src/Scripting/Core", "../../src/Scripting/Scene"]
 
 includePaths = []
 includePaths.append("./")
 includePaths.extend(list(sourcePaths))
-includePaths.extend(["../../extern/include", "../../extern/include/bullet"])
-
-#precompiledHeaders = ["../../src/Util/Common.h", "/usr/include/boost/filesystem.hpp", "/usr/include/boost/ptr_container/ptr_vector.hpp"]
-precompiledHeaders = []
+includePaths.extend(["../../extern/include", "../../extern/include/bullet", "/usr/include/python2.6"])
 
 executableName = "anki"
 
 compiler = "g++"
 
-defines__ = "-DPLATFORM_LINUX -DREVISION=\\\"`svnversion -c ../..`\\\""
-
-precompiledHeadersFlags = defines__ + " -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -pipe -s -msse3 -O3 -mtune=core2 -ffast-math"
-
-compilerFlags = precompiledHeadersFlags + " -fsingle-precision-constant"
+compilerFlags = "-DDEBUG_ENABLED=0 -DPLATFORM_LINUX -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -s -msse4 -O3 -mtune=core2 -ffast-math -fsingle-precision-constant"
 
-linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -lboost_system -lboost_filesystem -Wl,-Bdynamic -lSDL -lGL -ljpeg -lpng -ltiff"
+linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -lboost_system -lboost_python -lboost_filesystem -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6"

+ 1 - 1
src/Core/App.cpp

@@ -205,7 +205,7 @@ void App::printAppInfo()
 {
 	stringstream msg;
 	msg << "App info: debugging ";
-	#if defined(DEBUG_ENABLED)
+	#if DEBUG_ENABLED == 1
 		msg << "on, ";
 	#else
 		msg << "off, ";

+ 21 - 7
src/Core/Common.h

@@ -3,7 +3,7 @@
 
 #include <iostream>
 
-// dummy define just to use namespace
+// dummy define just to use the namespace
 namespace boost
 {}
 
@@ -11,23 +11,37 @@ using namespace boost;
 using namespace std;
 
 
+//======================================================================================================================
+// Defines sanity checks                                                                                               =
+//======================================================================================================================
+#if !defined(DEBUG_ENABLED)
+	#error "DEBUG_ENABLED is not defined"
+#endif
+
+#if !defined(PLATFORM_LINUX)
+	#if !defined(PLATFORM_WIN)
+		#error "PLATFORM not defined"
+	#endif
+#endif
+
+
 //======================================================================================================================
 // misc types                                                                                                          =
 //======================================================================================================================
 #ifndef uchar
-typedef unsigned char uchar;
+	typedef unsigned char uchar;
 #endif
 
 #ifndef uint
-typedef unsigned int uint;
+	typedef unsigned int uint;
 #endif
 
 #ifndef ushort
-typedef unsigned short int ushort;
+	typedef unsigned short int ushort;
 #endif
 
 #ifndef ulong
-typedef unsigned long int ulong;
+	typedef unsigned long int ulong;
 #endif
 
 
@@ -70,7 +84,7 @@ extern bool msgGlError(const char* file, int line, const char* func);
 #define INFO(x) msgPrefix(MT_INFO, __FILE__, __LINE__, FUNCTION) << x << msgSuffix
 
 /// Reverse assertion
-#if defined(DEBUG_ENABLED)
+#if DEBUG_ENABLED == 1
 	#define DEBUG_ERR(x) \
 		if(x) \
 			msgPrefix(MT_DEBUG_ERR, __FILE__, __LINE__, FUNCTION) << #x << msgSuffix
@@ -80,7 +94,7 @@ extern bool msgGlError(const char* file, int line, const char* func);
 
 
 /// code that executes on debug
-#ifdef DEBUG_ENABLED
+#if DEBUG_ENABLED == 1
 	#define DEBUG_CODE if(true)
 #else
 	#define DEBUG_CODE if(false)

+ 1 - 2
src/Math/Mat3.inl.h

@@ -59,8 +59,7 @@ inline Mat3::Mat3(const Mat3& b)
 // constructor [quat]
 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()) > 0.002); // If length is > 1 + 0.002 or < 1 - 0.002 then not normalized quat
 
 	float xs, ys, zs, wx, wy, wz, xx, xy, xz, yy, yz, zz;
 

+ 3 - 3
src/Misc/memory.cpp

@@ -30,7 +30,7 @@ namespace mem {
 #endif
 
 
-#ifdef DEBUG_ENABLED
+#if DEBUG_ENABLED == 1
 	#define SANITY_CHECKS SanityChecks();
 	#define PRINT_CALL_INFO(x) { if(mem::print_call_info) INFO(x) }
 #else
@@ -286,7 +286,7 @@ init
 */
 static void init()
 {
-#ifdef DEBUG_ENABLED
+#if DEBUG_ENABLED == 1
 	memset(buffer, (char)0xCC, buffer_size);
 #endif
 
@@ -622,7 +622,7 @@ static void FreeBlock(mem_block_t* crnt)
 
 	free_size += crnt->size;
 
-#ifdef DEBUG_ENABLED
+#if DEBUG_ENABLED == 1
 	memset(crnt->addr, (char)0xCC, crnt->size);
 #endif
 

+ 6 - 4
src/Physics/MotionState.h

@@ -4,15 +4,16 @@
 #include <LinearMath/btMotionState.h>
 #include "Common.h"
 #include "SceneNode.h"
+#include "Object.h"
 
 
 /**
  * A custom motion state
  */
-class MotionState: public btMotionState
+class MotionState: public btMotionState, public Object
 {
 	public:
-		MotionState(const Transform& initialTransform, SceneNode* node_);
+		MotionState(const Transform& initialTransform, SceneNode* node_, Object* parent);
 		~MotionState() {}
 
 		/**
@@ -26,7 +27,7 @@ class MotionState: public btMotionState
 
 	private:
 		btTransform worldTransform;
-		SceneNode* node;
+		SceneNode* node; ///< Pointer cause it may be NULL
 };
 
 
@@ -34,7 +35,8 @@ class MotionState: public btMotionState
 // Inlines                                                                                                             =
 //======================================================================================================================
 
-inline MotionState::MotionState(const Transform& initialTransform, SceneNode* node_):
+inline MotionState::MotionState(const Transform& initialTransform, SceneNode* node_, Object* parent):
+	Object(parent),
 	worldTransform(toBt(initialTransform)),
 	node(node_)
 {}

+ 3 - 3
src/Physics/PhyCharacter.cpp

@@ -11,12 +11,13 @@
 //======================================================================================================================
 // Contructor                                                                                                          =
 //======================================================================================================================
-PhyCharacter::PhyCharacter(Physics& physics_, const Initializer& init):
+PhyCharacter::PhyCharacter(Physics& physics_, const Initializer& init, Object* parent):
+	Object(parent),
 	physics(physics_)
 {
 	ghostObject = new btPairCachingGhostObject();
 
-	motionState = new MotionState(init.startTrf, init.sceneNode);
+	motionState = new MotionState(init.startTrf, init.sceneNode, this);
 
 	btAxisSweep3* sweepBp = dynamic_cast<btAxisSweep3*>(physics.broadphase);
 	DEBUG_ERR(sweepBp == NULL);
@@ -58,7 +59,6 @@ PhyCharacter::~PhyCharacter()
 	delete convexShape;
 	delete ghostPairCallback;
 	delete ghostObject;
-	delete motionState;
 }
 
 

+ 6 - 5
src/Physics/PhyCharacter.h

@@ -1,9 +1,10 @@
-#ifndef PHYCHARACTER_H
-#define PHYCHARACTER_H
+#ifndef PHY_CHARACTER_H
+#define PHY_CHARACTER_H
 
 #include "Common.h"
 #include "Physics.h"
 #include "Math.h"
+#include "Object.h"
 
 
 class Physics;
@@ -17,7 +18,7 @@ class MotionState;
 /**
  * Its basically a wrapper around bullet character
  */
-class PhyCharacter
+class PhyCharacter: public Object
 {
 	friend class Physics;
 
@@ -32,13 +33,13 @@ class PhyCharacter
 			float stepHeight;
 			float jumpSpeed;
 			float maxJumpHeight;
-			SceneNode* sceneNode;
+			SceneNode* sceneNode; ///< For the MotionState
 			Transform startTrf;
 
 			Initializer();
 		};
 
-		PhyCharacter(Physics& physics_, const Initializer& init);
+		PhyCharacter(Physics& physics_, const Initializer& init, Object* parent = NULL);
 		~PhyCharacter();
 		void rotate(float angle);
 		void moveForward(float distance);

+ 7 - 0
src/Physics/Physics.h

@@ -38,6 +38,13 @@ class Physics: public Object
 		void update(float crntTime);
 		void debugDraw();
 
+		/**
+		 * @name Accessors
+		 */
+		/**@{*/
+		btDiscreteDynamicsWorld& getWorld() {return *dynamicsWorld;}
+		/**@}*/
+
 	private:
 		btDiscreteDynamicsWorld* dynamicsWorld;
 		btDefaultCollisionConfiguration* collisionConfiguration;

+ 5 - 3
src/Physics/RigidBody.cpp

@@ -7,8 +7,9 @@
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-RigidBody::RigidBody(Physics& physics_, const Initializer& init):
+RigidBody::RigidBody(Physics& physics_, const Initializer& init, Object* parent):
   btRigidBody(btRigidBody::btRigidBodyConstructionInfo(0.0, NULL, NULL, btVector3(0.0, 0.0, 0.0))), // dummy init
+  Object(parent),
   physics(physics_)
 {
 	DEBUG_ERR(init.shape==NULL || init.shape->getShapeType()==INVALID_SHAPE_PROXYTYPE);
@@ -21,9 +22,9 @@ RigidBody::RigidBody(Physics& physics_, const Initializer& init):
 	else
 		localInertia = btVector3(0.0, 0.0, 0.0);
 
-	motionState.reset(new MotionState(init.startTrf, init.sceneNode));
+	motionState = new MotionState(init.startTrf, init.sceneNode, this);
 
-	btRigidBody::btRigidBodyConstructionInfo cInfo(init.mass, motionState.get(), init.shape, localInertia);
+	btRigidBody::btRigidBodyConstructionInfo cInfo(init.mass, motionState, init.shape, localInertia);
 
 	setupRigidBody(cInfo);
 
@@ -31,6 +32,7 @@ RigidBody::RigidBody(Physics& physics_, const Initializer& init):
 
 	forceActivationState(ISLAND_SLEEPING);
 
+	// register
 	if(init.mask==-1 || init.group==-1)
 		physics.dynamicsWorld->addRigidBody(this);
 	else

+ 4 - 3
src/Physics/RigidBody.h

@@ -6,6 +6,7 @@
 #include <btBulletCollisionCommon.h>
 #include "Common.h"
 #include "Math.h"
+#include "Object.h"
 
 
 class SceneNode;
@@ -16,7 +17,7 @@ class Physics;
 /**
  * Wrapper for rigid body
  */
-class RigidBody: public btRigidBody
+class RigidBody: public btRigidBody, public Object
 {
 	public:
 		/**
@@ -37,7 +38,7 @@ class RigidBody: public btRigidBody
 		/**
 		 * Init and register
 		 */
-		RigidBody(Physics& physics, const Initializer& init);
+		RigidBody(Physics& physics, const Initializer& init, Object* parent = NULL);
 
 		/**
 		 * Unregister
@@ -46,7 +47,7 @@ class RigidBody: public btRigidBody
 
 	private:
 		Physics& physics; ///< Know your father
-		auto_ptr<MotionState> motionState; ///< Keep it here as well for garbage collection
+		MotionState* motionState; ///< Keep it here as well for garbage collection
 };
 
 

+ 2 - 2
src/Renderer/Renderer.h

@@ -58,13 +58,13 @@ class Renderer: public Object
 					friend class Renderer;
 					friend class Ms;
 
-					PROPERTY_R(bool, enabled, isEnabled)
-
 					public:
 						Ez(Renderer& r_): RenderingStage(r_) {}
+						bool isEnabled() const {return enabled;}
 
 					private:
 						Fbo fbo;
+						bool enabled;
 
 						void init();
 						void run();

+ 0 - 5
src/Resources/Core/Resource.h

@@ -48,11 +48,6 @@ class Resource
 		 * @return True on success
 		 */
 		virtual bool load(const char* filename) = 0;
-
-		/**
-		 * Special unload func for stuff that the destructor cannot cleanup (eg OpenGL stuff).
-		 */
-		virtual void unload() {}
 };
 
 

+ 0 - 1
src/Resources/Core/RsrcContainer.inl.h

@@ -124,7 +124,6 @@ void RsrcContainer<Type>::unload(Type* x)
 	// if no other users then call unload and update the container
 	if(del_->referenceCounter == 0)
 	{
-		del_->unload();
 		delete del_;
 		BaseClass::erase(it);
 	}

+ 7 - 1
src/Resources/Extension.cpp

@@ -2,6 +2,9 @@
 #include "Extension.h"
 
 
+//======================================================================================================================
+// load                                                                                                                =
+//======================================================================================================================
 bool Extension::load(const char* filename)
 {
 	// load libary
@@ -24,7 +27,10 @@ bool Extension::load(const char* filename)
 }
 
 
-void Extension::unload()
+//======================================================================================================================
+// Destructor                                                                                                          =
+//======================================================================================================================
+Extension::~Extension()
 {
 	DEBUG_ERR(libHandle==NULL || foobarPtr==NULL);
 	dlclose(libHandle);

+ 1 - 2
src/Resources/Extension.h

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

+ 0 - 1
src/Resources/LightProps.h

@@ -25,7 +25,6 @@ class LightProps: public Resource
 		LightProps();
 		virtual ~LightProps() {}
 		bool load(const char* filename);
-		void unload() {}
 		const Texture* getTexture() const;
 
 	private:

+ 0 - 1
src/Resources/Material.h

@@ -139,7 +139,6 @@ class Material: public Resource
 	public:
 		Material();
 		bool load(const char* filename);
-		void unload() {};
 };
 
 

+ 0 - 9
src/Resources/Mesh.cpp

@@ -190,15 +190,6 @@ bool Mesh::load(const char* filename)
 }
 
 
-//======================================================================================================================
-// unload                                                                                                              =
-//======================================================================================================================
-void Mesh::unload()
-{
-	// ToDo: add when finalized
-}
-
-
 //======================================================================================================================
 // createFaceNormals                                                                                                   =
 //======================================================================================================================

+ 0 - 1
src/Resources/Mesh.h

@@ -70,7 +70,6 @@ class Mesh: public Resource
 		Mesh();
 		~Mesh() {}
 		bool load(const char* filename);
-		void unload();
 
 		/**
 		 * The mesh is renderable when the material is loaded

+ 0 - 1
src/Resources/ParticleEmitterProps.h

@@ -68,7 +68,6 @@ class ParticleEmitterProps: public ParticleEmitterPropsStruct, public Resource
 		~ParticleEmitterProps() {}
 
 		bool load(const char* filename);
-		void unload() {} ///< Do nothing
 };
 
 

+ 0 - 1
src/Resources/Path.h

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

+ 0 - 1
src/Resources/Script.h

@@ -13,7 +13,6 @@ class Script: public Resource
 	public:
 		Script();
 		~Script() {}
-
 		bool load(const char* filename);
 
 	private:

+ 1 - 6
src/Resources/ShaderProg.h

@@ -90,7 +90,7 @@ class ShaderProg: public Resource
 	//====================================================================================================================
 	public:
 		ShaderProg();
-		~ShaderProg() {}
+		~ShaderProg() {/** @todo add code */}
 
 		/**
 		 * Accessor to glId
@@ -186,11 +186,6 @@ class ShaderProg: public Resource
 		 * Resource load
 		 */
 		bool load(const char* filename);
-
-		/**
-		 * Free GL program
-		 */
-		void unload() { /** @todo add code */ }
 }; 
 
 

+ 0 - 1
src/Resources/SkelAnim.h

@@ -39,7 +39,6 @@ class SkelAnim: public Resource
 		SkelAnim();
 		~SkelAnim() {}
 		bool load(const char* filename);
-		void unload() {}
 };
 
 

+ 0 - 1
src/Resources/Skeleton.h

@@ -51,7 +51,6 @@ class Skeleton: public Resource
 		 Skeleton();
 		~Skeleton() {}
 		bool load(const char* filename);
-		void unload() {}
 };
 
 

+ 10 - 10
src/Resources/Texture.cpp

@@ -26,6 +26,16 @@ Texture::Texture():
 {}
 
 
+//======================================================================================================================
+// Destructor                                                                                                          =
+//======================================================================================================================
+Texture::~Texture()
+{
+	if(isLoaded())
+		glDeleteTextures(1, &glId);
+}
+
+
 //======================================================================================================================
 // load                                                                                                                =
 //======================================================================================================================
@@ -141,16 +151,6 @@ bool Texture::createEmpty2DMsaa(int samplesNum, int internalFormat, int width_,
 }
 
 
-//======================================================================================================================
-// unload                                                                                                              =
-//======================================================================================================================
-void Texture::unload()
-{
-	if(isLoaded())
-		glDeleteTextures(1, &glId);
-}
-
-
 //======================================================================================================================
 // bind                                                                                                                =
 //======================================================================================================================

+ 1 - 2
src/Resources/Texture.h

@@ -21,7 +21,7 @@ class Texture: public Resource
 
 	public:
 		 Texture();
-		~Texture() {}
+		~Texture();
 
 		uint getGlId() const;
 
@@ -30,7 +30,6 @@ class Texture: public Resource
 		 */
 		/**@{*/
 		bool load(const char* filename);
-		void unload();
 		bool createEmpty2D(float width, float height, int internalFormat, int format, uint type_);
 		bool createEmpty2DMsaa(int samplesNum, int internalFormat, int width_, int height_, bool mimapping);
 		/**@}*/

+ 2 - 14
src/Util/Object.h

@@ -22,8 +22,8 @@ class Object
 		 * @name Accessors
 		 */
 		/**@{*/
-		const Object* getObjParent() const;
-		const Vec<Object*> getObjChilds() const; ///< Get the childs Vec
+		const Object* getObjParent() const {return objParent;}
+		const Vec<Object*> getObjChilds() const {return objChilds;} ///< Get the childs Vec
 		/**@}*/
 
 	private:
@@ -55,18 +55,6 @@ inline Object::~Object()
 }
 
 
-inline const Object* Object::getObjParent() const
-{
-	return objParent;
-}
-
-
-inline const Vec<Object*> Object::getObjChilds() const
-{
-	return objChilds;
-}
-
-
 inline void Object::addChild(Object* child)
 {
 	DEBUG_ERR(child == NULL);

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor