Index: orxonox/trunk/src/lib/collision_detection/cd_engine.cc
===================================================================
--- orxonox/trunk/src/lib/collision_detection/cd_engine.cc	(revision 4923)
+++ orxonox/trunk/src/lib/collision_detection/cd_engine.cc	(revision 4924)
@@ -71,5 +71,7 @@
 
 
-
+/**
+ *  this checks the collisions with the objects
+ */
 void CDEngine::checkCollisionObjects()
 {
@@ -96,4 +98,7 @@
 
 
+/**
+ *  this checks the collisions with the ground
+ */
 void CDEngine::checkCollisionGround()
 {
@@ -103,4 +108,9 @@
 
 
+/**
+ *  this draws the bounding volume tree
+ * @param depth until which depth to draw the tree
+ * @param drawMode mod which states how to draw it
+ */
 void CDEngine::drawBV(int depth, int drawMode) const
 {
@@ -116,11 +126,10 @@
   }
   delete iterator;
-  //model->draw();
 }
 
 
-
-
-
+/**
+ * some debug output on the class
+ */
 void CDEngine::debug()
 {
@@ -133,4 +142,8 @@
 }
 
+
+/**
+ * this spawns a tree for debug purposes only
+ */
 void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices)
 {
@@ -140,4 +153,8 @@
 }
 
+
+/**
+ * this draws the debug spawn tree
+ */
 void CDEngine::debugDraw(int depth, int drawMode)
 {
Index: orxonox/trunk/src/lib/collision_detection/cd_engine.h
===================================================================
--- orxonox/trunk/src/lib/collision_detection/cd_engine.h	(revision 4923)
+++ orxonox/trunk/src/lib/collision_detection/cd_engine.h	(revision 4924)
@@ -55,6 +55,5 @@
 
   void debug();
-  void debugSpawnTree(int depth, sVec3D* vertices, int numVertices);
-  void debugDraw(int depth, int drawMode);
+
 
  private:
@@ -66,4 +65,7 @@
   void checkCollisionObjects();
   void checkCollisionGround();
+
+  void debugSpawnTree(int depth, sVec3D* vertices, int numVertices);
+  void debugDraw(int depth, int drawMode);
 
 
Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 4923)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 4924)
@@ -9,5 +9,5 @@
    any later version.
 
-   ### File Specific:
+### File Specific:
    main-programmer: Patrick Boenzli
    co-programmer: ...
@@ -19,6 +19,8 @@
 
 #include "quadtree_node.h"
+#include "vector.h"
+
 #include "material.h"
-#include "vector.h"
+
 
 using namespace std;
@@ -27,53 +29,46 @@
 /**
  *  standard constructor
-   @todo this constructor is not jet implemented - do it
-*/
+ */
 Quadtree::Quadtree (modelInfo* pModelInfo, const int treeDepth)
 {
-   this->setClassID(CL_QUADTREE, "Quadtree");
-   this->pModelInfo = pModelInfo;
-   this->treeDepth = treeDepth;
+  this->setClassID(CL_QUADTREE, "Quadtree");
+  this->pModelInfo = pModelInfo;
+  this->treeDepth = treeDepth;
 
-   /* initialize the materials for debug draw */
-   this->materials = new Material*[4];
-   for(int i = 0; i < 4; ++i)
-   {
-     materials[i] = new Material();
-     materials[i]->setIllum(3);
-   }
-   materials[0]->setAmbient(0.0, 0.3, 0.0);
-   materials[1]->setAmbient(0.4, 0.0, 0.2);
-   materials[2]->setAmbient(1.0, 0.0, 0.0);
-   materials[3]->setAmbient(5.0, 3.0, 1.0);
+  /* initialize the materials for debug draw */
+  this->materials = new Material*[4];
+  for(int i = 0; i < 4; ++i)
+  {
+    materials[i] = new Material();
+    materials[i]->setIllum(3);
+  }
+  materials[0]->setAmbient(0.0, 0.3, 0.0);
+  materials[1]->setAmbient(0.4, 0.0, 0.2);
+  materials[2]->setAmbient(1.0, 0.0, 0.0);
+  materials[3]->setAmbient(5.0, 3.0, 1.0);
 
-   /* build the tree */
-   this->rootNode = new QuadtreeNode(this->pModelInfo, this, this->treeDepth);
+  /* build the tree */
+  this->rootNode = new QuadtreeNode(this->pModelInfo, this, this->treeDepth);
 
-   /* make an array with access to the leafs of the Quad-Tree */
-   this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)];
-   int* index = new int; *index = 0;
-   for(int i = 0; i < (int)pow(2, treeDepth); ++i)
-   {
-     printf("============================\n");
-     this->rootNode->buildHashTable(this->nodes, index);
-   }
-   this->sortHashTable(this->nodes);
-   this->revertHashTable(this->nodes);
+  /* make an array with access to the leafs of the Quad-Tree */
+  this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)];
+  int* index = new int; *index = 0;
+  for(int i = 0; i < (int)pow(2, treeDepth); ++i)
+  {
+    this->rootNode->buildHashTable(this->nodes, index);
+  }
+  /* sort and revert the hash table to fit the right position */
+  this->sortHashTable(this->nodes);
+  this->revertHashTable(this->nodes);
 
