"L. Spiro Engine"
|
00001 00016 #ifndef __LSP_AABB2D_H__ 00017 #define __LSP_AABB2D_H__ 00018 00019 #include "../LSPPhysicsLib.h" 00020 #include "Matrix/LSMMatrix4x4.h" 00021 #include "Vector/LSMVector2.h" 00022 00023 namespace lsp { 00024 00025 // == Enumerations. 00029 enum LSP_AABB_2D_CORNERS { 00030 LSP_A2C_UPPER_LEFT, 00031 LSP_A2C_UPPER_RIGHT, 00032 00033 LSP_A2C_LOWER_LEFT, 00034 LSP_A2C_LOWER_RIGHT, 00035 }; 00036 00043 class CAabb2d { 00044 // All is public. This class has no secrets. 00045 public : 00046 // == Functions. 00050 LSVOID LSE_CALL MakeInfinitelySmall(); 00051 00058 LSVOID LSE_CALL ComputeAabbFromPointArray( const CVector2 * _pvPoints, LSUINT32 _uiTotal ); 00059 00067 LSVOID LSE_CALL ComputeAabbFromAabbAndMatrix( const CAabb2d &_aabb2Other, const CMatrix4x4 &_mTrans ); 00068 00074 LSVOID LSE_CALL Encompass( const CAabb2d &_aabb2Other ); 00075 00081 LSVOID LSE_CALL Encompass( const CVector2 &_vOther ); 00082 00089 LSVOID LSE_CALL GetBox( CVector2 _vPoints[4] ) const; 00090 00096 CVector2 LSE_CALL GetCenter() const; 00097 00103 LSREAL LSE_CALL GetSizeX() const; 00104 00110 LSREAL LSE_CALL GetSizeY() const; 00111 00117 LSREAL LSE_CALL GetArea() const; 00118 00119 00120 00121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00122 // DISTANCE TESTS 00123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00124 // == Points. 00131 CVector2 LSE_CALL ClosestPointToPoint( const CVector2 &_vPoint ) const; 00132 00140 LSREAL LSE_CALL GetSqDistFromPoint( const CVector2 &_vPoint ) const; 00141 00142 00143 // == Members. 00147 CVector2 m_vMin; 00148 00152 CVector2 m_vMax; 00153 }; 00154 00155 00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00157 // DEFINITIONS 00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00159 // == Functions. 00165 LSE_INLINE LSREAL LSE_CALL CAabb2d::GetSizeX() const { 00166 return m_vMax.x - m_vMin.x; 00167 } 00168 00174 LSE_INLINE LSREAL LSE_CALL CAabb2d::GetSizeY() const { 00175 return m_vMax.y - m_vMin.y; 00176 } 00177 00178 } // namespace lsp 00179 00180 #endif // __LSP_AABB2D_H__