MCPcopy Create free account
hub / github.com/assaultcube/AC / render_seg_new

Function render_seg_new

source/src/worldrender.cpp:107–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105// mip levels only for perfect mips.
106
107void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs, int ys)
108{
109 sqr *w = wmip[mip];
110 int mfactor = sfactor - mip;
111 int sz = 1<<mfactor;
112 int vxx = ((int)vx+(1<<mip)/2)>>mip;
113 int vyy = ((int)vy+(1<<mip)/2)>>mip;
114 int lx = vxx-lodleft; // these mark the rect inside the current rest that we want to render using a lower mip level
115 int ly = vyy-lodtop;
116 int rx = vxx+lodright;
117 int ry = vyy+lodbot;
118
119 float fsize = (float)(1<<mip);
120 for(int oy = y; oy<ys; oy++) // first collect occlusion information for this block
121 {
122 sqr *s = SWS(w,x,oy,mfactor);
123 for(int ox = x; ox<xs; ox++, s++) s->occluded = isoccluded(camera1->o.x, camera1->o.y, (float)(ox<<mip), (float)(oy<<mip), fsize);
124 }
125
126 int pvx = (int)vx>>mip;
127 int pvy = (int)vy>>mip;
128 if(pvx>=0 && pvy>=0 && pvx<sz && pvy<sz)
129 {
130 //SWS(w,vxx,vyy,mfactor)->occluded = 0;
131 SWS(w, pvx, pvy, mfactor)->occluded = 0; // player cell never occluded
132 }
133
134 #define df(x) s->floor-(x->vdelta/4.0f)
135 #define dc(x) s->ceil+(x->vdelta/4.0f)
136
137 // loop through the rect 3 times (for floor/ceil/walls seperately, to facilitate dynamic stripify)
138 // for each we skip occluded cubes (occlusion at higher mip levels is a big time saver!).
139 // during the first loop (ceil) we collect cubes that lie within the lower mip rect and are
140 // also deferred, and render them recursively. Anything left (perfect mips and higher lods) we
141 // render here.
142
143 #define LOOPH {for(int yy = y; yy<ys; yy++) { sqr *s = SWS(w,x,yy,mfactor); \
144 for(int xx = x; xx<xs; xx++, s++) { if(s->occluded) continue;
145 #define LOOPD sqr *t = SWS(s,1,0,mfactor); \
146 sqr *v = SWS(s,0,1,mfactor); \
147 sqr *u = SWS(v,1,0,mfactor);
148
149 int rendered = 0;
150 LOOPH // floors
151 if(s->defer && mip && xx>=lx && xx<rx && yy>=ly && yy<ry)
152 {
153 s->occluded = 1; // shortcut for the other LOOPHs
154 int start = xx;
155 while(xx<xs-1 && s[1].defer && !s[1].occluded) {xx++; s++; if(xx<rx) s->occluded = 1;} // collect 2xN rect of lower mip
156 render_seg_new(vx, vy, vh, mip-1, start*2, yy*2, xx*2+2, yy*2+2);
157 continue;
158 }
159 rendered++;
160 switch(s->type)
161 {
162 case SPACE:
163 case CHF:
164 if(s->floor<=vh && render_floor)

Callers 1

render_worldFunction · 0.85

Calls 3

isoccludedFunction · 0.85
render_flatFunction · 0.85
addwaterquadFunction · 0.85

Tested by

no test coverage detected