"L. Spiro Engine"
|
00001 00017 #ifndef __LSM_RECT3_H__ 00018 #define __LSM_RECT3_H__ 00019 00020 #include "../LSMMathLib.h" 00021 #include "../Vector/LSMVector3.h" 00022 #include "LSMRect2.h" 00023 00024 namespace lsm { 00025 00031 class CRect3 { 00032 // All is public. This class has no secrets. 00033 public : 00034 // == Various constructors. 00035 LSE_INLINE LSE_CALLCTOR CRect3(); 00036 LSE_INLINE LSE_CALLCTOR CRect3( LSREAL _fX0, LSREAL _fX1, 00037 LSREAL _fY0, LSREAL _fY1, 00038 LSREAL _fZ0, LSREAL _fZ1 ); 00039 00040 00041 // == Functions. 00047 LSE_INLINE LSREAL LSE_FCALL SizeX() const; 00048 00054 LSE_INLINE LSREAL LSE_FCALL SizeY() const; 00055 00061 LSE_INLINE LSREAL LSE_FCALL SizeZ() const; 00062 00068 LSE_INLINE CVector3 LSE_FCALL Size() const; 00069 00073 LSE_INLINE LSVOID LSE_FCALL Clear(); 00074 00078 LSE_INLINE LSVOID LSE_FCALL NegativeBox(); 00079 00085 LSE_INLINE LSVOID LSE_FCALL EnclosePoint( const CVector3 &_vPoint ); 00086 00092 LSE_INLINE LSVOID LSE_FCALL EncloseBox( const CRect3 &_rRect ); 00093 00099 LSE_INLINE LSVOID LSE_FCALL Set2D( const CRect2 &_rRect ); 00100 00101 00102 // == Members. 00106 LSREAL x0, x1; 00107 00111 LSREAL y0, y1; 00112 00116 LSREAL z0, z1; 00117 }; 00118 00119 00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00121 // DEFINITIONS 00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00123 // == Various constructors. 00124 LSE_INLINE LSE_CALLCTOR CRect3::CRect3() { 00125 } 00126 LSE_INLINE LSE_CALLCTOR CRect3::CRect3( LSREAL _fX0, LSREAL _fX1, 00127 LSREAL _fY0, LSREAL _fY1, 00128 LSREAL _fZ0, LSREAL _fZ1 ) : 00129 x0( _fX0 ), x1( _fX1 ), 00130 y0( _fY0 ), y1( _fY1 ), 00131 z0( _fZ0 ), z1( _fZ1 ) { 00132 } 00133 00134 00135 // == Functions. 00141 LSE_INLINE LSREAL LSE_FCALL CRect3::SizeX() const { return x1 - x0; } 00142 00148 LSE_INLINE LSREAL LSE_FCALL CRect3::SizeY() const { return y1 - y0; } 00149 00155 LSE_INLINE LSREAL LSE_FCALL CRect3::SizeZ() const { return z1 - z0; } 00156 00162 LSE_INLINE CVector3 LSE_FCALL CRect3::Size() const { return CVector3( SizeX(), SizeY(), SizeZ() ); } 00163 00167 LSE_INLINE LSVOID LSE_FCALL CRect3::Clear() { 00168 x0 = x1 = y0 = y1 = z0 = z1 = LSM_ZERO; 00169 } 00170 00174 LSE_INLINE LSVOID LSE_FCALL CRect3::NegativeBox() { 00175 x0 = y0 = z0 = LSM_INFINITY; 00176 x1 = y1 = z1 = -LSM_INFINITY; 00177 } 00178 00184 LSE_INLINE LSVOID LSE_FCALL CRect3::EnclosePoint( const CVector3 &_vPoint ) { 00185 x0 = CMathLib::Min( x0, _vPoint.x ); 00186 x1 = CMathLib::Max( x1, _vPoint.x ); 00187 y0 = CMathLib::Min( y0, _vPoint.y ); 00188 y1 = CMathLib::Max( y1, _vPoint.y ); 00189 z0 = CMathLib::Min( z0, _vPoint.z ); 00190 z1 = CMathLib::Max( z1, _vPoint.z ); 00191 } 00192 00198 LSE_INLINE LSVOID LSE_FCALL CRect3::EncloseBox( const CRect3 &_rRect ) { 00199 x0 = CMathLib::Min( x0, _rRect.x0 ); 00200 x1 = CMathLib::Max( x1, _rRect.x1 ); 00201 y0 = CMathLib::Min( y0, _rRect.y0 ); 00202 y1 = CMathLib::Max( y1, _rRect.y1 ); 00203 z0 = CMathLib::Min( z0, _rRect.z0 ); 00204 z1 = CMathLib::Max( z1, _rRect.z1 ); 00205 } 00206 00212 LSE_INLINE LSVOID LSE_FCALL CRect3::Set2D( const CRect2 &_rRect ) { 00213 x0 = _rRect.x0; 00214 x1 = _rRect.x1; 00215 y0 = _rRect.y0; 00216 y1 = _rRect.y1; 00217 } 00218 00219 } // namespace lsm 00220 00221 #endif // __LSM_RECT3_H__