Index: branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
===================================================================
--- branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc	(revision 5867)
+++ branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc	(revision 5868)
@@ -354,5 +354,5 @@
  * @param length: the length of the indexes array
  */
-void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modInfo, const int* triangleIndexes, unsigned int length)
+void OBBTreeNode::calculateBoxAxis(OBB& box, const modelInfo& modelInf, const int* triangleIndexes, unsigned int length)
 {
 
@@ -370,29 +370,47 @@
   float               maxLength[3];
   float               minLength[3];
-
-
-  /* get a bad bounding box */
+  const sVec3D*       tmpVec;
+
+  /*
+  this step is split up in two: first there will be made a bounding box which is
+  very badly centered. In the secon step there will be calculated a new center
+  and a better bounding box.
+  */
+
+  /* get a bad bounding box axis */
   halfLength[0] = -1.0f;
-  for(int j = 0; j < length; ++j)
-  {
-    tmpLength = fabs(p0.distancePoint(vertices[j]));
-    if( tmpLength > halfLength[0])
-      halfLength[0] = tmpLength;
+  for( int j = 0; j < length; ++j)
+  {
+    for( int i = 0; i < 3; ++i)
+    {
+      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
+      tmpLength = fabs(p0.distancePoint(*tmpVec));
+      if( tmpLength > halfLength[0])
+        halfLength[0] = tmpLength;
+    }
   }
 
   halfLength[1] = -1.0f;
-  for(int j = 0; j < length; ++j)
-  {
-    tmpLength = fabs(p1.distancePoint(vertices[j]));
-    if( tmpLength > halfLength[1])
-      halfLength[1] = tmpLength;
+  for( int j = 0; j < length; ++j)
+  {
+    for( int i = 0; i < 3; ++i)
+    {
+      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
+      tmpLength = fabs(p0.distancePoint(*tmpVec));
+      if( tmpLength > halfLength[1])
+        halfLength[1] = tmpLength;
+    }
   }
 
   halfLength[2] = -1.0f;
-  for(int j = 0; j < length; ++j)
-  {
-    tmpLength = fabs(p2.distancePoint(vertices[j]));
-    if( tmpLength > halfLength[2])
-      halfLength[2] = tmpLength;
+  for( int j = 0; j < length; ++j)
+  {
+    for( int i = 0; i < 3; ++i)
+    {
+      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
+      tmpLength = fabs(p0.distancePoint(*tmpVec));
+      if( tmpLength > halfLength[2])
+        halfLength[2] = tmpLength;
+    }
   }
 
@@ -400,35 +418,53 @@
 
   /* get the maximal dimensions of the body in all directions */
-  maxLength[0] = p0.distancePoint(vertices[0]);
-  minLength[0] = p0.distancePoint(vertices[0]);
-  for(int j = 0; j < length; ++j)
-  {
-    tmpLength = p0.distancePoint(vertices[j]);
-    if( tmpLength > maxLength[0])
-      maxLength[0] = tmpLength;
-    else if( tmpLength < minLength[0])
-      minLength[0] = tmpLength;
-  }
-
-  maxLength[1] = p1.distancePoint(vertices[0]);
-  minLength[1] = p1.distancePoint(vertices[0]);
-  for(int j = 0; j < length; ++j)
-  {
-    tmpLength = p1.distancePoint(vertices[j]);
-    if( tmpLength > maxLength[1])
-      maxLength[1] = tmpLength;
-    else if( tmpLength < minLength[1])
-      minLength[1] = tmpLength;
-  }
-
-  maxLength[2] = p2.distancePoint(vertices[0]);
-  minLength[2] = p2.distancePoint(vertices[0]);
-  for(int j = 0; j < length; ++j)
-  {
-    tmpLength = p2.distancePoint(vertices[j]);
-    if( tmpLength > maxLength[2])
-      maxLength[2] = tmpLength;
-    else if( tmpLength < minLength[2])
-      minLength[2] = tmpLength;
+  /* for the initialisation the value just has to be inside of the polygon soup -> first vertices (rand) */
+  tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[0]].indexToVertices[0]]);
+  maxLength[0] = p0.distancePoint(*tmpVec);
+  minLength[0] = p0.distancePoint(*tmpVec);
+  for( int j = 0; j < length; ++j)
+  {
+    for( int i = 0; i < 3; ++i)
+    {
+      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
+      tmpLength = p0.distancePoint(*tmpVec);
+      if( tmpLength > maxLength[0])
+        maxLength[0] = tmpLength;
+      else if( tmpLength < minLength[0])
+        minLength[0] = tmpLength;
+    }
+  }
+
+  /* for the initialisation the value just has to be inside of the polygon soup -> first vertices (rand) */
+  tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[0]].indexToVertices[0]]);
+  maxLength[1] = p1.distancePoint(*tmpVec);
+  minLength[1] = p1.distancePoint(*tmpVec);
+  for( int j = 0; j < length; ++j)
+  {
+    for( int i = 0; i < 3; ++i)
+    {
+      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
+      tmpLength = p0.distancePoint(*tmpVec);
+      if( tmpLength > maxLength[1])
+        maxLength[1] = tmpLength;
+      else if( tmpLength < minLength[1])
+        minLength[1] = tmpLength;
+    }
+  }
+
+  /* for the initialisation the value just has to be inside of the polygon soup -> first vertices (rand) */
+  tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[0]].indexToVertices[0]]);
+  maxLength[2] = p2.distancePoint(*tmpVec);
+  minLength[2] = p2.distancePoint(*tmpVec);
+  for( int j = 0; j < length; ++j)
+  {
+    for( int i = 0; i < 3; ++i)
+    {
+      tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
+      tmpLength = p0.distancePoint(*tmpVec);
+      if( tmpLength > maxLength[2])
+        maxLength[2] = tmpLength;
+      else if( tmpLength < minLength[2])
+        minLength[2] = tmpLength;
+    }
   }
 