-   for(int i = 0; i < (int)pow(4, treeDepth); ++i)
-   {
-     printf("node %i, %f, %f \n", i, this->nodes[i]->getDimension()->getCenter()->x, this->nodes[i]->getDimension()->getCenter()->z);
-   }
-
-   this->quadLength = this->nodes[0]->getDimension()->getAxis() * 2.0f;
-   Rectangle* r = this->rootNode->getDimension();
-
-   Vector* offset = new Vector();
-   float xOff = r->getCenter()->x - r->getAxis();
-   float yOff = r->getCenter()->z - r->getAxis();
-   this->offset->x = xOff;
-   this->offset->z = yOff;
-
-   this->maxIndex = (int)pow(2, this->treeDepth);
+  /* define some important and often used variables */
+  this->quadLength = this->nodes[0]->getDimension()->getAxis() * 2.0f;
+  Rectangle* r = this->rootNode->getDimension();
+  Vector* offset = new Vector();
+  float xOff = r->getCenter()->x - r->getAxis();
+  float yOff = r->getCenter()->z - r->getAxis();
+  this->offset->x = xOff;
+  this->offset->z = yOff;
+  this->maxIndex = (int)pow(2, this->treeDepth);
 }
 
@@ -81,6 +76,5 @@
 /**
  *  standard deconstructor
-
-*/
+ */
 Quadtree::~Quadtree ()
 {
@@ -93,6 +87,6 @@
 
 /**
-  \brief this function rotates the array and mirrors it in the middle
-  \param nodes: the nodes to translate
+ *  this function rotates the array and mirrors it in the middle
+ * @param nodes: the nodes to translate
 
   since the original matrix is counted from the right upper edge to the right lower one, we have to reorganize the elements
@@ -123,8 +117,8 @@
 }
 
+
 /**
-  \brief sorts the hash table using their positions
-  \param nodes the nodes to use
-
+ *  sorts the hash table using their positions
+ * @param nodes the nodes to use
  */
 void Quadtree::sortHashTable(QuadtreeNode** nodes)
@@ -158,7 +152,7 @@
 
 /**
-  \brief maps a position to a quadtree
-  \param position the position so look for
-  \return the quadtree
+ *  maps a position to a quadtree
+ * @param position the position so look for
+ * @return the quadtree
 
   this function will return the quadtree that contains the position
Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h	(revision 4923)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h	(revision 4924)
@@ -1,7 +1,9 @@
 /*!
     \file quadtree.h
-  *  Definition of a spatial data separation using quadtree
+ *  Definition of a spatial data separation using quadtree
 
-*/
+  This is the top element of the quadtree framework. A Quadtree is build of QuadtreeNodes, which are again separated
+  into QuadtreeNodes until a certain depth is reached
+ */
 
 #ifndef _QUADTREE_H
@@ -20,12 +22,14 @@
 class Quadtree : public BaseObject {
 
- public:
-  Quadtree(modelInfo* pModelInfo, const int treeDepth);
-  virtual ~Quadtree();
 
-  QuadtreeNode* getQuadtreeFromPosition(const Vector& position);
+  public:
+    Quadtree(modelInfo* pModelInfo, const int treeDepth);
+    virtual ~Quadtree();
 
-  void drawTree() const;
-  inline Material* getMaterial(int indexNode) const { return this->materials[indexNode % 4]; }
+    QuadtreeNode* getQuadtreeFromPosition(const Vector& position);
+
+    void drawTree() const;
+    inline Material* getMaterial(int indexNode) const { return this->materials[indexNode % 4]; }
+
 
   private:
@@ -33,16 +37,16 @@
     void sortHashTable(QuadtreeNode** nodes);
 
- private:
-   QuadtreeNode*                   rootNode;              //!< reference to the root node of the quadtree
-   modelInfo*                      pModelInfo;            //!< reference to the modelInfo of the object
-   int                             treeDepth;             //!< depth of the tree
 
-   float                           quadLength;            //!< length of the leaf quadtree nodes
-   Vector*                         offset;                //!< vector to the left lower corner of the root quadtree node
-   int                             maxIndex;              //!< maximal index for the nodes array
+  private:
+    QuadtreeNode*                   rootNode;              //!< reference to the root node of the quadtree
+    QuadtreeNode**                  nodes;                 //!< reference to all quadtree nodes (only leafs of the quad tree)
+    modelInfo*                      pModelInfo;            //!< reference to the modelInfo of the object
+    int                             treeDepth;             //!< depth of the tree
 
-   Material**                      materials;             //!< materials for debug drawing purposes
+    float                           quadLength;            //!< length of the leaf quadtree nodes
+    Vector*                         offset;                //!< vector to the left lower corner of the root quadtree node
+    int                             maxIndex;              //!< maximal index for the nodes array
 
-   QuadtreeNode**                  nodes;                 //!< reference to all quadtree nodes (only leafs of the quad tree)
+    Material**                      materials;             //!< materials for debug drawing purposes
 };
 
Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 4923)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 4924)
@@ -9,5 +9,5 @@
    any later version.
 
