OpenBarnyard
 
Loading...
Searching...
No Matches
AWorld.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "AWorld.h"
3
4//-----------------------------------------------------------------------------
5// Enables memory debugging.
6// Note: Should be the last include!
7//-----------------------------------------------------------------------------
9
11
13{
14 aFrustumPlanes[ 0 ].uiClipFlag = 0;
15 aFrustumPlanes[ 1 ].uiClipFlag = 0;
16 aFrustumPlanes[ 2 ].uiClipFlag = 0;
17 aFrustumPlanes[ 3 ].uiClipFlag = 0;
18 aFrustumPlanes[ 4 ].uiClipFlag = 0;
19 aFrustumPlanes[ 5 ].uiClipFlag = 0;
21}
22
24{
26
27 for ( TINT i = 0; i < iActivePlaneCount; i++ )
28 {
29 apActivePlanes[ i ] = &aFrustumPlanes[ i ].oPlane;
30 }
31}
32
34{
35 for ( TINT i = 0; i < iActivePlaneCount; )
36 {
37 TFLOAT fDistance = TVector4::DotProduct3( a_rSphere.AsVector4(), apActivePlanes[ i ]->AsVector4() ) - apActivePlanes[ i ]->GetD();
38
39 if ( a_rSphere.GetRadius() < fDistance )
40 return FISR_NOT_VISIBLE;
41
42 if ( a_rSphere.GetRadius() <= -fDistance )
43 {
46 }
47 else
48 {
49 i += 1;
50 }
51 }
52
53 if ( iActivePlaneCount == 0 )
54 return FISR_ALL_VISIBLE;
55
57}
58
59void Frustum::Transform( const Frustum& a_rFrustum, const Toshi::TMatrix44& a_rMatrix )
60{
61 for ( TINT i = 0; i < 6; i++ )
62 {
64 aFrustumPlanes[ i ].oPlane,
65 a_rMatrix,
66 a_rFrustum.aFrustumPlanes[ i ].oPlane
67 );
68
69 aFrustumPlanes[ i ].uiClipFlag = a_rFrustum.aFrustumPlanes[ i ].uiClipFlag;
70 }
71}
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
TFORCEINLINE void TSwapValues(T &a, T &b)
Definition Helpers.h:7
float TFLOAT
Definition Typedefs.h:4
int TINT
Definition Typedefs.h:7
FrustumIntersectSphereResult
Definition AWorld.h:38
@ FISR_NOT_VISIBLE
Definition AWorld.h:40
@ FISR_PARTIALLY_VISIBLE
Definition AWorld.h:41
@ FISR_ALL_VISIBLE
Definition AWorld.h:39
static void TransformPlaneOrthogonal(TPlane &a_rOutPlane, const TMatrix44 &a_rMatrix, const TPlane &a_rcSourcePlane)
Definition TMatrix44.h:239
TFLOAT constexpr DotProduct3(const TVector4 &vec) const
Definition TVector4.h:339
Toshi::TPlane oPlane
Definition AWorld.h:33
TUINT uiClipFlag
Definition AWorld.h:34
Frustum()
Definition AWorld.cpp:12
TINT iActivePlaneCount
Definition AWorld.h:58
Toshi::TPlane * apActivePlanes[6]
Definition AWorld.h:57
FrustumIntersectSphereResult IntersectSphereReduce(const Toshi::TSphere &a_rSphere)
Definition AWorld.cpp:33
void Transform(const Frustum &a_rFrustum, const Toshi::TMatrix44 &a_rMatrix)
Definition AWorld.cpp:59
void InitReduce()
Definition AWorld.cpp:23
FrustumPlane aFrustumPlanes[6]
Definition AWorld.h:56