Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
hrplib
hrpCollision
Opcode
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
}
FALSE
#define FALSE
Definition:
OPC_IceHook.h:9
TRUE
#define TRUE
Definition:
OPC_IceHook.h:13
inline_
#define inline_
Definition:
IcePreprocessor.h:103
Point::z
float z
Definition:
IcePoint.h:524
RayCollider::mDir
Point mDir
Ray direction (normalized)
Definition:
OPC_RayCollider.h:181
Point
Definition:
IcePoint.h:25
RayCollider::RayAABBOverlap
inline_ BOOL RayAABBOverlap(const Point ¢er, const Point &extents)
Definition:
OPC_RayAABBOverlap.h:40
BOOL
int BOOL
Another boolean type.
Definition:
IceTypes.h:102
Point::x
float x
Definition:
IcePoint.h:524
RayCollider::mFDir
Point mFDir
fabsf(mDir)
Definition:
OPC_RayCollider.h:182
RayCollider::mData2
Point mData2
Definition:
OPC_RayCollider.h:183
RayCollider::mOrigin
Point mOrigin
Ray origin.
Definition:
OPC_RayCollider.h:180
Point::y
float y
Definition:
IcePoint.h:524
RayCollider::mData
Point mData
Definition:
OPC_RayCollider.h:183
RayCollider::SegmentAABBOverlap
inline_ BOOL SegmentAABBOverlap(const Point ¢er, const Point &extents)
Definition:
OPC_RayAABBOverlap.h:15
GREATER
#define GREATER(x, y)
Definition:
Opcode.h:28
swingTest.f
f
Definition:
swingTest.py:6
RayCollider::mNbRayBVTests
udword mNbRayBVTests
Number of Ray-BV tests.
Definition:
OPC_RayCollider.h:193
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