Line data Source code
1 : #ifndef RENDERVA_H_
2 : #define RENDERVA_H_
3 :
4 : struct vtxarray;
5 :
6 : struct occludequery
7 : {
8 : const void *owner;
9 : GLuint id;
10 : int fragments;
11 :
12 : void startquery() const;
13 : };
14 :
15 : class vfc
16 : {
17 : public:
18 : int isfoggedcube(const ivec &o, int size) const;
19 : int isvisiblecube(const ivec &o, int size) const;
20 : void visiblecubes(bool cull = true);
21 : bool isfoggedsphere(float rad, const vec &cv) const;
22 : int isvisiblesphere(float rad, const vec &cv) const;
23 : int isvisiblebb(const ivec &bo, const ivec &br) const;
24 : int cullfrustumsides(const vec &lightpos, float lightradius, float size, float border);
25 : private:
26 : static constexpr uint numvfc = 5;
27 : void calcvfcD();
28 : void setvfcP(const vec &bbmin = vec(-1, -1, -1), const vec &bbmax = vec(1, 1, 1));
29 :
30 : std::array<plane, numvfc> vfcP; // perpindictular vectors to view frustrum bounding planes
31 : float vfcDfog; // far plane culling distance (fog limit).
32 : std::array<float, numvfc> vfcDnear,
33 : vfcDfar;
34 : };
35 :
36 : class Occluder
37 : {
38 : public:
39 : void setupmodelquery(occludequery *q);
40 : void clearqueries();
41 : void flipqueries();
42 : void endquery();
43 : void endmodelquery(); // starts the model query (!)
44 : bool checkquery(occludequery *query, bool nowait = false);
45 : void resetqueries();
46 : int getnumqueries() const;
47 0 : occludequery *newquery(const void *owner)
48 : {
49 0 : return queryframes[flipquery].newquery(owner);
50 : }
51 : private:
52 : class queryframe
53 : {
54 : public:
55 : int cur;
56 :
57 2 : queryframe() : cur(0), max(0), defer(0) {}
58 :
59 : void flip();
60 : occludequery *newquery(const void *owner);
61 : void reset();
62 : void cleanup();
63 : private:
64 : static constexpr int maxquery = 2048;
65 :
66 : int max, defer;
67 : occludequery queries[maxquery];
68 : };
69 : static constexpr int maxqueryframes = 2;
70 : std::array<queryframe, maxqueryframes> queryframes;
71 : uint flipquery = 0;
72 :
73 : occludequery *modelquery = nullptr;
74 : int modelquerybatches = -1,
75 : modelquerymodels = -1,
76 : modelqueryattached = -1;
77 :
78 : };
79 :
80 : extern Occluder occlusionengine;
81 :
82 : extern vfc view;
83 :
84 : extern int oqfrags;
85 :
86 : extern vec shadoworigin, shadowdir;
87 : extern float shadowradius, shadowbias;
88 : extern size_t shadowside;
89 : extern int shadowspot;
90 :
91 : extern vtxarray *visibleva;
92 :
93 : extern void renderrefractmask();
94 : extern void renderalphageom(int side);
95 : extern void rendermapmodels();
96 : extern void renderoutline();
97 : extern bool renderexplicitsky(bool outline = false);
98 : extern bvec outlinecolor;
99 :
100 : extern int deferquery;
101 : extern void startbb(bool mask = true);
102 : extern void endbb(bool mask = true);
103 : extern void drawbb(const ivec &bo, const ivec &br);
104 :
105 : extern void renderdecals();
106 :
107 : struct shadowmesh;
108 : extern void clearshadowmeshes();
109 : extern void genshadowmeshes();
110 : extern shadowmesh *findshadowmesh(int idx, const extentity &e);
111 : extern void rendershadowmesh(const shadowmesh *m);
112 : extern void dynamicshadowvabounds(int mask, vec &bbmin, vec &bbmax);
113 :
114 : #endif
|