Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5932 in orxonox.OLD


Ignore:
Timestamp:
Dec 5, 2005, 11:26:19 AM (19 years ago)
Author:
patrick
Message:

collision_detection: the algorithm works smoother now on the std object

File:
1 edited

Legend:

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

    r5929 r5932  
    199199    }
    200200  }
    201   for(int i = 0; i < 3; ++i)
     201  for( int i = 0; i < 3; ++i)
    202202  {
    203203    box.covarianceMatrix[i][0] = covariance[i][0];
     
    216216
    217217  /* go thourgh all vertices, add only the used vertices indexes */
    218   for( int i = 0; i < length; ++i)
    219   {
    220     for(int j = 0; j < 3; ++j)
    221     {
    222       vertIndex = modelInf.pTriangles[triangleIndexes[i]].indexToVertices[j];
    223 
    224       vertexFound = false;
    225       for( int i = 0; i < vertIndexVector.size(); i++)
    226       {
    227         if( vertIndexVector[i] == vertIndex)
    228           vertexFound = true;
    229       }
    230       if( !vertexFound)
    231         vertIndexVector.push_back(vertIndex);
    232     }
    233   }
    234   /* now realy calculate the center */
    235   for( int i = 0; i < vertIndexVector.size(); ++i)
    236   {
    237     tmpVec = (sVec3D*)(&modelInf.pVertices[vertIndexVector[i]]);
    238     arithCenter += *tmpVec;
    239   }
    240   box.arithCenter = arithCenter / vertIndexVector.size();
     218//   for( int i = 0; i < length; ++i)
     219//   {
     220//     for(int j = 0; j < 3; ++j)
     221//     {
     222//       vertIndex = modelInf.pTriangles[triangleIndexes[i]].indexToVertices[j];
     223//
     224//       vertexFound = false;
     225//       for( int i = 0; i < vertIndexVector.size(); i++)
     226//       {
     227//         if( vertIndexVector[i] == vertIndex)
     228//           vertexFound = true;
     229//       }
     230//       if( !vertexFound)
     231//         vertIndexVector.push_back(vertIndex);
     232//     }
     233//   }
     234//   /* now realy calculate the center */
     235//   for( int i = 0; i < vertIndexVector.size(); ++i)
     236//   {
     237//     tmpVec = (sVec3D*)(&modelInf.pVertices[vertIndexVector[i]]);
     238//     arithCenter += *tmpVec;
     239//   }
     240//   box.arithCenter = arithCenter / vertIndexVector.size();
    241241
    242242
     
    254254  }
    255255  PRINTF(3)("\nWeighteed OBB Center:\n\t\t%11.4f\t %11.4f\t %11.4f\n", center.x, center.y, center.z);
    256   PRINTF(3)("\nArithmetical OBB Center:\n\t\t%11.4f\t %11.4f\t %11.4f\n", box.arithCenter.x, box.arithCenter.y, box.arithCenter.z);
     256//   PRINTF(3)("\nArithmetical OBB Center:\n\t\t%11.4f\t %11.4f\t %11.4f\n", box.arithCenter.x, box.arithCenter.y, box.arithCenter.z);
    257257
    258258  /* write back the covariance matrix data to the object oriented bouning box */
     
    320320  const sVec3D*       tmpVec;                                //!< variable taking tmp vectors
    321321
    322   /*
    323   this step is split up in three: first there will be made a bounding box which is
    324   very badly centered. In the section step there will be calculated a new center
    325   and a better bounding box.
    326   */
    327 
    328   /* get a bad bounding box axis */
    329 //   halfLength[0] = -1.0f;
    330 //   for( int j = 0; j < length; ++j)
    331 //   {
    332 //     for( int i = 0; i < 3; ++i)
    333 //     {
    334 //       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
    335 //       tmpLength = fabs(p0.distancePoint(*tmpVec));
    336 //       if( tmpLength > halfLength[0])
    337 //         halfLength[0] = tmpLength;
    338 //     }
    339 //   }
    340 //
    341 //   halfLength[1] = -1.0f;
    342 //   for( int j = 0; j < length; ++j)
    343 //   {
    344 //     for( int i = 0; i < 3; ++i)
    345 //     {
    346 //       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
    347 //       tmpLength = fabs(p0.distancePoint(*tmpVec));
    348 //       if( tmpLength > halfLength[1])
    349 //         halfLength[1] = tmpLength;
    350 //     }
    351 //   }
    352 //
    353 //   halfLength[2] = -1.0f;
    354 //   for( int j = 0; j < length; ++j)
    355 //   {
    356 //     for( int i = 0; i < 3; ++i)
    357 //     {
    358 //       tmpVec = (sVec3D*)(&modelInf.pVertices[modelInf.pTriangles[triangleIndexes[j]].indexToVertices[i]]);
    359 //       tmpLength = fabs(p0.distancePoint(*tmpVec));
    360 //       if( tmpLength > halfLength[2])
    361 //         halfLength[2] = tmpLength;
    362 //     }
    363 //   }
    364 
    365 
    366322
    367323  /* get the maximal dimensions of the body in all directions */
     
    420376  /* calculate the real centre of the body by using the axis length */
    421377  float               centerOffset[3];
    422   float               newHalfLength[3];
    423378
    424379  for( int i = 0; i < 3; ++i)
    425380  {
    426381    centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f;       // min length is negatie
    427     newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;      // min length is negative
    428     box.center +=  (box.axis[i] * centerOffset[i]);               // update the new center vector
    429     halfLength[i] = newHalfLength[i];
    430   }
     382    box.halfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;      // min length is negative
     383  }
     384  box.center.x += centerOffset[0];
     385  box.center.y += centerOffset[1];
     386  box.center.z += centerOffset[2];
     387
    431388  PRINTF(3)("\n");
    432389  PRINT(3)("\tAxis Length x: %f (max: %11.2f, \tmin: %11.2f)\n", halfLength[0], maxLength[0], minLength[0]);
     
    435392
    436393
    437   box.halfLength[0] = halfLength[0];
    438   box.halfLength[1] = halfLength[1];
    439   box.halfLength[2] = halfLength[2];
     394//   box.halfLength[0] = halfLength[0];
     395//   box.halfLength[1] = halfLength[1];
     396//   box.halfLength[2] = halfLength[2];
    440397}
    441398
     
    808765    }
    809766
    810     if(this->nodeLeft == NULL || this->nodeRight == NULL)
     767    if( this->nodeLeft == NULL || this->nodeRight == NULL)
    811768      depth = 0;
    812769    if( !(drawMode & DRAW_SINGLE && depth != 0))
Note: See TracChangeset for help on using the changeset viewer.