OpenBarnyard
 
Loading...
Searching...
No Matches
TSphere Class Reference

#include <TSphere.h>

Public Member Functions

constexpr TSphere ()=default
 
constexpr TSphere (const TVector4 &a_rSphereData)
 
constexpr TSphere (const TVector3 &a_rOrigin, TFLOAT a_fRadius)
 
constexpr TSphere (TFLOAT a_fOriginX, TFLOAT a_fOriginY, TFLOAT a_fOriginZ, TFLOAT a_fRadius)
 
constexpr TSphere (const TSphere &a_rSphere)
 
constexpr void Set (const TVector4 &a_rSphereData)
 
constexpr void Set (const TVector3 &a_rOrigin, TFLOAT a_fRadius)
 
constexpr void Set (TFLOAT a_fOriginX, TFLOAT a_fOriginY, TFLOAT a_fOriginZ, TFLOAT a_fRadius)
 
constexpr void Set (const TSphere &a_rSphere)
 
void Union (const TSphere &a_rSphere1, const TSphere &a_rSphere2)
 
constexpr TPlane::PlaneComparison ComparePlane (const TPlane &a_rPlane)
 
constexpr TSphereoperator= (const TSphere &a_rSphere)
 
constexpr TFORCEINLINE TVector3GetOrigin ()
 
constexpr TFORCEINLINE const TVector3GetOrigin () const
 
constexpr TFORCEINLINE TFLOAT GetRadius () const
 
TFORCEINLINE TVector4AsVector4 ()
 
TFORCEINLINE const TVector4AsVector4 () const
 

Detailed Description

Definition at line 7 of file TSphere.h.

Constructor & Destructor Documentation

◆ TSphere() [1/5]

TSphere::TSphere ( )
constexprdefault

◆ TSphere() [2/5]

TSphere::TSphere ( const TVector4 & a_rSphereData)
inlineconstexpr

Definition at line 12 of file TSphere.h.

13 : m_Origin( a_rSphereData.AsVector3() ), m_fRadius( a_rSphereData.w )
14 {}
TVector3 & AsVector3()
Definition TVector4.h:321
TFLOAT w
Definition TVector4.h:367

◆ TSphere() [3/5]

TSphere::TSphere ( const TVector3 & a_rOrigin,
TFLOAT a_fRadius )
inlineconstexpr

Definition at line 16 of file TSphere.h.

17 : m_Origin( a_rOrigin ), m_fRadius( a_fRadius )
18 {}

◆ TSphere() [4/5]

TSphere::TSphere ( TFLOAT a_fOriginX,
TFLOAT a_fOriginY,
TFLOAT a_fOriginZ,
TFLOAT a_fRadius )
inlineconstexpr

Definition at line 20 of file TSphere.h.

21 : m_Origin( a_fOriginX, a_fOriginY, a_fOriginZ ), m_fRadius( a_fRadius )
22 {}

◆ TSphere() [5/5]

TSphere::TSphere ( const TSphere & a_rSphere)
inlineconstexpr

Definition at line 24 of file TSphere.h.

25 : m_Origin( a_rSphere.m_Origin ), m_fRadius( a_rSphere.m_fRadius )
26 {}

Member Function Documentation

◆ AsVector4() [1/2]

TFORCEINLINE TVector4 & TSphere::AsVector4 ( )
inline

Definition at line 111 of file TSphere.h.

111{ return *TREINTERPRETCAST( TVector4*, this ); }
#define TREINTERPRETCAST(TYPE, VALUE)
Definition Defines.h:68

◆ AsVector4() [2/2]

TFORCEINLINE const TVector4 & TSphere::AsVector4 ( ) const
inline

Definition at line 112 of file TSphere.h.

112{ return *TREINTERPRETCAST( const TVector4*, this ); }

◆ ComparePlane()

TPlane::PlaneComparison TSphere::ComparePlane ( const TPlane & a_rPlane)
inlineconstexpr

Definition at line 76 of file TSphere.h.

