Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4585 in orxonox.OLD


Ignore:
Timestamp:
Jun 10, 2005, 4:05:04 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: fixed the axis length bug

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

Legend:

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

    r4581 r4585  
    220220  ax[2].r = *box->center; ax[2].a = *box->axis[2];
    221221
    222   for(int i = 0; i < 3; ++i)
     222  Plane p0(*box->axis[0], *box->center);
     223  Plane p1(*box->axis[1], *box->center);
     224  Plane p2(*box->axis[2], *box->center);
     225 
     226
     227
     228  halfLength[0] = 0.0f;
     229  for(int j = 0; j < length; ++j)
    223230  {
    224     for(int j = 0; j < length; ++j)
    225     {
    226       tmpLength = ax[i].distancePoint(vertices[j]);
    227       if( tmpLength > halfLength[i])
    228         halfLength[i] = tmpLength;
    229     }
     231    tmpLength = p0.distancePoint(vertices[j]);
     232    if( tmpLength > halfLength[0])
     233      halfLength[0] = tmpLength;
    230234  }
     235
     236
     237  halfLength[1] = 0.0f;
     238  for(int j = 0; j < length; ++j)
     239  {
     240    tmpLength = p1.distancePoint(vertices[j]);
     241    if( tmpLength > halfLength[1])
     242      halfLength[1] = tmpLength;
     243  }
     244
     245  halfLength[2] = 0.0f;
     246  for(int j = 0; j < length; ++j)
     247  {
     248    tmpLength = p2.distancePoint(vertices[j]);
     249    if( tmpLength > halfLength[2])
     250      halfLength[2] = tmpLength;
     251  }
     252
     253
     254
     255   
     256//   for(int i = 0; i < 3; ++i)
     257//   {
     258//     halfLength[i] = 0.0f;
     259//     for(int j = 0; j < length; ++j)
     260//     {
     261//       tmpLength = ax[i].distancePoint(vertices[j]);
     262//       if( tmpLength > halfLength[i])
     263//         halfLength[i] = tmpLength;
     264//     }
     265//   }
    231266
    232267  box->halfLength = halfLength;
  • orxonox/trunk/src/lib/math/vector.cc

    r4578 r4585  
    675675}
    676676
     677
     678/**
     679   \brief returns the distance between the plane and a point
     680   \param p: a Point
     681   \return the distance between the plane and the point (can be negative)
     682 */
     683float Plane::distancePoint (const sVec3D& p) const
     684{
     685  Vector s(p[0], p[1], p[2]);
     686  float l = n.len();
     687  if( l == 0.0) return 0.0;
     688  return (n.dot(s) + k) / n.len();
     689}
     690
     691
    677692/**
    678693   \brief returns the side a point is located relative to a Plane
  • orxonox/trunk/src/lib/math/vector.h

    r4578 r4585  
    225225  Vector intersectLine (const Line& l) const;
    226226  float distancePoint (const Vector& p) const;
     227  float distancePoint (const sVec3D& p) const;
    227228  float locatePoint (const Vector& p) const;
    228229};
Note: See TracChangeset for help on using the changeset viewer.