00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 INLINE_MATHUTIL BoundingBox::
00022 BoundingBox() {
00023 }
00024
00025
00026
00027
00028
00029
00030 INLINE_MATHUTIL BoundingBox::
00031 BoundingBox(const LPoint3 &min, const LPoint3 &max) :
00032 _min(min), _max(max)
00033 {
00034 #ifdef NDEBUG
00035 _flags = F_empty;
00036 nassertv(!_min.is_nan() && !_max.is_nan());
00037 nassertv(_min[0] <= _max[0] && _min[1] <= _max[1] && _min[2] <= _max[2]);
00038 #endif // NDEBUG
00039 _flags = 0;
00040 }
00041
00042
00043
00044
00045
00046
00047
00048
00049 INLINE_MATHUTIL const LPoint3 &BoundingBox::
00050 get_minq() const {
00051 nassertr(!is_empty(), _min);
00052 nassertr(!is_infinite(), _min);
00053 return _min;
00054 }
00055
00056
00057
00058
00059
00060
00061
00062
00063 INLINE_MATHUTIL const LPoint3 &BoundingBox::
00064 get_maxq() const {
00065 nassertr(!is_empty(), _max);
00066 nassertr(!is_infinite(), _max);
00067 return _max;
00068 }
00069
00070
00071
00072
00073
00074
00075 INLINE_MATHUTIL int BoundingBox::
00076 get_num_points() const {
00077 return 8;
00078 }
00079
00080
00081
00082
00083
00084
00085 INLINE_MATHUTIL LPoint3 BoundingBox::
00086 get_point(int n) const {
00087 nassertr(n >= 0 && n < 8, LPoint3::zero());
00088
00089
00090
00091 const LPoint3 *a = &_min;
00092 return LPoint3(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]);
00093 }
00094
00095
00096
00097
00098
00099
00100 INLINE_MATHUTIL int BoundingBox::
00101 get_num_planes() const {
00102 return 6;
00103 }
00104
00105
00106
00107
00108
00109
00110 INLINE_MATHUTIL LPlane BoundingBox::
00111 get_plane(int n) const {
00112 nassertr(n >= 0 && n < 6, LPlane());
00113 return LPlane(get_point(plane_def[n][0]),
00114 get_point(plane_def[n][1]),
00115 get_point(plane_def[n][2]));
00116 }