"L. Spiro Engine"
|
00001 00017 #ifndef __LSP_TEST_H__ 00018 #define __LSP_TEST_H__ 00019 00020 #include "../LSPPhysicsLib.h" 00021 #include "../BoundingBoxes/LSPAabb.h" 00022 #include "../BoundingBoxes/LSPAabb2d.h" 00023 #include "../BoundingBoxes/LSPCappedKDop.h" 00024 #include "../BoundingBoxes/LSPKDop.h" 00025 #include "Frustum/LSMFrustum.h" 00026 #include "LSPClassify.h" 00027 #include "Plane/LSMPlane3.h" 00028 00029 namespace lsp { 00030 00038 class CTest { 00039 // All is public. This class has no secrets. 00040 public : 00041 // == Functions. 00049 static LSE_INLINE LSBOOL LSE_CALL AabbFrustum( const CAabb &_aAabb, const CFrustum &_fFrustum ); 00050 00059 static LSBOOL LSE_CALL AabbFrustum( const CAabb &_aAabb, const CFrustum &_fFrustum, LSBOOL &_bFully ); 00060 00068 template <unsigned _uMax> 00069 static LSE_INLINE LSBOOL LSE_CALL AabbKDop( const CAabb &_aAabb, const CCappedKDop<_uMax> &_ckdDop ); 00070 00079 template <unsigned _uMax> 00080 static LSE_INLINE LSBOOL LSE_CALL AabbKDop( const CAabb &_aAabb, const CCappedKDop<_uMax> &_ckdDop, LSBOOL &_bFully ); 00081 00089 static LSE_INLINE LSBOOL LSE_CALL AabbAabb( const CAabb &_aLeft, const CAabb &_aRight ); 00090 00098 static LSE_INLINE LSBOOL LSE_CALL Aabb2dAabb2d( const CAabb2d &_a2Left, const CAabb2d &_a2Right ); 00099 00100 }; 00101 00102 00103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00104 // DEFINITIONS 00105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00106 // == Functions. 00114 LSE_INLINE LSBOOL LSE_CALL CTest::AabbFrustum( const CAabb &_aAabb, const CFrustum &_fFrustum ) { 00115 if ( (CClassify::Aabb( _aAabb, _fFrustum[LSM_FP_LEFT] ) == LSM_PI_BACK) 00116 || (CClassify::Aabb( _aAabb, _fFrustum[LSM_FP_RIGHT] ) == LSM_PI_BACK) 00117 || (CClassify::Aabb( _aAabb, _fFrustum[LSM_FP_TOP] ) == LSM_PI_BACK) 00118 || (CClassify::Aabb( _aAabb, _fFrustum[LSM_FP_BOTTOM] ) == LSM_PI_BACK) 00119 || (CClassify::Aabb( _aAabb, _fFrustum[LSM_FP_NEAR] ) == LSM_PI_BACK) 00120 || (CClassify::Aabb( _aAabb, _fFrustum[LSM_FP_FAR] ) == LSM_PI_BACK) ) { 00121 return false; 00122 } 00123 return true; 00124 } 00125 00133 template <unsigned _uMax> 00134 LSE_INLINE LSBOOL LSE_CALL CTest::AabbKDop( const CAabb &_aAabb, const CCappedKDop<_uMax> &_ckdDop ) { 00135 for ( LSUINT32 I = _ckdDop.TotalPlanes(); I--; ) { 00136 if ( CClassify::Aabb( _aAabb, _ckdDop[I] ) == LSM_PI_BACK ) { return false; } 00137 } 00138 return true; 00139 } 00140 00149 template <unsigned _uMax> 00150 LSE_INLINE LSBOOL LSE_CALL CTest::AabbKDop( const CAabb &_aAabb, const CCappedKDop<_uMax> &_ckdDop, LSBOOL &_bFully ) { 00151 _bFully = true; 00152 for ( LSUINT32 I = _ckdDop.TotalPlanes(); I--; ) { 00153 LSM_PLANE_INTERSECT piThis = CClassify::Aabb( _aAabb, _ckdDop[I] ); 00154 if ( piThis == LSM_PI_BACK ) { return false; } 00155 if ( piThis != LSM_PI_FRONT ) { _bFully = false; } 00156 } 00157 return true; 00158 } 00159 00167 LSE_INLINE LSBOOL LSE_CALL CTest::AabbAabb( const CAabb &_aLeft, const CAabb &_aRight ) { 00168 return (_aLeft.m_vMin.x <= _aRight.m_vMax.x) && (_aLeft.m_vMin.y <= _aRight.m_vMax.y) && (_aLeft.m_vMin.z <= _aRight.m_vMax.z) && 00169 (_aLeft.m_vMax.x >= _aRight.m_vMin.x) && (_aLeft.m_vMax.y >= _aRight.m_vMin.y) && (_aLeft.m_vMax.z >= _aRight.m_vMin.z); 00170 } 00171 00179 LSE_INLINE LSBOOL LSE_CALL CTest::Aabb2dAabb2d( const CAabb2d &_a2Left, const CAabb2d &_a2Right ) { 00180 return (_a2Left.m_vMin.x <= _a2Right.m_vMax.x) && (_a2Left.m_vMin.y <= _a2Right.m_vMax.y) && 00181 (_a2Left.m_vMax.x >= _a2Right.m_vMin.x) && (_a2Left.m_vMax.y >= _a2Right.m_vMin.y); 00182 } 00183 00184 } // namespace lsp 00185 00186 #endif // __LSP_TEST_H__