121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
render_seg_new(
float vx, float vy, float vh, int mip, int x, int y, int xs, int ys)
{
struct sqr *w = wmip[mip];
int sz = ssize >> mip;
int vxx = ((int)vx + (1 << mip) / 2) >> mip;
int vyy = ((int)vy + (1 << mip) / 2) >> mip;
int lx =
vxx - lodleft; // these mark the rect inside the current rest that
// we want to render using a lower mip level
int ly = vyy - lodtop;
int rx = vxx + lodright;
int ry = vyy + lodbot;
float fsize = (float)(1 << mip);
Player *player1 = Player.player1;
for (int ox = x; ox < xs; ox++) {
// first collect occlusion information for this block
for (int oy = y; oy < ys; oy++) {
SWS(w, ox, oy, sz)->occluded =
isoccluded(player1.origin.x, player1.origin.y,
(float)(ox << mip), (float)(oy << mip), fsize);
}
}
int pvx = (int)vx >> mip;
int pvy = (int)vy >> mip;
if (pvx >= 0 && pvy >= 0 && pvx < sz && pvy < sz) {
// SWS(w,vxx,vyy,sz)->occluded = 0;
|
<
|
|
>
|
|
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
render_seg_new(
float vx, float vy, float vh, int mip, int x, int y, int xs, int ys)
{
struct sqr *w = wmip[mip];
int sz = ssize >> mip;
int vxx = ((int)vx + (1 << mip) / 2) >> mip;
int vyy = ((int)vy + (1 << mip) / 2) >> mip;
// these mark the rect inside the current rest that we want to render
// using a lower mip level
int lx = vxx - lodleft;
int ly = vyy - lodtop;
int rx = vxx + lodright;
int ry = vyy + lodbot;
float fsize = (float)(1 << mip);
Player *player1 = Player.player1;
for (int ox = x; ox < xs; ox++) {
// first collect occlusion information for this block
for (int oy = y; oy < ys; oy++) {
SWS(w, ox, oy, sz)->occluded =
isoccluded(player1.origin.x, player1.origin.y,
(float)(ox << mip), (float)(oy << mip), fsize);
}
}
int pvx = (int)vx >> mip;
int pvy = (int)vy >> mip;
if (pvx >= 0 && pvy >= 0 && pvx < sz && pvy < sz) {
// SWS(w,vxx,vyy,sz)->occluded = 0;
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
// loop through the rect 3 times (for floor/ceil/walls seperately, to
// facilitate dynamic stripify) for each we skip occluded cubes
// (occlusion at higher mip levels is a big time saver!). during the
// first loop (ceil) we collect cubes that lie within the lower mip rect
// and are also deferred, and render them recursively. Anything left
// (perfect mips and higher lods) we render here.
#define LOOPH \
{ \
for (int xx = x; xx < xs; xx++) \
for (int yy = y; yy < ys; yy++) { \
struct sqr *s = SWS(w, xx, yy, sz); \
if (s->occluded == 1) \
continue; \
if (s->defer && !s->occluded && mip && \
xx >= lx && xx < rx && yy >= ly && \
yy < ry)
#define LOOPD \
struct sqr *t = SWS(s, 1, 0, sz); \
struct sqr *u = SWS(s, 1, 1, sz); \
struct sqr *v = SWS(s, 0, 1, sz);
LOOPH // ceils
{
int start = yy;
struct sqr *next;
while (yy < ys - 1 && (next = SWS(w, xx, yy + 1, sz))->defer &&
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
// loop through the rect 3 times (for floor/ceil/walls seperately, to
// facilitate dynamic stripify) for each we skip occluded cubes
// (occlusion at higher mip levels is a big time saver!). during the
// first loop (ceil) we collect cubes that lie within the lower mip rect
// and are also deferred, and render them recursively. Anything left
// (perfect mips and higher lods) we render here.
#define LOOPH \
{ \
for (int xx = x; xx < xs; xx++) \
for (int yy = y; yy < ys; yy++) { \
struct sqr *s = SWS(w, xx, yy, sz); \
if (s->occluded == 1) \
continue; \
if (s->defer && !s->occluded && mip && \
xx >= lx && xx < rx && yy >= ly && \
yy < ry)
#define LOOPD \
struct sqr *t = SWS(s, 1, 0, sz); \
struct sqr *u = SWS(s, 1, 1, sz); \
struct sqr *v = SWS(s, 0, 1, sz);
LOOPH // ceils
{
int start = yy;
struct sqr *next;
while (yy < ys - 1 && (next = SWS(w, xx, yy + 1, sz))->defer &&
|