OPC_RayAABBOverlap.h
Go to the documentation of this file.
1 // Opcode 1.1: ray-AABB overlap tests based on Woo's code
2 // Opcode 1.2: ray-AABB overlap tests based on the separating axis theorem
3 //
4 // The point of intersection is not computed anymore. The distance to impact is not needed anymore
5 // since we now have two different queries for segments or rays.
6 
8 
14 inline_ BOOL RayCollider::SegmentAABBOverlap(const Point& center, const Point& extents)
16 {
17  // Stats
18  mNbRayBVTests++;
19 
20  float Dx = mData2.x - center.x; if(fabsf(Dx) > extents.x + mFDir.x) return FALSE;
21  float Dy = mData2.y - center.y; if(fabsf(Dy) > extents.y + mFDir.y) return FALSE;
22  float Dz = mData2.z - center.z; if(fabsf(Dz) > extents.z + mFDir.z) return FALSE;
23 
24  float f;
25  f = mData.y * Dz - mData.z * Dy; if(fabsf(f) > extents.y*mFDir.z + extents.z*mFDir.y) return FALSE;
26  f = mData.z * Dx - mData.x * Dz; if(fabsf(f) > extents.x*mFDir.z + extents.z*mFDir.x) return FALSE;
27  f = mData.x * Dy - mData.y * Dx; if(fabsf(f) > extents.x*mFDir.y + extents.y*mFDir.x) return FALSE;
28 
29  return TRUE;
30 }
31 
33 
39 inline_ BOOL RayCollider::RayAABBOverlap(const Point& center, const Point& extents)
41 {
42  // Stats
43  mNbRayBVTests++;
44 
45 // float Dx = mOrigin.x - center.x; if(fabsf(Dx) > extents.x && Dx*mDir.x>=0.0f) return FALSE;
46 // float Dy = mOrigin.y - center.y; if(fabsf(Dy) > extents.y && Dy*mDir.y>=0.0f) return FALSE;
47 // float Dz = mOrigin.z - center.z; if(fabsf(Dz) > extents.z && Dz*mDir.z>=0.0f) return FALSE;
48 
49  float Dx = mOrigin.x - center.x; if(GREATER(Dx, extents.x) && Dx*mDir.x>=0.0f) return FALSE;
50  float Dy = mOrigin.y - center.y; if(GREATER(Dy, extents.y) && Dy*mDir.y>=0.0f) return FALSE;
51  float Dz = mOrigin.z - center.z; if(GREATER(Dz, extents.z) && Dz*mDir.z>=0.0f) return FALSE;
52 
53 // float Dx = mOrigin.x - center.x; if(GREATER(Dx, extents.x) && ((SIR(Dx)-1)^SIR(mDir.x))>=0.0f) return FALSE;
54 // float Dy = mOrigin.y - center.y; if(GREATER(Dy, extents.y) && ((SIR(Dy)-1)^SIR(mDir.y))>=0.0f) return FALSE;
55 // float Dz = mOrigin.z - center.z; if(GREATER(Dz, extents.z) && ((SIR(Dz)-1)^SIR(mDir.z))>=0.0f) return FALSE;
56 
57  float f;
58  f = mDir.y * Dz - mDir.z * Dy; if(fabsf(f) > extents.y*mFDir.z + extents.z*mFDir.y) return FALSE;
59  f = mDir.z * Dx - mDir.x * Dz; if(fabsf(f) > extents.x*mFDir.z + extents.z*mFDir.x) return FALSE;
60  f = mDir.x * Dy - mDir.y * Dx; if(fabsf(f) > extents.x*mFDir.y + extents.y*mFDir.x) return FALSE;
61 
62  return TRUE;
63 }
#define FALSE
Definition: OPC_IceHook.h:9
#define TRUE
Definition: OPC_IceHook.h:13
#define inline_
float z
Definition: IcePoint.h:524
Point mDir
Ray direction (normalized)
Definition: IcePoint.h:25
inline_ BOOL RayAABBOverlap(const Point &center, const Point &extents)
int BOOL
Another boolean type.
Definition: IceTypes.h:102
float x
Definition: IcePoint.h:524
Point mFDir
fabsf(mDir)
Point mOrigin
Ray origin.
float y
Definition: IcePoint.h:524
inline_ BOOL SegmentAABBOverlap(const Point &center, const Point &extents)
#define GREATER(x, y)
Definition: Opcode.h:28
udword mNbRayBVTests
Number of Ray-BV tests.


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:39