Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5920 in orxonox.OLD for branches/collision_detection/src/lib


Ignore:
Timestamp:
Dec 4, 2005, 10:17:39 PM (19 years ago)
Author:
patrick
Message:

collision_detection: speed up in some function, more checks and more flexible output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc

    r5884 r5920  
    9898  PRINTF(3)("\n==============================Creating OBB Tree Node==================\n");
    9999  PRINT(3)(" OBB Tree Infos: \n");
    100   PRINT(3)("\tDepth: %i \n\tTree Index: %i \n\tNumber of Vertices: %i\n", depth, treeIndex, length);
     100  PRINT(3)("\tDepth: %i \n\tTree Index: %i \n\tNumber of Triangles: %i\n", depth, treeIndex, length);
    101101  this->depth = depth;
    102102
     
    290290
    291291  /* get a bad bounding box axis */
    292   halfLength[0] = -1.0f;
    293   for( int j = 0; j < length; ++j)
    294   {
    295     for( int i = 0; i < 3; ++i)
    296     {
    297       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
    298       tmpLength = fabs(p0.distancePoint(*tmpVec));
    299       if( tmpLength > halfLength[0])
    300         halfLength[0] = tmpLength;
    301     }
    302   }
    303 
    304   halfLength[1] = -1.0f;
    305   for( int j = 0; j < length; ++j)
    306   {
    307     for( int i = 0; i < 3; ++i)
    308     {
    309       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
    310       tmpLength = fabs(p0.distancePoint(*tmpVec));
    311       if( tmpLength > halfLength[1])
    312         halfLength[1] = tmpLength;
    313     }
    314   }
    315 
    316   halfLength[2] = -1.0f;
    317   for( int j = 0; j < length; ++j)
    318   {
    319     for( int i = 0; i < 3; ++i)
    320     {
    321       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
    322       tmpLength = fabs(p0.distancePoint(*tmpVec));
    323       if( tmpLength > halfLength[2])
    324         halfLength[2] = tmpLength;
    325     }
    326   }
     292//   halfLength[0] = -1.0f;
     293//   for( int j = 0; j < length; ++j)
     294//   {
     295//     for( int i = 0; i < 3; ++i)
     296//     {
     297//       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
     298//       tmpLength = fabs(p0.distancePoint(*tmpVec));
     299//       if( tmpLength > halfLength[0])
     300//         halfLength[0] = tmpLength;
     301//     }
     302//   }
     303//
     304//   halfLength[1] = -1.0f;
     305//   for( int j = 0; j < length; ++j)
     306//   {
     307//     for( int i = 0; i < 3; ++i)
     308//     {
     309//       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
     310//       tmpLength = fabs(p0.distancePoint(*tmpVec));
     311//       if( tmpLength > halfLength[1])
     312//         halfLength[1] = tmpLength;
     313//     }
     314//   }
     315//
     316//   halfLength[2] = -1.0f;
     317//   for( int j = 0; j < length; ++j)
     318//   {
     319//     for( int i = 0; i < 3; ++i)
     320//     {
     321//       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
     322//       tmpLength = fabs(p0.distancePoint(*tmpVec));
     323//       if( tmpLength > halfLength[2])
     324//         halfLength[2] = tmpLength;
     325//     }
     326//   }
    327327
    328328
     
    382382
    383383  /* calculate the real centre of the body by using the axis length */
    384   float centerOffset[3];
    385   float newHalfLength[3];
     384  float               centerOffset[3];
     385  float               newHalfLength[3];
     386
    386387  for(int i = 0; i < 3; ++i)
    387388  {
     
    392393  }
    393394  PRINTF(3)("\n");
    394   PRINT(3)("\tmax: %11.2f, \tmin: %11.2f\n", maxLength[0], minLength[0]);
    395   PRINT(3)("\tmax: %11.2f, \tmin: %11.2f\n", maxLength[1], minLength[1]);
    396   PRINT(3)("\tmax: %11.2f, \tmin: %11.2f\n", maxLength[2], minLength[2]);
     395  PRINT(3)("\tAxis Length x: %f (max: %11.2f, \tmin: %11.2f)\n", halfLength[0], maxLength[0], minLength[0]);
     396  PRINT(3)("\tAxis Length x: %f (max: %11.2f, \tmin: %11.2f)\n", halfLength[1], maxLength[1], minLength[1]);
     397  PRINT(3)("\tAxis Length x: %f (max: %11.2f, \tmin: %11.2f)\n", halfLength[2], maxLength[2], minLength[2]);
    397398
    398399
     
    450451  const float*             b;                                    //!< triangle  edge b
    451452  const float*             c;                                    //!< triangle  edge c
     453
     454
     455  ./* find the center of the box */
    452456
    453457  this->separationPlane = Plane(box.axis[longestAxisIndex], box.center);
Note: See TracChangeset for help on using the changeset viewer.