OpenGTA/math/obox.h

46 lines
1.3 KiB
C
Raw Normal View History

2015-12-03 00:37:02 +00:00
#include "math3d.h"
// see: from: http://www.3dkingdoms.com/weekly/weekly.php?a=21
// basically the same as bbox.h/.cpp but using coldet math
class OBox
{
public:
OBox() {}
OBox( const Matrix3D & m, const Vector3D & extent )
{ Set( m, extent ); }
OBox( const Matrix3D & m, const Vector3D & low, const Vector3D & high )
{ Set( m, low, high ); }
2015-12-03 00:37:37 +00:00
OBox( const OBox & other)
{ Set( other.m_M, other.m_Extent ); }
2015-12-03 00:37:02 +00:00
void Set( const Matrix3D & m, const Vector3D & extent )
{
m_M = m;
m_Extent = extent;
}
void Set( const Matrix3D & m, const Vector3D & low, const Vector3D & high )
{
m_M = m;
m_M.Translate( 0.5f * (low + high) );
m_Extent = 0.5f * (high - low);
}
2015-12-03 00:37:37 +00:00
Vector3D GetSize() const
2015-12-03 00:37:02 +00:00
{ return 2.0f * m_Extent; }
2015-12-03 00:37:37 +00:00
Vector3D GetCenterPoint() const
2015-12-03 00:37:02 +00:00
{ return m_M.GetTranslate(); }
2015-12-03 00:37:37 +00:00
void GetInvRot( Vector3D *pvRot ) const;
2015-12-03 00:37:02 +00:00
2015-12-03 00:37:37 +00:00
bool IsPointInBox( const Vector3D & p ) const ;
bool IsBoxInBox( OBox & box ) const ;
bool IsSphereInBox( const Vector3D & p, float fRadius ) const ;
bool IsLineInBox( const Vector3D & l1, const Vector3D & l2 ) const ;
bool BoxOutsidePlane( const Vector3D & normal, const Vector3D & p ) const ;
2015-12-03 00:37:02 +00:00
// Data
Matrix3D m_M;
Vector3D m_Extent;
};