-   ### File Specific:
+### File Specific:
    main-programmer: Patrick Boenzli
    co-programmer: ...
@@ -29,5 +29,5 @@
 /**
  *  standard constructor
-*/
+ */
 QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles,
                             const float* pVertices, int numVertices,
@@ -36,12 +36,11 @@
                            )
 {
+  /* save all important variables localy */
   this->pTriangles = triangles;
   this->numTriangles = numTriangles;
   this->pVertices = pVertices;
   this->numVertices = numVertices;
-
   this->quadtree = quadtree;
   this->parent = parent;
-
   this->pDimension = rect;
   this->treeDepth = treeDepth;
@@ -49,5 +48,4 @@
   this->indexNode = index;
 
-
   /* debug output */
   for( int i = 0; i < this->treeDepth; ++i)
@@ -69,6 +67,8 @@
 QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth)
 {
+  /* save all important variables localy */
   this->pModelInfo = pModelInfo;
   this->quadtree = quadtree;
+  this->maxDepth = maxDepth;
 
   /* create an array of triangle references */
@@ -80,8 +80,4 @@
     this->pTriangles[i] = &this->pModelInfo->pTriangles[i];
 
-  this->treeDepth = 0;
-  this->maxDepth = maxDepth;
-  this->indexNode = 0;
-
   /* debug output */
   for( int i = 0; i < this->treeDepth; ++i)
@@ -89,5 +85,9 @@
   PRINT(3)(" | +-| (Event) Building Node Nr. %i Depth: %i/%i, pointer: %p\n", this->indexNode, treeDepth, maxDepth, this);
 
+  /* set some important variables */
+  this->treeDepth = 0;
+  this->indexNode = 0;
   this->pDimension = this->getDimFromModel();
+
   this->init();
 }
@@ -101,4 +101,5 @@
   this->setClassID(CL_QUADTREE_NODE, "QuadtreeNode");
 
+  /* init the rest of the variables for both init types */
   this->offset = 0.0f;
   this->nodeIter = -1;
