Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7706 in orxonox.OLD for branches


Ignore:
Timestamp:
May 18, 2006, 8:13:53 PM (19 years ago)
Author:
patrick
Message:

cd: now the obb fits perfectly for the first time

File:
1 edited

Legend:

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

    r7705 r7706  
    359359  for( int i = 0; i < 3; ++i)
    360360  {
    361 //     centerOffset[i] = (fabs(maxLength[i]) - fabs(minLength[i])) / 2.0f;       // min length is negatie
    362     centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f;       // min length is negatie
    363     box.halfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;                 // min length is negative
    364   }
    365 
    366   box.center.x += centerOffset[0];
    367   box.center.y += centerOffset[1];
    368   box.center.z += centerOffset[2];
     361    if( maxLength[i] > 0.0f && minLength[i] > 0.0f)  // both axis positiv
     362      centerOffset[i] = minLength[i] + (maxLength[i] - minLength[i]) / 2.0f;
     363    else if( maxLength[i] > 0.0f && maxLength[i] < 0.0f) // positiv and negativ
     364      centerOffset[i] = (maxLength[i] + minLength[i]) / 2.0f;
     365    else //both negativ
     366     centerOffset[i] = minLength[i] + (maxLength[i] - minLength[i]) / 2.0f;
     367
     368    box.halfLength[i] = (maxLength[i] - minLength[i]) / 2.0f;
     369  }
     370
     371  box.center += (box.axis[0] * centerOffset[0]);
     372  box.center += (box.axis[1] * centerOffset[1]);
     373  box.center += (box.axis[2] * centerOffset[2]);
     374
    369375
    370376  PRINTF(3)("\n");
Note: See TracChangeset for help on using the changeset viewer.