forked from azzuriel/TerrainProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aabb.cpp
51 lines (44 loc) · 881 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "precompiled.h"
const float MAX_VALUE = 999999999999999.9f;
/*
====================
Clear
Invalidates the aabb
====================
*/
void aabb::Clear()
{
max = vec3( -MAX_VALUE, -MAX_VALUE, -MAX_VALUE );
min = vec3( MAX_VALUE, MAX_VALUE, MAX_VALUE );
}
/*
====================
ContainPoint
Expand Bbox (if needed) to contain given point
====================
*/
void aabb::ContainPoint(vec3 v)
{
min.x = MIN( min.x, v.x );
min.y = MIN( min.y, v.y );
min.z = MIN( min.z, v.z );
max.x = MAX( max.x, v.x );
max.y = MAX( max.y, v.y );
max.z = MAX( max.z, v.z );
}
/*
====================
TestVector
return true of v is inside this aabb
====================
*/
bool aabb::TestVector(vec3 v)
{
if( v.x > max.x || v.x < min.x )
return false;
if( v.y > max.y || v.y < min.y )
return false;
if( v.z > max.z || v.z < min.z )
return false;
return true;
}