OPC_RayAABBOverlap.h
Go to the documentation of this file.
00001 // Opcode 1.1: ray-AABB overlap tests based on Woo's code
00002 // Opcode 1.2: ray-AABB overlap tests based on the separating axis theorem
00003 //
00004 // The point of intersection is not computed anymore. The distance to impact is not needed anymore
00005 // since we now have two different queries for segments or rays.
00006 
00008 
00014 
00015 inline_ BOOL RayCollider::SegmentAABBOverlap(const Point& center, const Point& extents)
00016 {
00017         // Stats
00018         mNbRayBVTests++;
00019 
00020         float Dx = mData2.x - center.x;         if(fabsf(Dx) > extents.x + mFDir.x)     return FALSE;
00021         float Dy = mData2.y - center.y;         if(fabsf(Dy) > extents.y + mFDir.y)     return FALSE;
00022         float Dz = mData2.z - center.z;         if(fabsf(Dz) > extents.z + mFDir.z)     return FALSE;
00023 
00024         float f;
00025         f = mData.y * Dz - mData.z * Dy;        if(fabsf(f) > extents.y*mFDir.z + extents.z*mFDir.y)    return FALSE;
00026         f = mData.z * Dx - mData.x * Dz;        if(fabsf(f) > extents.x*mFDir.z + extents.z*mFDir.x)    return FALSE;
00027         f = mData.x * Dy - mData.y * Dx;        if(fabsf(f) > extents.x*mFDir.y + extents.y*mFDir.x)    return FALSE;
00028 
00029         return TRUE;
00030 }
00031 
00033 
00039 
00040 inline_ BOOL RayCollider::RayAABBOverlap(const Point& center, const Point& extents)
00041 {
00042         // Stats
00043         mNbRayBVTests++;
00044 
00045 //      float Dx = mOrigin.x - center.x;        if(fabsf(Dx) > extents.x && Dx*mDir.x>=0.0f)    return FALSE;
00046 //      float Dy = mOrigin.y - center.y;        if(fabsf(Dy) > extents.y && Dy*mDir.y>=0.0f)    return FALSE;
00047 //      float Dz = mOrigin.z - center.z;        if(fabsf(Dz) > extents.z && Dz*mDir.z>=0.0f)    return FALSE;
00048 
00049         float Dx = mOrigin.x - center.x;        if(GREATER(Dx, extents.x) && Dx*mDir.x>=0.0f)   return FALSE;
00050         float Dy = mOrigin.y - center.y;        if(GREATER(Dy, extents.y) && Dy*mDir.y>=0.0f)   return FALSE;
00051         float Dz = mOrigin.z - center.z;        if(GREATER(Dz, extents.z) && Dz*mDir.z>=0.0f)   return FALSE;
00052 
00053 //      float Dx = mOrigin.x - center.x;        if(GREATER(Dx, extents.x) && ((SIR(Dx)-1)^SIR(mDir.x))>=0.0f)   return FALSE;
00054 //      float Dy = mOrigin.y - center.y;        if(GREATER(Dy, extents.y) && ((SIR(Dy)-1)^SIR(mDir.y))>=0.0f)   return FALSE;
00055 //      float Dz = mOrigin.z - center.z;        if(GREATER(Dz, extents.z) && ((SIR(Dz)-1)^SIR(mDir.z))>=0.0f)   return FALSE;
00056 
00057         float f;
00058         f = mDir.y * Dz - mDir.z * Dy;          if(fabsf(f) > extents.y*mFDir.z + extents.z*mFDir.y)    return FALSE;
00059         f = mDir.z * Dx - mDir.x * Dz;          if(fabsf(f) > extents.x*mFDir.z + extents.z*mFDir.x)    return FALSE;
00060         f = mDir.x * Dy - mDir.y * Dx;          if(fabsf(f) > extents.x*mFDir.y + extents.y*mFDir.x)    return FALSE;
00061 
00062         return TRUE;
00063 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:55