15 |
|
#ifdef BSD |
16 |
|
#include <sys/time.h> |
17 |
|
#include <sys/resource.h> |
18 |
– |
#else |
19 |
– |
#include <signal.h> |
18 |
|
#endif |
19 |
+ |
|
20 |
+ |
#include <signal.h> |
21 |
|
#include <fcntl.h> |
22 |
|
|
23 |
|
#include "view.h" |
41 |
|
double shadthresh = .05; /* shadow threshold */ |
42 |
|
double shadcert = .5; /* shadow certainty */ |
43 |
|
int directrelay = 0; /* number of source relays */ |
44 |
+ |
int vspretest = 512; /* virtual source pretest density */ |
45 |
+ |
int directinvis = 0; /* sources invisible? */ |
46 |
|
|
47 |
|
int maxdepth = 6; /* maximum recursion depth */ |
48 |
|
double minweight = 5e-3; /* minimum ray weight */ |
122 |
|
float *zbar[MAXDIV+1]; /* z values */ |
123 |
|
int ypos; /* current scanline */ |
124 |
|
int ystep; /* current y step size */ |
125 |
+ |
int hstep; /* h step size */ |
126 |
|
int zfd; |
127 |
|
COLOR *colptr; |
128 |
|
float *zptr; |
168 |
|
pctdone = 100.0*i/vresolu; |
169 |
|
if (ralrm > 0) /* report init stats */ |
170 |
|
report(); |
171 |
+ |
#ifndef BSD |
172 |
+ |
else |
173 |
+ |
#endif |
174 |
+ |
signal(SIGALRM, report); |
175 |
|
ypos = vresolu-1 - i; |
176 |
< |
fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); |
177 |
< |
ystep = psample; |
176 |
> |
hstep = (psample*140+49)/99; /* quincunx sampling */ |
177 |
> |
ystep = (psample*99+70)/140; |
178 |
> |
fillscanline(scanbar[0], zbar[0], hresolu, ypos, hstep); |
179 |
|
/* compute scanlines */ |
180 |
|
for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { |
181 |
|
/* bottom adjust? */ |
190 |
|
zbar[ystep] = zbar[0]; |
191 |
|
zbar[0] = zptr; |
192 |
|
/* fill base line */ |
193 |
< |
fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); |
193 |
> |
fillscanline(scanbar[0], zbar[0], hresolu, ypos, hstep); |
194 |
|
/* fill bar */ |
195 |
|
fillscanbar(scanbar, zbar, hresolu, ypos, ystep); |
196 |
|
/* write it out */ |
197 |
+ |
#ifndef BSD |
198 |
+ |
signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ |
199 |
+ |
#endif |
200 |
|
for (i = ystep; i > 0; i--) { |
201 |
|
if (zfd != -1 && write(zfd, (char *)zbar[i], |
202 |
|
hresolu*sizeof(float)) |
211 |
|
pctdone = 100.0*(vresolu-1-ypos)/vresolu; |
212 |
|
if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) |
213 |
|
report(); |
214 |
+ |
#ifndef BSD |
215 |
+ |
else |
216 |
+ |
signal(SIGALRM, report); |
217 |
+ |
#endif |
218 |
|
} |
219 |
|
/* clean up */ |
220 |
|
if (zfd != -1) { |
245 |
|
register float *zline; |
246 |
|
int xres, y, xstep; |
247 |
|
{ |
248 |
+ |
static int nc = 0; /* number of calls */ |
249 |
|
int b = xstep; |
250 |
|
double z; |
251 |
|
register int i; |
252 |
|
|
253 |
|
z = pixvalue(scanline[0], 0, y); |
254 |
|
if (zline) zline[0] = z; |
255 |
< |
|
256 |
< |
for (i = xstep; i < xres-1+xstep; i += xstep) { |
255 |
> |
/* zig-zag start for quincunx pattern */ |
256 |
> |
for (i = nc++ & 1 ? xstep/2 : xstep; i < xres-1+xstep; i += xstep) { |
257 |
|
if (i >= xres) { |
258 |
|
xstep += xres-1-i; |
259 |
|
i = xres-1; |
368 |
|
|
369 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
370 |
|
|
371 |
< |
samplendx = 3*y + x; /* set pixel index */ |
371 |
> |
samplendx = pixnumber(x,y,hresolu,vresolu); /* set pixel index */ |
372 |
|
|
373 |
|
rayvalue(&thisray); /* trace ray */ |
374 |
|
|
427 |
|
return(y); |
428 |
|
writerr: |
429 |
|
error(SYSTEM, "write error in salvage"); |
430 |
+ |
} |
431 |
+ |
|
432 |
+ |
|
433 |
+ |
int |
434 |
+ |
pixnumber(x, y, xres, yres) /* compute pixel index (brushed) */ |
435 |
+ |
register int x, y; |
436 |
+ |
int xres, yres; |
437 |
+ |
{ |
438 |
+ |
x -= y; |
439 |
+ |
while (x < 0) |
440 |
+ |
x += xres; |
441 |
+ |
return((((x>>2)*yres + y) << 2) + (x & 3)); |
442 |
|
} |