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