-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAABB.cpp
33 lines (28 loc) · 830 Bytes
/
AABB.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
AABB.cpp
*/
#include "AABB.h"
typedef glm::vec3 vec3;
AABB::AABB()
{
this->minimum = vec3(0.0,0.0,0.0);
this->maximum = vec3(0.0,0.0,0.0);
}
bool AABB::doesIntersectAABB(AABB* otherBox)
{
return (this->maximum.x > otherBox->minimum.x) &&
(this->maximum.y > otherBox->minimum.y) &&
(this->maximum.z > otherBox->minimum.z) &&
(this->minimum.x < otherBox->maximum.x) &&
(this->minimum.y < otherBox->maximum.y) &&
(this->minimum.z < otherBox->maximum.z);
}
bool AABB::isWithin(glm::vec3& point)
{
return (point.x >= this->minimum.x) &&
(point.y >= this->minimum.y) &&
(point.z >= this->minimum.z) &&
(point.x <= this->maximum.x) &&
(point.y <= this->maximum.y) &&
(point.z <= this->maximum.z);
}