Index: /trunk/src/lib/collision_detection/bv_tree_node.h
===================================================================
--- /trunk/src/lib/collision_detection/bv_tree_node.h	(revision 7731)
+++ /trunk/src/lib/collision_detection/bv_tree_node.h	(revision 7732)
@@ -39,6 +39,8 @@
 
 
+
  private:
   unsigned int        treeIndex;                  //!< Index number of the BV in the tree
+
 
 };
Index: /trunk/src/lib/collision_detection/obb_tree_node.cc
===================================================================
--- /trunk/src/lib/collision_detection/obb_tree_node.cc	(revision 7731)
+++ /trunk/src/lib/collision_detection/obb_tree_node.cc	(revision 7732)
@@ -483,28 +483,47 @@
 
 
-
+/**
+ * collides one tree with an other
+ *  @param treeNode the other bv tree node
+ *  @param nodeA  the worldentity belonging to this bv
+ *  @param nodeB the worldentity belonging to treeNode
+ */
 void OBBTreeNode::collideWith(BVTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB)
 {
-  if( unlikely(treeNode == NULL))
+  if( unlikely(treeNode == NULL || nodeA == NULL || nodeB == NULL))
+  {
+    assert(false);
     return;
+  }
 
   PRINTF(4)("collideWith\n");
-  /* if the obb overlap, make subtests: check which node is realy overlaping  */
-  PRINTF(4)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
-  //   if( unlikely(treeNode == NULL)) return;
-
-
-  if( this->overlapTest(*this->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
-  {
-    PRINTF(4)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassName(), nodeB->getClassName(), this->nodeLeft, this->nodeRight);
+  PRINTF(5)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());
+
+  // for now only collide with OBBTreeNodes
+  this->collideWithOBB((OBBTreeNode*)treeNode, nodeA, nodeB);
+}
+
+
+
+/**
+ * collides one obb tree with an other
+ *  @param treeNode the other bv tree node
+ *  @param nodeA  the worldentity belonging to this bv
+ *  @param nodeB the worldentity belonging to treeNode
+ */
+void OBBTreeNode::collideWithOBB(OBBTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB)
+{
+  if( this->overlapTest(this->bvElement, (OBB*)treeNode->bvElement, nodeA, nodeB))
+  {
+    PRINTF(5)("collision @ lvl %i, object %s vs. %s, (%p, %p)\n", this->depth, nodeA->getClassName(), nodeB->getClassName(), this->nodeLeft, this->nodeRight);
 
     /* check if left node overlaps */
     if( likely( this->nodeLeft != NULL))
     {
-      PRINTF(4)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
-      if( this->overlapTest(*this->nodeLeft->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
+      PRINTF(5)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());
+      if( this->overlapTest(this->nodeLeft->bvElement, treeNode->bvElement, nodeA, nodeB))
       {
-        this->nodeLeft->collideWith((((const OBBTreeNode*)treeNode)->nodeLeft), nodeA, nodeB);
-        this->nodeLeft->collideWith((((const OBBTreeNode*)treeNode)->nodeRight), nodeA, nodeB);
+        this->nodeLeft->collideWith(treeNode->nodeLeft, nodeA, nodeB);
+        this->nodeLeft->collideWith(treeNode->nodeRight, nodeA, nodeB);
       }
     }
@@ -512,9 +531,9 @@
     if( likely( this->nodeRight != NULL))
     {
-      PRINTF(4)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
-      if(this->overlapTest(*this->nodeRight->bvElement, *(((const OBBTreeNode*)&treeNode)->bvElement), nodeA, nodeB))
+      PRINTF(5)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());
+      if(this->overlapTest(this->nodeRight->bvElement, treeNode->bvElement, nodeA, nodeB))
       {
-        this->nodeRight->collideWith((((const OBBTreeNode*)treeNode)->nodeLeft), nodeA, nodeB);
-        this->nodeRight->collideWith((((const OBBTreeNode*)treeNode)->nodeRight), nodeA, nodeB);
+        this->nodeRight->collideWith(treeNode->nodeLeft, nodeA, nodeB);
+        this->nodeRight->collideWith(treeNode->nodeRight, nodeA, nodeB);
       }
     }
@@ -524,6 +543,5 @@
     if( unlikely(this->nodeRight == NULL || this->nodeLeft == NULL))
     {
-      nodeA->collidesWith(nodeB, (((const OBBTreeNode*)&treeNode)->bvElement->center));
-
+      nodeA->collidesWith(nodeB, treeNode->bvElement->center);
       nodeB->collidesWith(nodeA, this->bvElement->center);
     }
@@ -533,6 +551,12 @@
 
 
-
-bool OBBTreeNode::overlapTest(OBB& boxA, OBB& boxB, WorldEntity* nodeA, WorldEntity* nodeB)
+/**
+ * this actualy checks if one obb box touches the other
+ * @param boxA the box from nodeA
+ * @param boxB the box from nodeB
+ * @param nodeA the node itself
+ * @param nodeB the node itself
+ */
+bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB)
 {
   //HACK remove this again
@@ -549,24 +573,13 @@
   Vector      rotAxisB[3];
 
-  rotAxisA[0] =  nodeA->getAbsDir().apply(boxA.axis[0]);
-  rotAxisA[1] =  nodeA->getAbsDir().apply(boxA.axis[1]);
-  rotAxisA[2] =  nodeA->getAbsDir().apply(boxA.axis[2]);
-
-  rotAxisB[0] =  nodeB->getAbsDir().apply(boxB.axis[0]);
-  rotAxisB[1] =  nodeB->getAbsDir().apply(boxB.axis[1]);
-  rotAxisB[2] =  nodeB->getAbsDir().apply(boxB.axis[2]);
-
-
-  t = nodeA->getAbsCoor() + nodeA->getAbsDir().apply(boxA.center) - ( nodeB->getAbsCoor() + nodeB->getAbsDir().apply(boxB.center));
-
-  //   printf("\n");
-  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[0].x, boxA->axis[0].y, boxA->axis[0].z, rotAxisA[0].x, rotAxisA[0].y, rotAxisA[0].z);
-  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[1].x, boxA->axis[1].y, boxA->axis[1].z, rotAxisA[1].x, rotAxisA[1].y, rotAxisA[1].z);
-  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxA->axis[2].x, boxA->axis[2].y, boxA->axis[2].z, rotAxisA[2].x, rotAxisA[2].y, rotAxisA[2].z);
-  //
-  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[0].x, boxB->axis[0].y, boxB->axis[0].z, rotAxisB[0].x, rotAxisB[0].y, rotAxisB[0].z);
-  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[1].x, boxB->axis[1].y, boxB->axis[1].z, rotAxisB[1].x, rotAxisB[1].y, rotAxisB[1].z);
-  //   printf("(%f, %f, %f) -> (%f, %f, %f)\n", boxB->axis[2].x, boxB->axis[2].y, boxB->axis[2].z, rotAxisB[2].x, rotAxisB[2].y, rotAxisB[2].z);
-
+  rotAxisA[0] =  nodeA->getAbsDir().apply(boxA->axis[0]);
+  rotAxisA[1] =  nodeA->getAbsDir().apply(boxA->axis[1]);
+  rotAxisA[2] =  nodeA->getAbsDir().apply(boxA->axis[2]);
+
+  rotAxisB[0] =  nodeB->getAbsDir().apply(boxB->axis[0]);
+  rotAxisB[1] =  nodeB->getAbsDir().apply(boxB->axis[1]);
+  rotAxisB[2] =  nodeB->getAbsDir().apply(boxB->axis[2]);
+
+  t = nodeA->getAbsCoor() + nodeA->getAbsDir().apply(boxA->center) - ( nodeB->getAbsCoor() + nodeB->getAbsDir().apply(boxB->center));
 
   /* All 3 axis of the object A */
