Browse Source

Refactoring

Panagiotis Christopoulos Charitos 15 years ago
parent
commit
3cffe4451f
6 changed files with 428 additions and 622 deletions
  1. 342 552
      build/debug/Makefile
  2. 12 1
      src/Scene/Light.h
  3. 3 3
      src/Scene/SceneNode.cpp
  4. 4 10
      src/Util/CharPtrHashMap.h
  5. 66 0
      src/Util/Object.cpp
  6. 1 56
      src/Util/Object.h

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


+ 12 - 1
src/Scene/Light.h

@@ -37,6 +37,17 @@ class Light: public SceneNode
 
 	PROPERTY_R(LightType, type, getType) ///< Light type
 
+	/// @name Copies of some of the resource properties
+	/// @{
+	PROPERTY_RW(Vec3, diffuseCol, setDiffuseColor, getDiffuseColor)
+	PROPERTY_RW(Vec3, specularCol, setSpecularColor, getSpecularColor)
+	PROPERTY_RW(float, radius, setRadius, getRadius)
+	PROPERTY_RW(bool, castsShadow_, setCastsShadow, castsShadow)
+	PROPERTY_RW(float, distance, setDistance, getDistance)
+	PROPERTY_RW(float, fovX, setFovX, getFovX)
+	PROPERTY_RW(float, fovY, setFovY, getFovY)
+	/// @}
+
 	public:
 		RsrcPtr<LightData> lightData;
 	
@@ -44,7 +55,7 @@ class Light: public SceneNode
 		void render();
 
 	private:
-
+		Camera* camera;
 };
 
 

+ 3 - 3
src/Scene/SceneNode.cpp

@@ -123,15 +123,15 @@ void SceneNode::addChild(SceneNode* node)
 //======================================================================================================================
 // removeChild                                                                                                         =
 //======================================================================================================================
-void SceneNode::removeChild(SceneNode* node)
+void SceneNode::removeChild(SceneNode* child)
 {
-	Vec<SceneNode*>::iterator it = find(childs.begin(), childs.end(), node);
+	Vec<SceneNode*>::iterator it = std::find(childs.begin(), childs.end(), child);
 	if(it == childs.end())
 	{
 		ERROR("Child not found");
 		return;
 	}
 
-	node->parent = NULL;
+	child->parent = NULL;
 	childs.erase(it);
 }

+ 4 - 10
src/Util/CharPtrHashMap.h

@@ -6,9 +6,7 @@
 #include "Common.h"
 
 
-/**
- * The hash function
- */
+/// The hash function
 struct CreateCharPtrHashMapKey
 {
   size_t operator()(const char* str) const
@@ -23,9 +21,7 @@ struct CreateCharPtrHashMapKey
 };
 
 
-/**
- * The collision evaluation function
- */
+/// The collision evaluation function
 struct CompareCharPtrHashMapKeys
 {
   bool operator()(const char* a, const char* b) const
@@ -35,10 +31,8 @@ struct CompareCharPtrHashMapKeys
 };
 
 
-/**
- * The hash map that has as key an old school C string. When inserting the char MUST NOT point to a temporary or the
- * evaluation function will fail.
- */
+/// The hash map that has as key an old school C string. When inserting the char MUST NOT point to a temporary or the
+/// evaluation function will fail.
 template<typename Type>
 class CharPtrHashMap: public unordered_map<const char*, Type, CreateCharPtrHashMapKey, CompareCharPtrHashMapKeys>
 {};

+ 66 - 0
src/Util/Object.cpp

@@ -0,0 +1,66 @@
+#include <algorithm>
+#include "Object.h"
+
+
+//======================================================================================================================
+// Constructor                                                                                                         =
+//======================================================================================================================
+Object::Object(Object* parent):
+	objParent(NULL)
+{
+	if(parent != NULL)
+	{
+		parent->addChild(this);
+	}
+}
+
+
+//======================================================================================================================
+// Destructor                                                                                                          =
+//======================================================================================================================
+Object::~Object()
+{
+	if(objParent != NULL)
+	{
+		objParent->removeChild(this);
+	}
+
+	// delete all children
+	for(Vec<Object*>::reverse_iterator it=objChilds.rbegin(); it!=objChilds.rend(); it++)
+	{
+		delete *it;
+	}
+}
+
+
+//======================================================================================================================
+// addChild                                                                                                            =
+//======================================================================================================================
+void Object::addChild(Object* child)
+{
+	DEBUG_ERR(child == NULL);
+	DEBUG_ERR(child->objParent != NULL); // Child already has parent
+
+	child->objParent = this;
+	objChilds.push_back(child);
+}
+
+
+//======================================================================================================================
+// removeChild                                                                                                         =
+//======================================================================================================================
+void Object::removeChild(Object* child)
+{
+	DEBUG_ERR(child == NULL);
+
+	Vec<Object*>::iterator it = std::find(objChilds.begin(), objChilds.end(), child);
+
+	if(it == objChilds.end())
+	{
+		ERROR("Internal error");
+		return;
+	}
+
+	objChilds.erase(it);
+	child->objParent = NULL;
+}

+ 1 - 56
src/Util/Object.h

@@ -10,6 +10,7 @@
 class Object
 {
 	public:
+		/// Calls addChild if parent is not NULL
 		Object(Object* parent = NULL);
 
 		/// Delete childs from the last entered to the first and update parent
@@ -24,60 +25,4 @@ class Object
 };
 
 
-//======================================================================================================================
-// Inlines                                                                                                             =
-//======================================================================================================================
-
-inline Object::Object(Object* parent):
-	objParent(NULL)
-{
-	if(parent != NULL)
-	{
-		parent->addChild(this);
-	}
-}
-
-
-inline Object::~Object()
-{
-	if(objParent != NULL)
-	{
-		objParent->removeChild(this);
-	}
-
-	// delete all children
-	for(Vec<Object*>::reverse_iterator it=objChilds.rbegin(); it!=objChilds.rend(); it++)
-	{
-		delete *it;
-	}
-}
-
-
-inline void Object::addChild(Object* child)
-{
-	DEBUG_ERR(child == NULL);
-	DEBUG_ERR(child->objParent != NULL); // Child already has parent
-
-	child->objParent = this;
-	objChilds.push_back(child);
-}
-
-
-inline void Object::removeChild(Object* child)
-{
-	DEBUG_ERR(child == NULL);
-
-	Vec<Object*>::iterator it = find(objChilds.begin(), objChilds.end(), child);
-
-	if(it == objChilds.end())
-	{
-		ERROR("Internal error");
-		return;
-	}
-
-	objChilds.erase(it);
-	child->objParent = NULL;
-}
-
-
 #endif

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