Skip to content

Commit 521f856

Browse files
committed
Reformat: xrCDB
1 parent ef48491 commit 521f856

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+14053
-12713
lines changed

src/xrCDB/Frustum.cpp

Lines changed: 416 additions & 375 deletions
Large diffs are not rendered by default.

src/xrCDB/Frustum.h

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,93 +11,94 @@
1111

1212
#include "xrCore/fixedvector.h"
1313

14-
#pragma pack(push,4)
14+
#pragma pack(push, 4)
1515

16-
enum EFC_Visible {
17-
fcvNone = 0,
18-
fcvPartial,
19-
fcvFully,
20-
fcv_forcedword = u32(-1)
16+
enum EFC_Visible
17+
{
18+
fcvNone = 0,
19+
fcvPartial,
20+
fcvFully,
21+
fcv_forcedword = u32(-1)
2122
};
2223

24+
#define FRUSTUM_MAXPLANES 12
25+
#define FRUSTUM_P_LEFT (1 << 0)
26+
#define FRUSTUM_P_RIGHT (1 << 1)
27+
#define FRUSTUM_P_TOP (1 << 2)
28+
#define FRUSTUM_P_BOTTOM (1 << 3)
29+
#define FRUSTUM_P_NEAR (1 << 4)
30+
#define FRUSTUM_P_FAR (1 << 5)
2331

24-
#define FRUSTUM_MAXPLANES 12
25-
#define FRUSTUM_P_LEFT (1<<0)
26-
#define FRUSTUM_P_RIGHT (1<<1)
27-
#define FRUSTUM_P_TOP (1<<2)
28-
#define FRUSTUM_P_BOTTOM (1<<3)
29-
#define FRUSTUM_P_NEAR (1<<4)
30-
#define FRUSTUM_P_FAR (1<<5)
31-
32-
#define FRUSTUM_P_LRTB (FRUSTUM_P_LEFT|FRUSTUM_P_RIGHT|FRUSTUM_P_TOP|FRUSTUM_P_BOTTOM)
33-
#define FRUSTUM_P_ALL (FRUSTUM_P_LRTB|FRUSTUM_P_NEAR|FRUSTUM_P_FAR)
32+
#define FRUSTUM_P_LRTB (FRUSTUM_P_LEFT | FRUSTUM_P_RIGHT | FRUSTUM_P_TOP | FRUSTUM_P_BOTTOM)
33+
#define FRUSTUM_P_ALL (FRUSTUM_P_LRTB | FRUSTUM_P_NEAR | FRUSTUM_P_FAR)
3434

35-
#define FRUSTUM_SAFE (FRUSTUM_MAXPLANES*4)
36-
typedef svector<Fvector,FRUSTUM_SAFE> sPoly;
37-
extern u32 frustum_aabb_remap[8][6];
35+
#define FRUSTUM_SAFE (FRUSTUM_MAXPLANES * 4)
36+
typedef svector<Fvector, FRUSTUM_SAFE> sPoly;
37+
extern u32 frustum_aabb_remap[8][6];
3838

39-
class XRCDB_API CFrustum
39+
class XRCDB_API CFrustum
4040
{
4141
public:
42-
struct fplane : public Fplane
43-
{
44-
u32 aabb_overlap_id; // [0..7]
45-
void cache ();
46-
};
47-
fplane planes [FRUSTUM_MAXPLANES];
48-
int p_count;
49-
50-
public:
51-
ICF EFC_Visible AABB_OverlapPlane (const fplane& P, const float* mM) const
52-
{
53-
// calc extreme pts (neg,pos) along normal axis (pos in dir of norm, etc.)
54-
u32* id = frustum_aabb_remap[P.aabb_overlap_id];
55-
56-
Fvector Neg;
57-
Neg.set (mM[id[3]],mM[id[4]],mM[id[5]]);
58-
if (P.classify(Neg) > 0) return fcvNone;
59-
60-
Fvector Pos;
61-
Pos.set (mM[id[0]],mM[id[1]],mM[id[2]]);
62-
if (P.classify(Pos) <= 0) return fcvFully;
42+
struct fplane : public Fplane
43+
{
44+
u32 aabb_overlap_id; // [0..7]
45+
void cache();
46+
};
47+
fplane planes[FRUSTUM_MAXPLANES];
48+
int p_count;
6349

64-
return fcvPartial;
65-
}
6650
public:
67-
IC void _clear () { p_count=0; }
68-
void _add (Fplane &P);
69-
void _add (Fvector& P1, Fvector& P2, Fvector& P3);
70-
71-
void SimplifyPoly_AABB (sPoly* P, Fplane& plane);
72-
73-
void CreateOccluder (Fvector* p, int count, Fvector& vBase, CFrustum& clip);
74-
BOOL CreateFromClipPoly (Fvector* p, int count, Fvector& vBase, CFrustum& clip); // returns 'false' if creation failed
75-
void CreateFromPoints (Fvector* p, int count, Fvector& vBase );
76-
void CreateFromMatrix (Fmatrix &M, u32 mask);
77-
void CreateFromPortal (sPoly* P, Fvector& vPN, Fvector& vBase, Fmatrix& mFullXFORM);
78-
void CreateFromPlanes (Fplane* p, int count);
51+
ICF EFC_Visible AABB_OverlapPlane(const fplane& P, const float* mM) const
52+
{
53+
// calc extreme pts (neg,pos) along normal axis (pos in dir of norm, etc.)
54+
u32* id = frustum_aabb_remap[P.aabb_overlap_id];
7955

80-
sPoly* ClipPoly (sPoly& src, sPoly& dest) const;
56+
Fvector Neg;
57+
Neg.set(mM[id[3]], mM[id[4]], mM[id[5]]);
58+
if (P.classify(Neg) > 0) return fcvNone;
8159

82-
u32 getMask () const { return (1<<p_count)-1; }
60+
Fvector Pos;
61+
Pos.set(mM[id[0]], mM[id[1]], mM[id[2]]);
62+
if (P.classify(Pos) <= 0) return fcvFully;
8363

84-
EFC_Visible testSphere (Fvector& c, float r, u32& test_mask) const;
85-
BOOL testSphere_dirty (Fvector& c, float r) const;
86-
EFC_Visible testAABB (const float* mM, u32& test_mask) const;
87-
EFC_Visible testSAABB (Fvector& c, float r, const float* mM, u32& test_mask) const;
88-
BOOL testPolyInside_dirty(Fvector* p, int count) const;
64+
return fcvPartial;
65+
}
8966

90-
IC BOOL testPolyInside (sPoly& src) const
67+
public:
68+
IC void _clear() { p_count = 0; }
69+
void _add(Fplane& P);
70+
void _add(Fvector& P1, Fvector& P2, Fvector& P3);
71+
72+
void SimplifyPoly_AABB(sPoly* P, Fplane& plane);
73+
74+
void CreateOccluder(Fvector* p, int count, Fvector& vBase, CFrustum& clip);
75+
BOOL CreateFromClipPoly(
76+
Fvector* p, int count, Fvector& vBase, CFrustum& clip); // returns 'false' if creation failed
77+
void CreateFromPoints(Fvector* p, int count, Fvector& vBase);
78+
void CreateFromMatrix(Fmatrix& M, u32 mask);
79+
void CreateFromPortal(sPoly* P, Fvector& vPN, Fvector& vBase, Fmatrix& mFullXFORM);
80+
void CreateFromPlanes(Fplane* p, int count);
81+
82+
sPoly* ClipPoly(sPoly& src, sPoly& dest) const;
83+
84+
u32 getMask() const { return (1 << p_count) - 1; }
85+
EFC_Visible testSphere(Fvector& c, float r, u32& test_mask) const;
86+
BOOL testSphere_dirty(Fvector& c, float r) const;
87+
EFC_Visible testAABB(const float* mM, u32& test_mask) const;
88+
EFC_Visible testSAABB(Fvector& c, float r, const float* mM, u32& test_mask) const;
89+
BOOL testPolyInside_dirty(Fvector* p, int count) const;
90+
91+
IC BOOL testPolyInside(sPoly& src) const
9192
{
92-
sPoly d;
93-
return !!ClipPoly(src,d);
93+
sPoly d;
94+
return !!ClipPoly(src, d);
9495
}
95-
IC BOOL testPolyInside (Fvector* p, int count) const
96+
IC BOOL testPolyInside(Fvector* p, int count) const
9697
{
97-
sPoly src(p,count);
98+
sPoly src(p, count);
9899
return testPolyInside(src);
99100
}
100101
};
101102
#pragma pack(pop)
102103

103-
#endif // !defined(AFX_FRUSTUM_H__E66ED755_F741_49CF_8B2A_404CCF7067F2__INCLUDED_)
104+
#endif // !defined(AFX_FRUSTUM_H__E66ED755_F741_49CF_8B2A_404CCF7067F2__INCLUDED_)

0 commit comments

Comments
 (0)