@@ -577,11 +590,11 @@
     l = rotAxisA[j];
 
-    rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
-    rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
-    rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
-
-    rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
-    rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
-    rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
+    rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l));
+    rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l));
+    rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l));
+
+    rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l));
+    rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l));
+    rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l));
 
     PRINTF(5)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
@@ -601,11 +614,11 @@
     l = rotAxisB[j];
 
-    rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
-    rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
-    rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
-
-    rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
-    rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
-    rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
+    rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l));
+    rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l));
+    rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l));
+
+    rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l));
+    rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l));
+    rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l));
 
     PRINTF(5)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
@@ -629,11 +642,11 @@
       l = rotAxisA[j].cross(rotAxisB[k]);
 
-      rA += fabs(boxA.halfLength[0] * rotAxisA[0].dot(l));
-      rA += fabs(boxA.halfLength[1] * rotAxisA[1].dot(l));
-      rA += fabs(boxA.halfLength[2] * rotAxisA[2].dot(l));
-
-      rB += fabs(boxB.halfLength[0] * rotAxisB[0].dot(l));
-      rB += fabs(boxB.halfLength[1] * rotAxisB[1].dot(l));
-      rB += fabs(boxB.halfLength[2] * rotAxisB[2].dot(l));
+      rA += fabs(boxA->halfLength[0] * rotAxisA[0].dot(l));
+      rA += fabs(boxA->halfLength[1] * rotAxisA[1].dot(l));
+      rA += fabs(boxA->halfLength[2] * rotAxisA[2].dot(l));
+
+      rB += fabs(boxB->halfLength[0] * rotAxisB[0].dot(l));
+      rB += fabs(boxB->halfLength[1] * rotAxisB[1].dot(l));
+      rB += fabs(boxB->halfLength[2] * rotAxisB[2].dot(l));
 
       PRINTF(5)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB);