@@ -114,4 +115,5 @@
     this->nodes[i] = NULL;
 
+  /* now separate the nodes */
   if( this->treeDepth < this->maxDepth)
     this->separateNode();
@@ -137,7 +139,7 @@
 
 /**
-  \brief this functions builds up a hash table containing all leafs of the Quadtree in a sorted array
-  \param nodeList the nodelist array to add them
-  \param index the current index in the array
+ *  this functions builds up a hash table containing all leafs of the Quadtree in a sorted array
+ * @param nodeList the nodelist array to add them
+ * @param index the current index in the array
 
   The algorithm used for this purpose is home-brown. its not to fast but and the nodes are not always in the right
@@ -166,4 +168,6 @@
  *  gives the signal to separate the model into a quadtree
  * @param treeDepth the max depth, the steps to go if treeDept == 0 leaf reached
+
+ * @todo ATTENION: This function is currently not used and not implemented, but would be a nice addon
  */
 void QuadtreeNode::separateNode(float minLength)
@@ -185,7 +189,8 @@
  *  gives the signal to separate the model into a quadtree
  * @param treeDepth the max depth, the steps to go if treeDept == 0 leaf reached
-*/
+ */
 void QuadtreeNode::separateNode()
 {
+  /* separate the four regions into the four lists */
   tList<sTriangleExt*>*           listA = new tList<sTriangleExt*>();    //!< triangle list of nodeA
   tList<sTriangleExt*>*           listB = new tList<sTriangleExt*>();    //!< triangle list of nodeB
@@ -197,23 +202,24 @@
   rectCenter = this->pDimension->getCenter();
   for( int i = 0; i < this->numTriangles; ++i)
+  {
+    for( int j = 0; j < 3; ++j)
     {
-      for( int j = 0; j < 3; ++j)
-        {
-          pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
-          if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
-            listA->add(&this->pTriangles[i]);
-          if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
-            listB->add(&this->pTriangles[i]);
-          if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
-            listC->add(&this->pTriangles[i]);
-          if( pVert[0] > rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
-            listD->add(&this->pTriangles[i]);
-        }
+      pVert = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
+      if( pVert[0] > rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
+        listA->add(&this->pTriangles[i]);
+      if( pVert[0] < rectCenter->x + this->offset && pVert[2] > rectCenter->z + this->offset)
+        listB->add(&this->pTriangles[i]);
+      if( pVert[0] < rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
+        listC->add(&this->pTriangles[i]);
+      if( pVert[0] > rectCenter->x + this->offset && pVert[2] < rectCenter->z + this->offset)
+        listD->add(&this->pTriangles[i]);
     }
-    for( int i = 0; i < treeDepth; ++i)
-      PRINT(3)(" |");
-    PRINT(3)(" | +-| (II) Quadtree Counts - separating: A: %i, B: %i, C: %i, D: %i\n", listA->getSize(), listB->getSize(), listC->getSize(), listD->getSize());
-
-  /* Separating into to the triangle lists  */
+  }
+  for( int i = 0; i < treeDepth; ++i)
+    PRINT(3)(" |");
+  PRINT(3)(" | +-| (II) Quadtree Counts - separating: A: %i, B: %i, C: %i, D: %i\n", listA->getSize(), listB->getSize(), listC->getSize(), listD->getSize());
+
+
+  /* Separating into to the triangle arrays */
   sTriangleExt**                 pTriA;                                 //!< Triangle array A
   sTriangleExt**                 pTriB;                                 //!< Triangle array B
@@ -238,44 +244,40 @@
   pTriD = new sTriangleExt*[listD->getSize()];
 
-
   counter = 0;
   iterator = listA->getIterator();
   tempTri = iterator->nextElement();
   while( tempTri)
-    {
-      pTriA[counter] = *tempTri;
-      tempTri = iterator->nextElement();
-      ++counter;
-    }
-
+  {
+    pTriA[counter] = *tempTri;
+    tempTri = iterator->nextElement();
+    ++counter;
+  }
   counter = 0;
   iterator = listB->getIterator();
   tempTri = iterator->nextElement();
   while( tempTri)
-    {
-      pTriB[counter] = *tempTri;
-      tempTri = iterator->nextElement();
-      ++counter;
-    }
-
+  {
+    pTriB[counter] = *tempTri;
+    tempTri = iterator->nextElement();
+    ++counter;
+  }
   counter = 0;
   iterator = listC->getIterator();
   tempTri = iterator->nextElement();
   while( tempTri)
-    {
-      pTriC[counter] = *tempTri;
-      tempTri = iterator->nextElement();
-      ++counter;
-    }
-
+  {
+    pTriC[counter] = *tempTri;
+    tempTri = iterator->nextElement();
+    ++counter;
+  }
   counter = 0;
   iterator = listD->getIterator();
   tempTri = iterator->nextElement();
   while( tempTri)
-    {
-      pTriD[counter] = *tempTri;
-      tempTri = iterator->nextElement();
-      ++counter;
-    }
+  {
+    pTriD[counter] = *tempTri;
+    tempTri = iterator->nextElement();
+    ++counter;
+  }
 
   /* now do cleanup */
@@ -288,28 +290,28 @@
 
   /* now create the rectangle dimensions */
-  Vector v;
+  Vector                     v;                                                             //!< temp saving place
+  Rectangle*                 rA;                                                            //!< new size of the node A
+  Rectangle*                 rB;                                                            //!< new size of the node B
+  Rectangle*                 rC;                                                            //!< new size of the node C
+  Rectangle*                 rD;                                                            //!< new size of the node D
+
 
   v.x = this->pDimension->getCenter()->x + this->pDimension->getAxis() / 2.0f;
   v.y = 0.0;
   v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
-  Rectangle* rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
-
+  rA = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
   v.z = this->pDimension->getCenter()->z - this->pDimension->getAxis() / 2.0f;
-  Rectangle* rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
-
+  rB = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
   v.x = this->pDimension->getCenter()->x - this->pDimension->getAxis() / 2.0f;
-  Rectangle* rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
-
+  rC = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
   v.z = this->pDimension->getCenter()->z + this->pDimension->getAxis() / 2.0f;
-  Rectangle* rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
-
-  /* now propagate */
+  rD = new Rectangle(v, this->pDimension->getAxis() / 2.0f);
+
+  /* now create the new nodes  */
   this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree, this, rA, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 0);
-
   this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree, this, rB, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 1);
-
   this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree, this, rC, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 2);
-
   this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree, this, rD, this->treeDepth + 1, this->maxDepth, (this->treeDepth + 1) * 10 + 3);
