Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4710 in orxonox.OLD for orxonox/trunk/src/lib/collision_detection


Ignore:
Timestamp:
Jun 26, 2005, 10:10:48 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: weeped out some very serious bugs, now the tree separation werks flawless, hf

Location:
orxonox/trunk/src/lib/collision_detection
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/collision_detection/cd_engine.cc

    r4704 r4710  
    130130  this->rootTree->spawnBVTree(depth, vertices, numVertices);
    131131}
     132
     133void CDEngine::debugDraw(int depth, int drawMode)
     134{
     135  if(this-> rootTree != NULL)
     136    this->rootTree->drawBV(depth, drawMode);
     137}
  • orxonox/trunk/src/lib/collision_detection/cd_engine.h

    r4688 r4710  
    5252  void debug();
    5353  void debugSpawnTree(int depth, sVec3D* vertices, int numVertices);
     54  void debugDraw(int depth, int drawMode);
    5455
    5556 private:
  • orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc

    r4708 r4710  
    114114
    115115
    116     if(this->tmpLen1 > 0)
     116    if(this->tmpLen1 > 2)
    117117    {
    118118      OBBTreeNode* node1 = new OBBTreeNode();
     
    125125    }
    126126
    127     if( this->tmpLen2 > 0)
     127    if( this->tmpLen2 > 2)
    128128    {
    129129      OBBTreeNode* node2 = new OBBTreeNode();
     
    133133    else
    134134    {
    135       PRINTF(0)("Aboarding tree walk: less than 3 vertices left\n");
     135      PRINTF(0)("Abording tree walk: less than 3 vertices left\n");
    136136    }
    137137
     
    420420
    421421  /* get the maximal dimensions of the body in all directions */
    422    maxLength[0] = 0.0f;
    423    minLength[0] = 0.0f;
     422    maxLength[0] = p0.distancePoint(vertices[0]);
     423    minLength[0] = p0.distancePoint(vertices[0]);
    424424   for(int j = 0; j < length; ++j)
    425425   {
     
    431431   }
    432432
    433    maxLength[1] = 0.0f;
    434    minLength[1] = 0.0f;
     433   maxLength[1] = p1.distancePoint(vertices[0]);
     434   minLength[1] = p1.distancePoint(vertices[0]);
    435435   for(int j = 0; j < length; ++j)
    436436   {
     
    442442   }
    443443
    444    maxLength[2] = 0.0f;
    445    minLength[2] = 0.0f;
     444   maxLength[2] = p2.distancePoint(vertices[0]);
     445   minLength[2] = p2.distancePoint(vertices[0]);
    446446   for(int j = 0; j < length; ++j)
    447447   {
     
    460460     {
    461461       PRINTF(3)("max: %f, min: %f \n", maxLength[i], minLength[i]);
    462        centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f; // min length is negatie
    463        newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f; // min length is negative
     462       centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f;       // min length is negatie
     463       newHalfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;      // min length is negative
    464464       *box->center +=  (box->axis[i] * centerOffset[i]);            // update the new center vector
    465465       halfLength[i] = newHalfLength[i];
     
    478478  {
    479479    //if( box->halfLength[i] == 0.0)
    480     PRINTF(3)("length[%i] = %f\n", i, box->halfLength[i]);
     480    if(fabs(box->halfLength[i]) > 5.0f)
     481    {
     482      PRINTF(0)("length[%i] = %f\n", i, box->halfLength[i]);
     483      PRINTF(0)("MaxLength = %f, MinLength = %f\n", maxLength[i], minLength[i]);
     484      PRINTF(0)("\nVertex Data:\n");
     485      for(int i = 0; i < length; i++)
     486      {
     487        PRINTF(0)("vertex %i: %f, %f, %f\n", i, box->vertices[i][0], box->vertices[i][1], box->vertices[i][2]);
     488      }
     489    }
    481490  }
    482491}
     
    525534  }
    526535
    527 //   PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
     536  PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
    528537
    529538
     
    534543  tList<sVec3D>      partition2;                           //!< the vertex partition 2
    535544
     545
    536546  PRINTF(3)("vertex index: %i, of %i\n", vertexIndex, box->numOfVertices);
    537547  this->separationPlane = new Plane(box->axis[axisIndex], box->vertices[vertexIndex]);  //!< separation plane
     
    541551  for(int i = 0; i < box->numOfVertices; ++i)
    542552  {
    543     if( this->separationPlane->distancePoint(box->vertices[i]) > 0.0f)
    544       partition1.add(&box->vertices[i]);
     553    if( i == vertexIndex) continue;
     554    tmpDist = this->separationPlane->distancePoint(box->vertices[i]);
     555    if( tmpDist > 0.0)
     556      partition1.add(&box->vertices[i]); /* positive numbers plus zero */
    545557    else
    546       partition2.add(&box->vertices[i]);
     558      partition2.add(&box->vertices[i]); /* negatice numbers */
    547559  }
    548560  partition1.add(&box->vertices[vertexIndex]);
    549 
    550 //   PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
     561  partition2.add(&box->vertices[vertexIndex]);
     562
     563  PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
    551564
    552565
     
    827840  if( drawMode & DRAW_BV_POLYGON || drawMode & DRAW_ALL || drawMode & DRAW_BV_BLENDED)
    828841  {
     842    if(this->nodeLeft == NULL && this->nodeRight == NULL)
     843      depth = 0;
    829844    if( !(drawMode & DRAW_SINGLE && depth != 0))
    830845    {
Note: See TracChangeset for help on using the changeset viewer.