@@ -648,6 +661,6 @@
 
   /* FIXME: there is no collision mark set now */
-     boxA.bCollided = true; /* use this ONLY(!!!!) for drawing operations */
-     boxB.bCollided = true;
+     boxA->bCollided = true; /* use this ONLY(!!!!) for drawing operations */
+     boxB->bCollided = true;
 
 
@@ -655,12 +668,4 @@
   return true;
 }
-
-
-
-
-
-
-
-
 
 
Index: /trunk/src/lib/collision_detection/obb_tree_node.h
===================================================================
--- /trunk/src/lib/collision_detection/obb_tree_node.h	(revision 7731)
+++ /trunk/src/lib/collision_detection/obb_tree_node.h	(revision 7732)
@@ -48,5 +48,6 @@
     void forkBox(OBB& box);
 
-    bool overlapTest(OBB& boxA, OBB& boxB, WorldEntity* nodeA, WorldEntity* nodeB);
+    void collideWithOBB(OBBTreeNode* treeNode, WorldEntity* nodeA, WorldEntity* nodeB);
+    bool overlapTest(OBB* boxA, OBB* boxB, WorldEntity* nodeA, WorldEntity* nodeB);
 
 
Index: /trunk/src/lib/graphics/importer/md2Model.cc
===================================================================
--- /trunk/src/lib/graphics/importer/md2Model.cc	(revision 7731)
+++ /trunk/src/lib/graphics/importer/md2Model.cc	(revision 7732)
@@ -125,4 +125,9 @@
 MD2Model::~MD2Model()
 {
+  this->pModelInfo.pVertices = NULL;
+  this->pModelInfo.pNormals = NULL;
+  this->pModelInfo.pTexCoor = NULL;
+  this->pModelInfo.pTriangles = NULL;
+
   ResourceManager::getInstance()->unload(this->data);
 }
@@ -408,5 +413,4 @@
   delete [] this->pLightNormals;
   delete [] this->pTexCoor;
-
 }
 
Index: /trunk/src/lib/graphics/importer/model.cc
===================================================================
--- /trunk/src/lib/graphics/importer/model.cc	(revision 7731)
+++ /trunk/src/lib/graphics/importer/model.cc	(revision 7732)
@@ -45,5 +45,17 @@
 */
 Model::~Model()
-{ }
+{
+  if( this->pModelInfo.pVertices != NULL)
+    delete [] this->pModelInfo.pVertices;
+
+  if( this->pModelInfo.pTriangles != NULL)
+    delete [] this->pModelInfo.pTriangles;
+
+  if( this->pModelInfo.pNormals != NULL)
+    delete [] this->pModelInfo.pNormals;
+
+  if( this->pModelInfo.pTexCoor != NULL)
+    delete [] this->pModelInfo.pTexCoor;
+}
 
 
Index: /trunk/src/lib/graphics/importer/static_model.cc
===================================================================
--- /trunk/src/lib/graphics/importer/static_model.cc	(revision 7731)
+++ /trunk/src/lib/graphics/importer/static_model.cc	(revision 7732)
@@ -185,4 +185,9 @@
     delete (*modMat);
   }
+
+  // mark this stuff as beeing deleted
+  this->pModelInfo.pVertices = NULL;
+  this->pModelInfo.pNormals = NULL;
+  this->pModelInfo.pTexCoor = NULL;
 }
 