77 {
78 float fDist = TVector3::DotProduct( a_rPlane.GetNormal(), m_Origin ) - a_rPlane.GetD();
79
80 if ( m_fRadius < fDist )
82
83 if ( fDist < -m_fRadius )
85
87 }
@ PlaneComparison_InBack
Definition TPlane.h:13
@ PlaneComparison_Intersects
Definition TPlane.h:12
@ PlaneComparison_InFront
Definition TPlane.h:11
TFORCEINLINE constexpr TFLOAT GetD() const
Definition TPlane.h:69
TFORCEINLINE constexpr const TVector3 & GetNormal() const
Definition TPlane.h:79
static constexpr TFLOAT DotProduct(const TVector3 &vec1, const TVector3 &vec2)
Definition TVector3.h:147

◆ GetOrigin() [1/2]

TFORCEINLINE TVector3 & TSphere::GetOrigin ( )
inlineconstexpr

Definition at line 96 of file TSphere.h.

97 {
98 return m_Origin;
99 }

◆ GetOrigin() [2/2]

TFORCEINLINE const TVector3 & TSphere::GetOrigin ( ) const
inlineconstexpr

Definition at line 101 of file TSphere.h.

102 {
103 return m_Origin;
104 }

◆ GetRadius()

TFORCEINLINE TFLOAT TSphere::GetRadius ( ) const
inlineconstexpr

Definition at line 106 of file TSphere.h.

107 {
108 return m_fRadius;
109 }

◆ operator=()

TSphere & TSphere::operator= ( const TSphere & a_rSphere)
inlineconstexpr

Definition at line 89 of file TSphere.h.

90 {
91 m_Origin = a_rSphere.m_Origin;
92 m_fRadius = a_rSphere.m_fRadius;
93 return *this;
94 }

◆ Set() [1/4]

void TSphere::Set ( const TSphere & a_rSphere)
inlineconstexpr

Definition at line 46 of file TSphere.h.

47 {
48 m_Origin = a_rSphere.m_Origin;
49 m_fRadius = a_rSphere.m_fRadius;
50 }

◆ Set() [2/4]

void TSphere::Set ( const TVector3 & a_rOrigin,
TFLOAT a_fRadius )
inlineconstexpr

Definition at line 34 of file TSphere.h.

35 {
36 m_Origin = a_rOrigin;
37 m_fRadius = a_fRadius;
38 }

◆ Set() [3/4]

void TSphere::Set ( const TVector4 & a_rSphereData)
inlineconstexpr

Definition at line 28 of file TSphere.h.

29 {
30 m_Origin = a_rSphereData.AsVector3();
31 m_fRadius = a_rSphereData.w;
32 }

◆ Set() [4/4]

void TSphere::Set ( TFLOAT a_fOriginX,
TFLOAT a_fOriginY,
TFLOAT a_fOriginZ,
TFLOAT a_fRadius )
inlineconstexpr

Definition at line 40 of file TSphere.h.

41 {
42 m_Origin.Set( a_fOriginX, a_fOriginY, a_fOriginZ );
43 m_fRadius = a_fRadius;
44 }

◆ Union()

void TSphere::Union ( const TSphere & a_rSphere1,
const TSphere & a_rSphere2 )
inline

Definition at line 52 of file TSphere.h.

53 {
54 TVector3 diff = a_rSphere2.m_Origin - a_rSphere1.m_Origin;
55
56 TFLOAT fMag = diff.MagnitudeSq();
57 TFLOAT fRadDiff = a_rSphere2.m_fRadius - a_rSphere1.m_fRadius;
58
59 if ( fRadDiff <= 0.0f )
60 {
61 if ( fMag < fRadDiff * fRadDiff )
62 Set( a_rSphere1 );
63 }
64 else if ( fMag < fRadDiff * fRadDiff )
65 {
66 Set( a_rSphere2 );
67 }
68 else
69 {
70 m_fRadius = ( a_rSphere1.m_fRadius + a_rSphere2.m_fRadius + TMath::Sqrt( fMag ) ) * 0.5f;
71 diff.Multiply( ( fRadDiff - a_rSphere1.m_fRadius ) / TMath::Sqrt( fMag ) );
72 m_Origin.Add( a_rSphere1.m_Origin, diff );
73 }
74 }
float TFLOAT
Definition Typedefs.h:4
TFORCEINLINE TFLOAT Sqrt(TFLOAT a_fX)
Definition TMathInline.h:84
constexpr void Set(const TVector4 &a_rSphereData)
Definition TSphere.h:28
constexpr void Multiply(const TVector3 &vec)
Definition TVector3.h:103
constexpr TFLOAT MagnitudeSq() const
Definition TVector3.h:133

The documentation for this class was generated from the following file: