20 |
|
#define vfork fork |
21 |
|
#endif |
22 |
|
|
23 |
< |
#define NSCANS 16 /* number of scanlines to buffer */ |
23 |
> |
#define NSCANS 32 /* number of scanlines to buffer */ |
24 |
|
|
25 |
|
int rt_pid = -1; /* process id for rtrace */ |
26 |
|
int fd_tort, fd_fromrt; /* pipe descriptors */ |
36 |
|
COLR *sl; /* scanline contents */ |
37 |
|
} scan[NSCANS]; /* buffered scanlines */ |
38 |
|
|
39 |
+ |
static long ncall = 0L; /* number of calls to getpictscan */ |
40 |
+ |
static long nread = 0L; /* number of scanlines read */ |
41 |
|
|
42 |
+ |
|
43 |
|
COLR * |
44 |
|
getpictscan(y) /* get picture scanline */ |
45 |
|
int y; |
46 |
|
{ |
47 |
|
extern long ftell(); |
45 |
– |
static long ncall = 0; |
48 |
|
int minused; |
49 |
|
register int i; |
50 |
|
/* first check our buffers */ |
60 |
|
} |
61 |
|
/* not there, read it in */ |
62 |
|
if (scanpos[y] == -1) { /* need to search */ |
61 |
– |
if (verbose) |
62 |
– |
fprintf(stderr, "%s: reading picture...\n", |
63 |
– |
progname); |
63 |
|
while (curpos > y) { |
64 |
|
scanpos[curpos] = ftell(pictfp); |
65 |
|
if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0) |
70 |
|
fprintf(stderr, "%s: picture seek error\n", progname); |
71 |
|
exit(1); |
72 |
|
} |
74 |
– |
if (verbose) |
75 |
– |
fprintf(stderr, "%s: reading scanline %d...\n", progname, y); |
73 |
|
if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0) |
74 |
|
goto readerr; |
75 |
+ |
nread++; |
76 |
|
curpos = y-1; |
77 |
|
scan[minused].lused = ncall; |
78 |
|
scan[minused].y = y; |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
+ |
pict_stats() /* print out picture read statistics */ |
87 |
+ |
{ |
88 |
+ |
static long lastcall = 0L; /* ncall at last report */ |
89 |
+ |
static long lastread = 0L; /* nread at last report */ |
90 |
+ |
|
91 |
+ |
if (ncall == lastcall) |
92 |
+ |
return; |
93 |
+ |
fprintf(stderr, "%s: %ld scanlines read, %ld reused\n", |
94 |
+ |
progname, nread-lastread, |
95 |
+ |
(ncall-lastcall)-(nread-lastread)); |
96 |
+ |
lastcall = ncall; |
97 |
+ |
lastread = nread; |
98 |
+ |
} |
99 |
+ |
|
100 |
+ |
|
101 |
|
double |
102 |
|
pict_val(vd) /* find picture value for view direction */ |
103 |
|
FVECT vd; |
175 |
|
vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i); |
176 |
|
npix_tort = 0; |
177 |
|
} |
178 |
< |
rt_buf[npix_tort] = ourview.vp[0]; |
179 |
< |
rt_buf[npix_tort+1] = ourview.vp[1]; |
180 |
< |
rt_buf[npix_tort+2] = ourview.vp[2]; |
181 |
< |
rt_buf[npix_tort+3] = dir[0]; |
182 |
< |
rt_buf[npix_tort+4] = dir[1]; |
183 |
< |
rt_buf[npix_tort+5] = dir[2]; |
178 |
> |
rt_buf[6*npix_tort] = ourview.vp[0]; |
179 |
> |
rt_buf[6*npix_tort+1] = ourview.vp[1]; |
180 |
> |
rt_buf[6*npix_tort+2] = ourview.vp[2]; |
181 |
> |
rt_buf[6*npix_tort+3] = dir[0]; |
182 |
> |
rt_buf[6*npix_tort+4] = dir[1]; |
183 |
> |
rt_buf[6*npix_tort+5] = dir[2]; |
184 |
|
buf_vh[npix_tort++] = vh; |
185 |
|
} |
186 |
|
if (npix_tort > 0) { /* process pending buffer */ |
188 |
|
for (i = 0; i < npix_tort; i++) |
189 |
|
vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i); |
190 |
|
} |
191 |
+ |
if (verbose) |
192 |
+ |
pict_stats(); |
193 |
|
} |
194 |
|
|
195 |
|
|