| 20 |
|
#define vfork fork |
| 21 |
|
#endif |
| 22 |
|
|
| 23 |
< |
#define NSCANS 32 /* number of scanlines to buffer */ |
| 23 |
> |
#define NSCANS 64 /* number of scanlines to buffer */ |
| 24 |
|
|
| 25 |
|
int rt_pid = -1; /* process id for rtrace */ |
| 26 |
|
int fd_tort, fd_fromrt; /* pipe descriptors */ |
| 149 |
|
float *vb; |
| 150 |
|
{ |
| 151 |
|
float rt_buf[6*MAXPIX]; /* rtrace send/receive buffer */ |
| 152 |
< |
int npix_tort; /* number of pixels in buffer */ |
| 152 |
> |
register int n; /* number of pixels in buffer */ |
| 153 |
|
short buf_vh[MAXPIX]; /* pixel positions */ |
| 154 |
|
FVECT dir; |
| 155 |
|
register int vh; |
| 156 |
– |
register int i; |
| 156 |
|
|
| 157 |
|
if (verbose) |
| 158 |
|
fprintf(stderr, "%s: computing view span at %d...\n", |
| 159 |
|
progname, vv); |
| 160 |
< |
npix_tort = 0; |
| 160 |
> |
n = 0; |
| 161 |
|
for (vh = -hsize; vh <= hsize; vh++) { |
| 162 |
|
if (compdir(dir, vh, vv) < 0) { /* off viewable region */ |
| 163 |
|
vb[vh+hsize] = -1.0; |
| 168 |
|
if (rt_pid == -1) /* missing information */ |
| 169 |
|
continue; |
| 170 |
|
/* send to rtrace */ |
| 171 |
< |
if (npix_tort >= MAXPIX) { /* flush */ |
| 172 |
< |
rt_compute(rt_buf, npix_tort); |
| 173 |
< |
for (i = 0; i < npix_tort; i++) |
| 174 |
< |
vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i); |
| 176 |
< |
npix_tort = 0; |
| 171 |
> |
if (n >= MAXPIX) { /* flush */ |
| 172 |
> |
rt_compute(rt_buf, n); |
| 173 |
> |
while (n-- > 0) |
| 174 |
> |
vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n); |
| 175 |
|
} |
| 176 |
< |
rt_buf[6*npix_tort] = ourview.vp[0]; |
| 177 |
< |
rt_buf[6*npix_tort+1] = ourview.vp[1]; |
| 178 |
< |
rt_buf[6*npix_tort+2] = ourview.vp[2]; |
| 179 |
< |
rt_buf[6*npix_tort+3] = dir[0]; |
| 180 |
< |
rt_buf[6*npix_tort+4] = dir[1]; |
| 181 |
< |
rt_buf[6*npix_tort+5] = dir[2]; |
| 182 |
< |
buf_vh[npix_tort++] = vh; |
| 176 |
> |
rt_buf[6*n] = ourview.vp[0]; |
| 177 |
> |
rt_buf[6*n+1] = ourview.vp[1]; |
| 178 |
> |
rt_buf[6*n+2] = ourview.vp[2]; |
| 179 |
> |
rt_buf[6*n+3] = dir[0]; |
| 180 |
> |
rt_buf[6*n+4] = dir[1]; |
| 181 |
> |
rt_buf[6*n+5] = dir[2]; |
| 182 |
> |
buf_vh[n++] = vh; |
| 183 |
|
} |
| 186 |
– |
if (npix_tort > 0) { /* process pending buffer */ |
| 187 |
– |
rt_compute(rt_buf, npix_tort); |
| 188 |
– |
for (i = 0; i < npix_tort; i++) |
| 189 |
– |
vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i); |
| 190 |
– |
} |
| 184 |
|
if (verbose) |
| 185 |
|
pict_stats(); |
| 186 |
+ |
if (n > 0) { /* process pending buffer */ |
| 187 |
+ |
rt_compute(rt_buf, n); |
| 188 |
+ |
while (n-- > 0) |
| 189 |
+ |
vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n); |
| 190 |
+ |
} |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
|
| 296 |
|
perror(progname); |
| 297 |
|
exit(1); |
| 298 |
|
} |
| 299 |
+ |
close(p0[0]); |
| 300 |
+ |
close(p1[1]); |
| 301 |
|
fd_tort = p0[1]; |
| 302 |
|
fd_fromrt = p1[0]; |
| 303 |
|
} |