-
Notifications
You must be signed in to change notification settings - Fork 9
/
CBBoxInt32.cpp
126 lines (101 loc) · 4.41 KB
/
CBBoxInt32.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//=============================================================================
//CBBoxInt32
// 3D bounding box with int32 coordinates
//
//=============================================================================
// (C) 2005 ATI Research, Inc., All rights reserved.
//=============================================================================
#include "CBBoxInt32.h"
#define CP_MIN_INT32 0x80000000
#define CP_MAX_INT32 0x7fffffff
#define CP_MIN(a, b) (((a) < (b)) ? (a) : (b))
#define CP_MAX(a, b) (((a) > (b)) ? (a) : (b))
//--------------------------------------------------------------------------------------
// CBBoxInt32
//--------------------------------------------------------------------------------------
CBBoxInt32::CBBoxInt32(void)
{
Clear();
}
//--------------------------------------------------------------------------------------
// Text to see if CBBoxInt32 is empty or not
//--------------------------------------------------------------------------------------
bool8 CBBoxInt32::Empty(void)
{
if( (m_minCoord[0] > m_maxCoord[0]) ||
(m_minCoord[1] > m_maxCoord[1]) ||
(m_minCoord[2] > m_maxCoord[2]) )
{
return TRUE;
}
else
{
return FALSE;
}
}
//--------------------------------------------------------------------------------------
// Clear bounding box extents
//--------------------------------------------------------------------------------------
void CBBoxInt32::Clear(void)
{
m_minCoord[0] = CP_MAX_INT32;
m_minCoord[1] = CP_MAX_INT32;
m_minCoord[2] = CP_MAX_INT32;
m_maxCoord[0] = CP_MIN_INT32;
m_maxCoord[1] = CP_MIN_INT32;
m_maxCoord[2] = CP_MIN_INT32;
}
//--------------------------------------------------------------------------------------
// Augment bounding box extents by specifying point to include in bounding box
//--------------------------------------------------------------------------------------
void CBBoxInt32::Augment(int32 aX, int32 aY, int32 aZ)
{
m_minCoord[0] = CP_MIN( m_minCoord[0], aX );
m_minCoord[1] = CP_MIN( m_minCoord[1], aY );
m_minCoord[2] = CP_MIN( m_minCoord[2], aZ );
m_maxCoord[0] = CP_MAX( m_maxCoord[0], aX );
m_maxCoord[1] = CP_MAX( m_maxCoord[1], aY );
m_maxCoord[2] = CP_MAX( m_maxCoord[2], aZ );
}
//--------------------------------------------------------------------------------------
// Augment bounding box extents by specifying x coordinate to include in bounding box
//--------------------------------------------------------------------------------------
void CBBoxInt32::AugmentX(int32 aX)
{
m_minCoord[0] = CP_MIN( m_minCoord[0], aX );
m_maxCoord[0] = CP_MAX( m_maxCoord[0], aX );
}
//--------------------------------------------------------------------------------------
// Augment bounding box extents by specifying x coordinate to include in bounding box
//--------------------------------------------------------------------------------------
void CBBoxInt32::AugmentY(int32 aY)
{
m_minCoord[1] = CP_MIN( m_minCoord[1], aY );
m_maxCoord[1] = CP_MAX( m_maxCoord[1], aY );
}
//--------------------------------------------------------------------------------------
// Augment bounding box extents by specifying x coordinate to include in bounding box
//--------------------------------------------------------------------------------------
void CBBoxInt32::AugmentZ(int32 aZ)
{
m_minCoord[2] = CP_MIN( m_minCoord[2], aZ );
m_maxCoord[2] = CP_MAX( m_maxCoord[2], aZ );
}
//--------------------------------------------------------------------------------------
// Clamp minimum values in bbox to be no larger than aX, aY, aZ
//--------------------------------------------------------------------------------------
void CBBoxInt32::ClampMin(int32 aX, int32 aY, int32 aZ)
{
m_minCoord[0] = CP_MAX( m_minCoord[0], aX );
m_minCoord[1] = CP_MAX( m_minCoord[1], aY );
m_minCoord[2] = CP_MAX( m_minCoord[2], aZ );
}
//--------------------------------------------------------------------------------------
// Clamp maximum values in bbox to be no larger than aX, aY, aZ
//--------------------------------------------------------------------------------------
void CBBoxInt32::ClampMax(int32 aX, int32 aY, int32 aZ)
{
m_maxCoord[0] = CP_MIN( m_maxCoord[0], aX );
m_maxCoord[1] = CP_MIN( m_maxCoord[1], aY );
m_maxCoord[2] = CP_MIN( m_maxCoord[2], aZ );
}