+
   /* map the array references, this is for faster and automatical interfacing  \todo: use only array */
   this->nodes[0] = this->nodeA;
@@ -321,6 +323,6 @@
 
 /**
-   \brief gets the maximal dimension of a model
-   \return the dimension of the AbstractModel as a Rectangle
+ *  gets the maximal dimension of a model
+ * @return the dimension of the AbstractModel as a Rectangle
 
    The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the
@@ -368,7 +370,7 @@
 
  /**
-  * checks if a point is included in this quadtree
-  * @param v the vector to be checked
-  * @returns true if the vector is included
+ * checks if a point is included in this quadtree
+ * @param v the vector to be checked
+ * @returns true if the vector is included
   */
 bool QuadtreeNode::includesPoint(const Vector& v)
Index: orxonox/trunk/src/world_entities/terrain.cc
===================================================================
--- orxonox/trunk/src/world_entities/terrain.cc	(revision 4923)
+++ orxonox/trunk/src/world_entities/terrain.cc	(revision 4924)
@@ -40,5 +40,4 @@
 
   this->ssp = new SpatialSeparation((AbstractModel*)this->model, 10.0f);
-// //   delete ssp;
 }
 
@@ -94,4 +93,5 @@
   this->objectList = 0;
 }
+
 
 void Terrain::loadParams(const TiXmlElement* root)
@@ -122,4 +122,5 @@
   glPopMatrix();
 
+  /* THIS IS ONLY FOR DEBUGGING INFORMATION */
   this->ssp->drawQuadtree();
 }
